本文整理汇总了PHP中floattostring函数的典型用法代码示例。如果您正苦于以下问题:PHP floattostring函数的具体用法?PHP floattostring怎么用?PHP floattostring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了floattostring函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
function show()
{
global $CONF, $LNG, $PLANET, $USER, $db, $resource, $UNI;
//$PlanetRess = new ResourceUpdate();
//$PlanetRess->CalcResource();
//$PlanetRess->SavePlanetToDB();
$this->tplObj->loadscript('p_trader.js');
if ($_POST) {
//if($_SESSION['last']['user_side'] != 'game.php?page=p_trade'){
// $this->printMessage("Page error, err nr 5.", true, array('game.php?page=ptrade', 2));
// die();
//}
//$PlanetRess = new ResourceUpdate();
//$PlanetRess->CalcResource();
//$PlanetRess->SavePlanetToDb();
/*totalPoints
oldMetal
oldCrystal
oldDeuterium
newMetal
newCrystal
newDeuterium
*/
$total_points = isset($_POST['totalPoints']) ? $_POST['totalPoints'] : 0;
$new_metal = isset($_POST['newMetal']) ? $_POST['newMetal'] : 0;
$new_crystal = isset($_POST['newCrystal']) ? $_POST['newCrystal'] : 0;
$new_deuterium = isset($_POST['newDeuterium']) ? $_POST['newDeuterium'] : 0;
$userId = isset($_POST['userid']) ? $_POST['userid'] : null;
$recalculate = $new_metal + 2 * $new_crystal + 4 * $new_deuterium;
if ($recalculate != $total_points && $recalculate - $total_points > 2000) {
$this->printMessage("Error with inputs.", true, array('game.php?page=PTrader', 2));
die;
}
if ($new_metal < 0 || $new_crystal < 0 || $new_deuterium < 0) {
$this->printMessage("ERROR with negative numbers.", true, array('game.php?page=PTrader', 2));
die;
}
// if($USER['antimatter'] < 250 && $USER['premium_reward_days'] < TIMESTAMP){
// $this->printMessage("Not enough antimatter.", true, array('game.php?page=PTrader', 2));
// die();
// }
$PLANET['metal'] = $GLOBALS['DATABASE']->sql_escape($new_metal);
$PLANET['crystal'] = $GLOBALS['DATABASE']->sql_escape($new_crystal);
$PLANET['deuterium'] = $GLOBALS['DATABASE']->sql_escape($new_deuterium);
$GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " set `metal` = '" . $GLOBALS['DATABASE']->sql_escape($new_metal) . "', `crystal` = '" . $GLOBALS['DATABASE']->sql_escape($new_crystal) . "', `deuterium` = '" . $GLOBALS['DATABASE']->sql_escape($new_deuterium) . "' where `id` = '" . $PLANET['id'] . "' ;");
if ($USER['premium_reward_days'] < TIMESTAMP) {
//$GLOBALS['DATABASE']->query("UPDATE ".USERS." set `antimatter` = antimatter - '250' WHERE `id` = '".$USER['id']."' ;");
}
$this->printMessage("Exchange has been successfully made.", true, array('game.php?page=PTrader', 2));
die;
}
$recalculate = $PLANET['metal'] + $PLANET['crystal'] * 2 + $PLANET['deuterium'] * 4;
//$GLOBALS['DATABASE']->query("UPDATE ".USERS." set `ptrader_total` = '".$recalculate."' where `id` = '".$USER['id']."' ;");
$_SESSION['total_p'] = $recalculate;
$this->tplObj->assign_vars(array('total_points' => pretty_number(floattostring($recalculate)), 'total_points11' => floattostring($recalculate), 'planet_metal' => pretty_number($PLANET['metal']), 'planet_crystal' => pretty_number($PLANET['crystal']), 'planet_deuterium' => pretty_number($PLANET['deuterium']), 'planet_metal11' => $PLANET['metal'], 'planet_crystal11' => $PLANET['crystal'], 'planet_deuterium11' => $PLANET['deuterium'], 'planet_metal_t' => pretty_number($PLANET['metal']), 'planet_crystal_t' => pretty_number(floattostring($PLANET['crystal'] * 2)), 'planet_deuterium_t' => pretty_number(floattostring($PLANET['deuterium'] * 4))));
$this->display('page.ptrader.default.tpl');
}
示例2: calculateSteal
/**
_ \_/ |\ | /¯¯\ \ / /\ |¯¯) |_¯ \ / /¯¯\ | | |´¯|¯` | /¯¯\ |\ |5
¯ /¯\ | \| \__/ \/ /--\ |¯¯\ |__ \/ \__/ |__ \_/ | | \__/ | \|Core.
* @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
* @link: http://www.xnovarevolution.con.ar
* @package 2Moons
* @author Slaver <slaver7@gmail.com>
* @copyright 2009 Lucky <douglas@crockford.com> (XGProyecto)
* @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
* @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
* @version 1.3 (2011-01-21)
* @link http://code.google.com/p/2moons/
* Please do not remove the credits
*/
function calculateSteal($attackFleets, $defenderPlanet, $ForSim = false)
{
//Steal-Math by Slaver for 2Moons(http://www.titanspace.org) based on http://www.owiki.de/Beute
global $pricelist, $db;
$SortFleets = array();
$Sumcapacity = '0';
foreach ($attackFleets as $FleetID => $Attacker) {
$SortFleets[$FleetID] = '0';
foreach ($Attacker['detail'] as $Element => $amount) {
$SortFleets[$FleetID] = bcadd($SortFleets[$FleetID], bcmul($pricelist[$Element]['capacity'], floattostring($amount)));
}
$SortFleets[$FleetID] = bcsub($SortFleets[$FleetID], $Attacker['fleet']['fleet_resource_metal']);
$SortFleets[$FleetID] = bcsub($SortFleets[$FleetID], $Attacker['fleet']['fleet_resource_crystal']);
$SortFleets[$FleetID] = bcsub($SortFleets[$FleetID], $Attacker['fleet']['fleet_resource_deuterium']);
$SortFleets[$FleetID] = bcsub($SortFleets[$FleetID], $Attacker['fleet']['fleet_resource_norio']);
$Sumcapacity = bcadd($Sumcapacity, $SortFleets[$FleetID]);
}
$AllCapacity = $Sumcapacity;
// Step 1
$booty['metal'] = min(bcdiv($Sumcapacity, 3), bcdiv(floattostring($defenderPlanet['metal']), 2));
$Sumcapacity = bcsub($Sumcapacity, $booty['metal']);
// Step 2
$booty['crystal'] = min(bcdiv($Sumcapacity, 2), bcdiv(floattostring($defenderPlanet['crystal']), 2));
$Sumcapacity = bcsub($Sumcapacity, $booty['crystal']);
// Step 3
$booty['deuterium'] = min($Sumcapacity, bcdiv(floattostring($defenderPlanet['deuterium']), 2));
$Sumcapacity = bcsub($Sumcapacity, $booty['deuterium']);
// Step 6
$booty['norio'] = min(bcdiv($Sumcapacity, 2), bcdiv(floattostring($defenderPlanet['norio']), 2));
$Sumcapacity = bcsub($Sumcapacity, $booty['norio']);
// Step 4
$oldMetalBooty = $booty['metal'];
$booty['metal'] = bcadd($booty['metal'], min(bcdiv($Sumcapacity, 2), max(bcsub(bcdiv(floattostring($defenderPlanet['metal']), 2), $booty['metal']), 0)));
$Sumcapacity = bcsub($Sumcapacity, bcsub($booty['metal'], $oldMetalBooty));
// Step 5
$booty['crystal'] = bcadd($booty['crystal'], min($Sumcapacity, max(bcsub(bcdiv(floattostring($defenderPlanet['crystal']), 2), $booty['crystal']), 0)));
// Step 7
$booty['norio'] = bcadd($booty['norio'], min($Sumcapacity, max(bcsub(bcdiv(floattostring($defenderPlanet['norio']), 2), $booty['norio']), 0)));
if ($ForSim) {
return $booty;
}
$Qry = "";
foreach ($SortFleets as $FleetID => $Capacity) {
$Factor = bcdiv($Capacity, $AllCapacity, 10);
$Qry .= "UPDATE " . FLEETS . " SET ";
$Qry .= "`fleet_resource_metal` = `fleet_resource_metal` + '" . bcmul($booty['metal'], $Factor, 0) . "', ";
$Qry .= "`fleet_resource_crystal` = `fleet_resource_crystal` + '" . bcmul($booty['crystal'], $Factor, 0) . "', ";
$Qry .= "`fleet_resource_deuterium` = `fleet_resource_deuterium` + '" . bcmul($booty['deuterium'], $Factor, 0) . "', ";
$Qry .= "`fleet_resource_norio` = `fleet_resource_norio` + '" . bcmul($booty['norio'], $Factor, 0) . "' ";
$Qry .= "WHERE fleet_id = '" . $FleetID . "';";
}
$db->multi_query($Qry);
return $booty;
}
示例3: calculateAKSSteal
public static function calculateAKSSteal($attackFleets, $defenderPlanet, $ForSim = false)
{
//Steal-Math by Slaver for 2Moons(http://code.google.com/p/2moons/) based on http://www.owiki.de/Beute
global $pricelist;
$SortFleets = array();
foreach ($attackFleets as $FleetID => $Attacker) {
foreach ($Attacker['detail'] as $Element => $amount) {
$SortFleets[$FleetID] += $pricelist[$Element]['capacity'] * $amount;
}
$SortFleets[$FleetID] -= $Attacker['fleet']['fleet_resource_metal'] - $Attacker['fleet']['fleet_resource_crystal'] - $Attacker['fleet']['fleet_resource_deuterium'];
}
$Sumcapacity = array_sum($SortFleets);
// Step 1
$booty['metal'] = min($Sumcapacity / 3, $defenderPlanet['metal'] / 2);
$Sumcapacity -= $booty['metal'];
// Step 2
$booty['crystal'] = min($Sumcapacity / 2, $defenderPlanet['crystal'] / 2);
$Sumcapacity -= $booty['crystal'];
// Step 3
$booty['deuterium'] = min($Sumcapacity, $defenderPlanet['deuterium'] / 2);
$Sumcapacity -= $booty['deuterium'];
// Step 4
$booty['tritium'] = min($Sumcapacity, $defenderPlanet['tritium'] / 2);
$Sumcapacity -= $booty['tritium'];
// Step 5
$oldMetalBooty = $booty['metal'];
$booty['metal'] += min($Sumcapacity / 2, max($defenderPlanet['metal'] / 2 - $booty['metal'], 0));
$Sumcapacity += $oldMetalBooty - $booty['metal'];
// Step 6
$booty['crystal'] += min($Sumcapacity, max($defenderPlanet['crystal'] / 2 - $booty['crystal'], 0));
$booty['metal'] = max($booty['metal'], 0);
$booty['crystal'] = max($booty['crystal'], 0);
$booty['deuterium'] = max($booty['deuterium'], 0);
$booty['deuterium'] = max($booty['tritium'], 0);
$steal = array_map('floor', $booty);
if ($ForSim) {
return $steal;
}
$AllCapacity = array_sum($SortFleets);
$QryUpdateFleet = "";
foreach ($SortFleets as $FleetID => $Capacity) {
$QryUpdateFleet = "UPDATE {{table}} SET ";
$QryUpdateFleet .= "`fleet_resource_metal` = `fleet_resource_metal` + '" . floattostring($steal['metal'] * ($Capacity / $AllCapacity)) . "', ";
$QryUpdateFleet .= "`fleet_resource_crystal` = `fleet_resource_crystal` +'" . floattostring($steal['crystal'] * ($Capacity / $AllCapacity)) . "', ";
$QryUpdateFleet .= "`fleet_resource_deuterium` = `fleet_resource_deuterium` +'" . floattostring($steal['deuterium'] * ($Capacity / $AllCapacity)) . "', ";
$QryUpdateFleet .= "`fleet_resource_tritium` = `fleet_resource_tritium` +'" . floattostring($steal['tritium'] * ($Capacity / $AllCapacity)) . "' ";
$QryUpdateFleet .= "WHERE fleet_id = '" . $FleetID . "' ";
$QryUpdateFleet .= "LIMIT 1;";
doquery($QryUpdateFleet, 'fleets');
}
return $steal;
}
示例4: StoreGoodsToPlanet
function StoreGoodsToPlanet($Start = false)
{
global $db;
$Qry = "UPDATE " . PLANETS . " SET ";
$Qry .= "`metal` = `metal` + '" . floattostring($this->_fleet['fleet_resource_metal']) . "', ";
$Qry .= "`crystal` = `crystal` + '" . floattostring($this->_fleet['fleet_resource_crystal']) . "', ";
$Qry .= "`deuterium` = `deuterium` + '" . floattostring($this->_fleet['fleet_resource_deuterium']) . "' ";
$Qry .= "WHERE ";
$Qry .= "`id` = '" . ($Start == true ? $this->_fleet['fleet_start_id'] : $this->_fleet['fleet_end_id']) . "';";
$db->query($Qry);
$this->UpdateFleet('fleet_resource_metal', '0');
$this->UpdateFleet('fleet_resource_crystal', '0');
$this->UpdateFleet('fleet_resource_deuterium', '0');
}
示例5: ShowQuickEditorPage
function ShowQuickEditorPage()
{
global $LNG, $db, $reslist, $resource;
$action = request_var('action', '');
$edit = request_var('edit', '');
$id = request_var('id', 0);
switch ($edit) {
case 'planet':
$DataIDs = array_merge($reslist['fleet'], $reslist['build'], $reslist['defense']);
foreach ($DataIDs as $ID) {
$SpecifyItemsPQ .= "`" . $resource[$ID] . "`,";
}
$PlanetData = $db->uniquequery("SELECT " . $SpecifyItemsPQ . " `name`, `id_owner`, `planet_type`, `galaxy`, `system`, `planet`, `destruyed`, `diameter`, `field_current`, `field_current`, `field_max`, `temp_min`, `temp_max`, `metal`, `crystal`, `deuterium` FROM " . PLANETS . " WHERE `id` = '" . $id . "';");
$reslist['build'] = $reslist['allow'][$PlanetData['planet_type']];
if ($action == 'send') {
$QryUpdateString = "UPDATE " . PLANETS . " SET ";
foreach ($DataIDs as $ID) {
$QryUpdateString .= "`" . $resource[$ID] . "` = '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "', ";
}
$QryUpdateString .= "`metal` = '" . floattostring(round(abs(request_var('metal', 0.0)), 0)) . "', ";
$QryUpdateString .= "`crystal` = '" . floattostring(round(abs(request_var('crystal', 0.0)), 0)) . "', ";
$QryUpdateString .= "`deuterium` = '" . floattostring(round(abs(request_var('deuterium', 0.0)), 0)) . "', ";
$QryUpdateString .= "`field_max` = '" . request_var('field_max', 0) . "', ";
$QryUpdateString .= "`name` = '" . $db->sql_escape(request_var('name', '')) . "' ";
$QryUpdateString .= "WHERE `id` = '" . $id . "' LIMIT 1;";
$db->query($QryUpdateString);
exit(sprintf($LNG['qe_edit_sucess'], $PlanetData['name'], $PlanetData['galaxy'], $PlanetData['system'], $PlanetData['planet']));
}
$UserInfo = $db->uniquequery("SELECT `username` FROM " . USERS . " WHERE `id` = '" . $PlanetData['id_owner'] . "'");
$build = $defense = $fleet = array();
foreach ($reslist['build'] as $ID) {
$build[] = array('type' => $resource[$ID], 'name' => $LNG['tech'][$ID], 'count' => pretty_number($PlanetData[$resource[$ID]]), 'input' => $PlanetData[$resource[$ID]]);
}
foreach ($reslist['fleet'] as $ID) {
$fleet[] = array('type' => $resource[$ID], 'name' => $LNG['tech'][$ID], 'count' => pretty_number($PlanetData[$resource[$ID]]), 'input' => $PlanetData[$resource[$ID]]);
}
foreach ($reslist['defense'] as $ID) {
$defense[] = array('type' => $resource[$ID], 'name' => $LNG['tech'][$ID], 'count' => pretty_number($PlanetData[$resource[$ID]]), 'input' => $PlanetData[$resource[$ID]]);
}
$template = new template();
$template->page_header();
$template->assign_vars(array('qe_resources' => $LNG['qe_resources'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'qe_defensive' => $LNG['qe_defensive'], 'qe_fleet' => $LNG['qe_fleet'], 'qe_build' => $LNG['qe_build'], 'qe_input' => $LNG['qe_input'], 'qe_count' => $LNG['qe_count'], 'qe_name' => $LNG['qe_name'], 'qe_reset' => $LNG['qe_reset'], 'qe_send' => $LNG['qe_send'], 'qe_temp' => $LNG['qe_temp'], 'qe_fields' => $LNG['qe_fields'], 'qe_owner' => $LNG['qe_owner'], 'qe_coords' => $LNG['qe_coords'], 'qe_id' => $LNG['qe_id'], 'qe_info' => $LNG['qe_info'], 'build' => $build, 'fleet' => $fleet, 'defense' => $defense, 'id' => $id, 'ownerid' => $PlanetData['id_owner'], 'ownername' => $UserInfo['username'], 'name' => $PlanetData['name'], 'galaxy' => $PlanetData['galaxy'], 'system' => $PlanetData['system'], 'planet' => $PlanetData['planet'], 'field_min' => $PlanetData['field_current'], 'field_max' => $PlanetData['field_max'], 'temp_min' => $PlanetData['temp_min'], 'temp_max' => $PlanetData['temp_max'], 'metal' => floattostring($PlanetData['metal']), 'crystal' => floattostring($PlanetData['crystal']), 'deuterium' => floattostring($PlanetData['deuterium']), 'metal_c' => pretty_number($PlanetData['metal']), 'crystal_c' => pretty_number($PlanetData['crystal']), 'deuterium_c' => pretty_number($PlanetData['deuterium'])));
$template->show('adm/QuickEditorPlanet.tpl');
break;
case 'player':
break;
}
}
示例6: DoFleetJump
private function DoFleetJump()
{
global $USER, $PLANET, $resource, $LNG, $db, $reslist;
if (!$_POST) {
return false;
}
$RestString = $this->GetNextJumpWaitTime($PLANET);
$NextJumpTime = $RestString['value'];
$JumpTime = TIMESTAMP;
if ($NextJumpTime != 0) {
return $LNG['in_jump_gate_already_used'] . $RestString['string'];
}
$TargetPlanet = request_var('jmpto', 0);
$TargetGate = $db->uniquequery("SELECT `id`, `last_jump_time` FROM " . PLANETS . " WHERE `id` = '" . $TargetPlanet . "' AND `sprungtor` > '0';");
if (!isset($TargetGate)) {
return $LNG['in_jump_gate_doesnt_have_one'];
}
$RestString = $this->GetNextJumpWaitTime($TargetGate);
if ($RestString['value'] != 0) {
return $LNG['in_jump_gate_not_ready_target'] . $RestString['string'];
}
$ShipArray = array();
$SubQueryOri = "";
$SubQueryDes = "";
foreach ($reslist['fleet'] as $Ship) {
$ShipArray[$Ship] = min(max(request_var('ship' . $Ship, 0.0), 0), $PLANET[$resource[$Ship]]);
$SubQueryOri .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - '" . floattostring($ShipArray[$Ship]) . "', ";
$SubQueryDes .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` + '" . floattostring($ShipArray[$Ship]) . "', ";
$PLANET[$resource[$Ship]] -= floattostring($ShipArray[$Ship]);
}
if (empty($SubQueryOri)) {
return $LNG['in_jump_gate_error_data'];
}
$SQL = "UPDATE " . PLANETS . " SET ";
$SQL .= $SubQueryOri;
$SQL .= "`last_jump_time` = '" . $JumpTime . "' ";
$SQL .= "WHERE ";
$SQL .= "`id` = '" . $PLANET['id'] . "';";
$SQL .= "UPDATE " . PLANETS . " SET ";
$SQL .= $SubQueryDes;
$SQL .= "`last_jump_time` = '" . $JumpTime . "' ";
$SQL .= "WHERE ";
$SQL .= "`id` = '" . $TargetGate['id'] . "';";
$db->multi_query($SQL);
$PLANET['last_jump_time'] = $JumpTime;
$RestString = $this->GetNextJumpWaitTime($PLANET);
return $LNG['in_jump_gate_done'] . $RestString['string'];
}
示例7: calculateAKSSteal
public static function calculateAKSSteal($attackFleets, $defenderPlanet, $ForSim = false)
{
//Steal-Math by Slaver for 2Moons(http://www.titanspace.org) based on http://www.owiki.de/Beute
global $pricelist, $db;
$SortFleets = array();
foreach ($attackFleets as $FleetID => $Attacker) {
foreach ($Attacker['detail'] as $Element => $amount) {
if ($Element != 210) {
//fix probos capacity in attack by jstar
$SortFleets[$FleetID] += $pricelist[$Element]['capacity'] * $amount;
}
}
$SortFleets[$FleetID] -= $Attacker['fleet']['fleet_resource_metal'] - $Attacker['fleet']['fleet_resource_crystal'] - $Attacker['fleet']['fleet_resource_deuterium'];
}
$Sumcapacity = array_sum($SortFleets);
//FIX JTSAMPER
$booty['deuterium'] = min($Sumcapacity / 3, $defenderPlanet['deuterium'] / 2);
$Sumcapacity -= $booty['deuterium'];
$booty['crystal'] = min($Sumcapacity / 2, $defenderPlanet['crystal'] / 2);
$Sumcapacity -= $booty['crystal'];
$booty['metal'] = min($Sumcapacity, $defenderPlanet['metal'] / 2);
$Sumcapacity -= $booty['metal'];
$oldMetalBooty = $booty['crystal'];
$booty['crystal'] += min($Sumcapacity / 2, max($defenderPlanet['crystal'] / 2 - $booty['crystal'], 0));
$Sumcapacity += $oldMetalBooty - $booty['crystal'];
$booty['metal'] += min($Sumcapacity, max($defenderPlanet['metal'] / 2 - $booty['metal'], 0));
$booty['metal'] = max($booty['metal'], 0);
$booty['crystal'] = max($booty['crystal'], 0);
$booty['deuterium'] = max($booty['deuterium'], 0);
//END FIX
$steal = array_map('floor', $booty);
if ($ForSim) {
return $steal;
}
$AllCapacity = array_sum($SortFleets);
$QryUpdateFleet = "";
foreach ($SortFleets as $FleetID => $Capacity) {
$QryUpdateFleet = 'UPDATE {{table}} SET ';
$QryUpdateFleet .= '`fleet_resource_metal` = `fleet_resource_metal` + ' . floattostring($steal['metal'] * ($Capacity / $AllCapacity)) . ', ';
$QryUpdateFleet .= '`fleet_resource_crystal` = `fleet_resource_crystal` +' . floattostring($steal['crystal'] * ($Capacity / $AllCapacity)) . ', ';
$QryUpdateFleet .= '`fleet_resource_deuterium` = `fleet_resource_deuterium` +' . floattostring($steal['deuterium'] * ($Capacity / $AllCapacity)) . ' ';
$QryUpdateFleet .= 'WHERE fleet_id = ' . $FleetID . ' ';
$QryUpdateFleet .= 'LIMIT 1;';
doquery($QryUpdateFleet, 'fleets');
}
return $steal;
}
示例8: show
public function show()
{
global $USER, $PLANET, $resource, $pricelist, $reslist, $LNG;
$targetGalaxy = HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
$targetSystem = HTTP::_GP('system', (int) $PLANET['system']);
$targetPlanet = HTTP::_GP('planet', (int) $PLANET['planet']);
$targetType = HTTP::_GP('type', (int) $PLANET['planet_type']);
$mission = HTTP::_GP('target_mission', 0);
$Fleet = array();
$FleetRoom = 0;
$allyInfo = $GLOBALS['DATABASE']->query("SELECT FleetCapa FROM `uni1_alliance` WHERE id = " . $USER['ally_id'] . ";");
$allyInfo = $GLOBALS['DATABASE']->fetch_array($allyInfo);
$listorder = array(210, 212, 202, 203, 204, 205, 229, 209, 206, 207, 208, 217, 215, 213, 211, 220, 224, 219, 223, 225, 226, 214, 216, 230, 227, 228, 222, 218, 221);
foreach ($listorder as $id => $ShipID) {
$amount = max(0, round(HTTP::_GP('ship' . $ShipID, 0.0, 0.0)));
if ($amount < 1 || $ShipID == 212) {
continue;
}
$Fleet[$ShipID] = $amount;
$FleetRoom += $pricelist[$ShipID]['capacity'] * $amount;
$FleetRoom += $FleetRoom / 100 * getbonusOneBis(1207, $USER['academy_1207']) + $FleetRoom / 100 * $allyInfo['FleetCapa'];
}
foreach ($Fleet as $Ship => $Count) {
if ($Count > $PLANET[$resource[$Ship]]) {
$this->printMessage($LNG['fl_not_all_ship_avalible']);
}
}
$FleetRoom *= 1 + $USER['factor']['ShipStorage'];
if (empty($Fleet)) {
FleetFunctions::GotoFleetPage();
}
$FleetData = array('fleetroom' => floattostring($FleetRoom), 'gamespeed' => FleetFunctions::GetGameSpeedFactor(), 'fleetspeedfactor' => max(0, 1 + $USER['factor']['FlyTime']), 'planet' => array('galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type']), 'maxspeed' => FleetFunctions::GetFleetMaxSpeed($Fleet, $USER), 'ships' => FleetFunctions::GetFleetShipInfo($Fleet, $USER), 'fleetMinDuration' => MIN_FLEET_TIME);
$token = getRandomString();
$_SESSION['fleet'][$token] = array('time' => TIMESTAMP, 'fleet' => $Fleet, 'fleetRoom' => $FleetRoom);
$shortcutList = $this->GetUserShotcut();
$colonyList = $this->GetColonyList();
$ACSList = $this->GetAvalibleACS();
if (!empty($shortcutList)) {
$shortcutAmount = max(array_keys($shortcutList));
} else {
$shortcutAmount = 0;
}
$this->tplObj->loadscript('flotten.js');
$this->tplObj->execscript('updateVars();FleetTime();window.setInterval("FleetTime()", 1000);');
$this->tplObj->assign_vars(array('token' => $token, 'mission' => $mission, 'shortcutList' => $shortcutList, 'shortcutMax' => $shortcutAmount, 'colonyList' => $colonyList, 'ACSList' => $ACSList, 'galaxy' => $targetGalaxy, 'system' => $targetSystem, 'planet' => $targetPlanet, 'type' => $targetType, 'speedSelect' => FleetFunctions::$allowedSpeed, 'typeSelect' => array(1 => $LNG['type_planet'][1], 2 => $LNG['type_planet'][2], 3 => $LNG['type_planet'][3], 4 => $LNG['type_planet'][4]), 'fleetdata' => $FleetData));
$this->display('page.fleetStep1.default.tpl');
}
示例9: StoreGoodsToPlanet
function StoreGoodsToPlanet($Start = false)
{
global $db;
$Qry = "UPDATE " . PLANETS . " SET ";
$Qry .= "`metal` = `metal` + '" . floattostring($this->_fleet['fleet_resource_metal']) . "', ";
$Qry .= "`crystal` = `crystal` + '" . floattostring($this->_fleet['fleet_resource_crystal']) . "', ";
$Qry .= "`deuterium` = `deuterium` + '" . floattostring($this->_fleet['fleet_resource_deuterium']) . "' ";
$Qry .= "WHERE ";
if ($Start == true) {
$Qry .= "`galaxy` = '" . $this->_fleet['fleet_start_galaxy'] . "' AND `system` = '" . $this->_fleet['fleet_start_system'] . "' AND `planet` = '" . $this->_fleet['fleet_start_planet'] . "' AND `planet_type` = '" . $this->_fleet['fleet_start_type'] . "' ";
} else {
$Qry .= "`galaxy` = '" . $this->_fleet['fleet_end_galaxy'] . "' AND `system` = '" . $this->_fleet['fleet_end_system'] . "' AND `planet` = '" . $this->_fleet['fleet_end_planet'] . "' AND `planet_type` = '" . $this->_fleet['fleet_end_type'] . "' ";
}
$Qry .= "LIMIT 1;";
$db->query($Qry);
$this->UpdateFleet('fleet_resource_metal', '0');
$this->UpdateFleet('fleet_resource_crystal', '0');
$this->UpdateFleet('fleet_resource_deuterium', '0');
}
示例10: show
public function show()
{
global $USER, $PLANET, $pricelist, $reslist, $LNG;
$targetGalaxy = HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
$targetSystem = HTTP::_GP('system', (int) $PLANET['system']);
$targetPlanet = HTTP::_GP('planet', (int) $PLANET['planet']);
$targetType = HTTP::_GP('type', (int) $PLANET['planet_type']);
$mission = HTTP::_GP('target_mission', 0);
$Fleet = array();
$FleetRoom = 0;
foreach ($reslist['fleet'] as $id => $ShipID) {
$amount = max(0, round(HTTP::_GP('ship' . $ShipID, 0.0, 0.0)));
if ($amount < 1 || $ShipID == 212) {
continue;
}
$Fleet[$ShipID] = $amount;
$FleetRoom += $pricelist[$ShipID]['capacity'] * $amount;
}
$FleetRoom *= 1 + $USER['factor']['ShipStorage'];
if (empty($Fleet)) {
FleetFunctions::GotoFleetPage();
}
$FleetData = array('fleetroom' => floattostring($FleetRoom), 'gamespeed' => FleetFunctions::GetGameSpeedFactor(), 'fleetspeedfactor' => max(0, 1 + $USER['factor']['FlyTime']), 'planet' => array('galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type']), 'maxspeed' => FleetFunctions::GetFleetMaxSpeed($Fleet, $USER), 'ships' => FleetFunctions::GetFleetShipInfo($Fleet, $USER), 'fleetMinDuration' => MIN_FLEET_TIME);
$token = getRandomString();
$_SESSION['fleet'][$token] = array('time' => TIMESTAMP, 'fleet' => $Fleet, 'fleetRoom' => $FleetRoom);
$shortcutList = $this->GetUserShotcut();
$colonyList = $this->GetColonyList();
$ACSList = $this->GetAvalibleACS();
if (!empty($shortcutList)) {
$shortcutAmount = max(array_keys($shortcutList));
} else {
$shortcutAmount = 0;
}
$this->tplObj->loadscript('flotten.js');
$this->tplObj->execscript('updateVars();FleetTime();window.setInterval("FleetTime()", 1000);');
$this->assign(array('token' => $token, 'mission' => $mission, 'shortcutList' => $shortcutList, 'shortcutMax' => $shortcutAmount, 'colonyList' => $colonyList, 'ACSList' => $ACSList, 'galaxy' => $targetGalaxy, 'system' => $targetSystem, 'planet' => $targetPlanet, 'type' => $targetType, 'speedSelect' => FleetFunctions::$allowedSpeed, 'typeSelect' => array(1 => $LNG['type_planet'][1], 2 => $LNG['type_planet'][2], 3 => $LNG['type_planet'][3]), 'fleetdata' => $FleetData));
$this->display('page.fleetStep1.default.tpl');
}
示例11: SendFleet
/** FLEET FUNCTIONS **/
function SendFleet($FleetData)
{
$FleetData = array_merge(array('mission' => 3, 'galaxy' => 0, 'system' => 0, 'planet' => 0, 'planettype' => 0, 'fleetgroup' => 0, 'speed' => 10, 'metal' => 0, 'crystal' => 0, 'deuterium' => 0, 'holdingtime' => 0, 'fleet' => array()), $FleetData);
$mission = $FleetData['mission'];
$galaxy = $FleetData['galaxy'];
$system = $FleetData['system'];
$planet = $FleetData['planet'];
$planettype = $FleetData['planettype'];
$fleet_group = $FleetData['fleetgroup'];
$GenFleetSpeed = $FleetData['speed'];
$TransportMetal = $FleetData['metal'];
$TransportCrystal = $FleetData['crystal'];
$TransportDeuterium = $FleetData['deuterium'];
$holdingtime = $FleetData['holdingtime'];
$rawfleetarray = $FleetData['fleet'];
if ($planettype != 1 && $planettype != 3) {
return false;
}
if ($this->PLANET['galaxy'] == $galaxy && $this->PLANET['system'] == $system && $this->PLANET['planet'] == $planet && $this->PLANET['planet_type'] == $planettype) {
return false;
}
if ($galaxy > $CONF['max_galaxy'] || $galaxy < 1 || $system > $CONF['max_system'] || $system < 1 || $planet > $CONF['max_planets'] + 1 || $planet < 1) {
return false;
}
if (empty($mission)) {
return false;
}
$ActualFleets = parent::GetCurrentFleets($USER['id']);
if (parent::GetMaxFleetSlots($USER) <= $ActualFleets) {
return false;
}
$fleet_group_mr = 0;
if (!empty($fleet_group) && $mission == 2) {
$aks_count_mr = $db->uniquequery("SELECT COUNT(*) as state FROM " . AKS . " WHERE `id` = '" . $fleet_group . "' AND `eingeladen` LIKE '%" . $USER['id'] . "%';");
if ($aks_count_mr['state'] > 0) {
$fleet_group_mr = $fleet_group;
} else {
$mission = 1;
}
}
$ActualFleets = parent::GetCurrentFleets($USER['id']);
$TargetPlanet = $db->uniquequery("SELECT `id`, `id_owner`,`destruyed`,`ally_deposit` FROM " . PLANETS . " WHERE `universe` = '" . $UNI . "' AND `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' AND `planet_type` = '" . ($planettype == 2 ? 1 : $planettype) . "';");
if ($mission != 15 && $TargetPlanet["destruyed"] != 0 || $mission != 15 && $mission != 7 && empty($TargetPlanet['id_owner'])) {
return false;
}
$MyDBRec = $USER;
$FleetArray = parent::GetFleetArray($rawfleetarray);
if (!is_array($FleetArray)) {
return false;
}
$FleetStorage = 0;
$FleetShipCount = 0;
$fleet_array = "";
$FleetSubQRY = "";
foreach ($FleetArray as $Ship => $Count) {
if ($Count > $this->PLANET[$resource[$Ship]] || $Count < 0) {
return false;
}
$FleetStorage += $pricelist[$Ship]["capacity"] * $Count;
$FleetShipCount += $Count;
$fleet_array .= $Ship . "," . $Count . ";";
$FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - '" . floattostring($Count) . "', ";
}
$error = 0;
$fleetmission = $mission;
$YourPlanet = false;
$UsedPlanet = false;
if ($mission == 11) {
$maxexpde = parent::GetCurrentFleets($USER['id'], 11);
if ($maxexpde >= $CONF['max_dm_missions']) {
return false;
}
} elseif ($mission == 15) {
$MaxExpedition = $USER[$resource[124]];
if ($MaxExpedition == 0) {
return false;
}
$ExpeditionEnCours = parent::GetCurrentFleets($USER['id'], 15);
$EnvoiMaxExpedition = floor(sqrt($MaxExpedition));
if ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
return false;
}
}
$YourPlanet = isset($TargetPlanet['id_owner']) && $TargetPlanet['id_owner'] == $USER['id'] ? true : false;
$UsedPlanet = isset($TargetPlanet['id_owner']) ? true : false;
$HeDBRec = $YourPlanet ? $MyDBRec : GetUserByID($TargetPlanet['id_owner'], array('id', 'onlinetime', 'ally_id', 'urlaubs_modus', 'banaday', 'authattack'));
if ($HeDBRec['urlaubs_modus'] && $mission != 8) {
return false;
}
if (!$YourPlanet && ($mission == 1 || $mission == 2 || $mission == 5 || $mission == 6 || $mission == 9)) {
if ($CONF['adm_attack'] == 1 && $UsedPlanet['authattack'] > $USER['authlevel']) {
return false;
}
$UserPoints = $USER;
$User2Points = $db->uniquequery("SELECT `total_points` FROM " . STATPOINTS . " WHERE `stat_type` = '1' AND `id_owner` = '" . $HeDBRec['id'] . "';");
$IsNoobProtec = CheckNoobProtec($UserPoints, $User2Points, $HeDBRec);
if ($IsNoobProtec['NoobPlayer']) {
return false;
} elseif ($IsNoobProtec['StrongPlayer']) {
//.........这里部分代码省略.........
示例12: show
//.........这里部分代码省略.........
$elementIDd = array(212, 202, 203, 204, 205);
$elementIDa = array(209, 206, 207, 217, 215, 213, 211, 219);
$elementIDq = array(225, 226, 214, 216, 227, 228, 222, 218, 221);
}
$Missiles = array();
$Domes = array();
$Orbits = array();
foreach ($reslist['missile'] as $elementID) {
$Missiles[$elementID] = $PLANET[$resource[$elementID]];
}
foreach ($reslist['defense'] as $elementID) {
$Domes[$elementID] = $PLANET[$resource[$elementID]];
$Orbits[$elementID] = $PLANET[$resource[$elementID]];
}
$MaxMissiles = BuildFunctions::getMaxConstructibleRockets($USER, $PLANET, $Missiles);
$MaxDomes = BuildFunctions::getMaxConstructibleDomes($USER, $PLANET, $Domes);
$MaxOrbits = BuildFunctions::getMaxConstructibleOrbits($USER, $PLANET, $Orbits);
foreach ($elementALL as $Element) {
$costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
$costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
$elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
$buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
$maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
if (isset($MaxMissiles[$Element])) {
$maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
}
if (isset($MaxDomes[$Element])) {
$maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
}
if (isset($MaxOrbits[$Element])) {
$maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
}
$AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
$elementListall[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
}
foreach ($elementIDs as $Element) {
$AllTech = array();
$GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
$AllTech[] = $x;
}
}
$costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
$costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
$elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
$buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
$maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
if (isset($MaxMissiles[$Element])) {
$maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
}
if (isset($MaxDomes[$Element])) {
$maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
}
if (isset($MaxOrbits[$Element])) {
$maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
}
$AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
$elementList[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
}
foreach ($elementIDq as $Element) {
$AllTech = array();
$GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
$AllTech[] = $x;
示例13: Menus
private function Menus()
{
global $PLANET, $LNG, $USER, $CONF;
//PlanetMenu
if (empty($this->UserPlanets)) {
$this->getplanets();
}
$this->loadscript("planetmenu.js");
$this->loadscript("topnav.js");
$this->execscript("PlanetMenu();");
$this->phpself = "?page=" . request_var('page', '') . "&mode=" . request_var('mode', '');
$PlanetSelect = array();
$Scripttime = array();
foreach ($this->UserPlanets as $CurPlanetID => $PlanetQuery) {
if (!empty($PlanetQuery['b_building_id'])) {
$QueueArray = explode(";", $PlanetQuery['b_building_id']);
$ActualCount = count($QueueArray);
for ($ID = 0; $ID < $ActualCount; $ID++) {
$ListIDArray = explode(",", $QueueArray[$ID]);
if ($ListIDArray[3] > TIMESTAMP) {
$Scripttime[$PlanetQuery['id']][] = $ListIDArray[3];
}
}
}
$Planetlist[$PlanetQuery['id']] = array('url' => $this->phpself . "&cp=" . $PlanetQuery['id'], 'name' => $PlanetQuery['name'] . ($PlanetQuery['planet_type'] == 3 ? " (" . $LNG['fcm_moon'] . ")" : ""), 'image' => $PlanetQuery['image'], 'galaxy' => $PlanetQuery['galaxy'], 'system' => $PlanetQuery['system'], 'planet' => $PlanetQuery['planet'], 'ptype' => $PlanetQuery['planet_type']);
$PlanetSelect[$this->phpself . "&cp=" . $PlanetQuery['id']] = $PlanetQuery['name'] . ($PlanetQuery['planet_type'] == 3 ? " (" . $LNG['fcm_moon'] . ")" : "") . " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "] ";
}
if ($USER['urlaubs_modus'] == 1) {
$CONF['metal_basic_income'] = 0;
$CONF['crystal_basic_income'] = 0;
$CONF['deuterium_basic_income'] = 0;
$CONF['norio_basic_income'] = 0;
}
$this->assign_vars(array('PlanetMenu' => $Planetlist, 'show_planetmenu' => $LNG['show_planetmenu'], 'current_pid' => $PLANET['id'], 'Scripttime' => json_encode($Scripttime), 'lm_overview' => $LNG['lm_overview'], 'lm_empire' => $LNG['lm_empire'], 'lm_buildings' => $LNG['lm_buildings'], 'lm_resources' => $LNG['lm_resources'], 'lm_trader' => $LNG['lm_trader'], 'lm_fleettrader' => $LNG['lm_fleettrader'], 'lm_research' => $LNG['lm_research'], 'lm_shipshard' => $LNG['lm_shipshard'], 'lm_fleet' => $LNG['lm_fleet'], 'lm_technology' => $LNG['lm_technology'], 'lm_galaxy' => $LNG['lm_galaxy'], 'lm_defenses' => $LNG['lm_defenses'], 'lm_alliance' => $LNG['lm_alliance'], 'lm_forums' => $LNG['lm_forums'], 'lm_officiers' => $LNG['lm_officiers'], 'lm_statistics' => $LNG['lm_statistics'], 'lm_records' => $LNG['lm_records'], 'lm_topkb' => $LNG['lm_topkb'], 'lm_search' => $LNG['lm_search'], 'lm_battlesim' => $LNG['lm_battlesim'], 'lm_messages' => $LNG['lm_messages'], 'lm_notes' => $LNG['lm_notes'], 'lm_buddylist' => $LNG['lm_buddylist'], 'lm_chat' => $LNG['lm_chat'], 'lm_support' => $LNG['lm_support'], 'lm_faq' => $LNG['lm_faq'], 'lm_options' => $LNG['lm_options'], 'lm_banned' => $LNG['lm_banned'], 'lm_rules' => $LNG['lm_rules'], 'lm_logout' => $LNG['lm_logout'], 'new_message' => $USER['new_message'], 'forum_url' => $CONF['forum_url'], 'lm_administration' => $LNG['lm_administration'], 'topnav' => true, 'metal' => $PLANET['metal'], 'crystal' => $PLANET['crystal'], 'deuterium' => $PLANET['deuterium'], 'norio' => $PLANET['norio'], 'energy' => $PLANET["energy_max"] + $PLANET["energy_used"] < 0 ? colorRed(pretty_number($PLANET["energy_max"] + $PLANET["energy_used"]) . "/" . pretty_number($PLANET["energy_max"])) : pretty_number($PLANET["energy_max"] + $PLANET["energy_used"]) . "/" . pretty_number($PLANET["energy_max"]), 'darkmatter' => pretty_number($USER["darkmatter"]), 'metal_max' => shortly_number($PLANET["metal_max"]), 'crystal_max' => shortly_number($PLANET["crystal_max"]), 'deuterium_max' => shortly_number($PLANET["deuterium_max"]), 'norio_max' => shortly_number($PLANET["norio_max"]), 'alt_metal_max' => pretty_number($PLANET["metal_max"]), 'alt_crystal_max' => pretty_number($PLANET["crystal_max"]), 'alt_deuterium_max' => pretty_number($PLANET["deuterium_max"]), 'alt_norio_max' => pretty_number($PLANET["norio_max"]), 'js_metal_max' => floattostring($PLANET["metal_max"]), 'js_crystal_max' => floattostring($PLANET["crystal_max"]), 'js_deuterium_max' => floattostring($PLANET["deuterium_max"]), 'js_norio_max' => floattostring($PLANET["norio_max"]), 'js_metal_hr' => $PLANET['planet_type'] == 1 ? floattostring($PLANET['metal_perhour'] + $CONF['metal_basic_income'] * $CONF['resource_multiplier']) : 0, 'js_crystal_hr' => $PLANET['planet_type'] == 1 ? floattostring($PLANET['crystal_perhour'] + $CONF['crystal_basic_income'] * $CONF['resource_multiplier']) : 0, 'js_deuterium_hr' => $PLANET['planet_type'] == 1 ? floattostring($PLANET['deuterium_perhour'] + $CONF['deuterium_basic_income'] * $CONF['resource_multiplier']) : 0, 'js_norio_hr' => $PLANET['planet_type'] == 1 ? floattostring($PLANET['norio_perhour'] + $CONF['norio_basic_income'] * $CONF['resource_multiplier']) : 0, 'current_planet' => $this->phpself . "&cp=" . $PLANET['id'], 'tn_vacation_mode' => $LNG['tn_vacation_mode'], 'closed' => !$CONF['game_disable'] ? $LNG['ov_closed'] : false, 'vacation' => $USER['urlaubs_modus'] ? date(TDFORMAT, $USER['urlaubs_until']) : false, 'delete' => $USER['db_deaktjava'] ? sprintf($LNG['tn_delete_mode'], date(TDFORMAT, strtotime("+7 day", $USER['db_deaktjava']))) : false, 'image' => $PLANET['image'], 'settings_tnstor' => $USER['settings_tnstor'], 'PlanetSelect' => $PlanetSelect, 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Norio' => $LNG['Norio'], 'Darkmatter' => $LNG['Darkmatter'], 'Energy' => $LNG['Energy']));
}
示例14: show
//.........这里部分代码省略.........
$GLOBALS['DATABASE']->query("INSERT INTO `uni1_loteria` VALUES ('" . $USER['id'] . "','" . $USER['username'] . "','" . $tickets . "') ;");
$this->printMessage($LNG['boti'], true, array('game.php?page=lottery', 2));
die;
}
}
$total_users = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` from `uni1_loteria` ;");
$total_users = $GLOBALS['DATABASE']->numRows($total_users);
if ($CONF['lottery_time'] < TIMESTAMP) {
if ($total_users < $CONF['lottery_min']) {
$GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " set `lottery_prize` = `lottery_prize` + 250 ");
$time = TIMESTAMP + 24 * 60 * 60;
$GLOBALS['DATABASE']->query("UPDATE `uni1_config` SET `lottery_time` = " . $time . " where `uni` = " . $UNI . ";");
$this->printMessage("Lottery Postponing from the lack of lottery users.", true, array('game.php?page=lottery', 2));
die;
}
$get_tickets = $GLOBALS['DATABASE']->query("SELECT *FROM `uni1_loteria` ");
if ($GLOBALS['DATABASE']->numRows($get_tickets) > 0) {
$user_array = array();
$diferent_users = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` from `uni1_loteria` ;");
while ($s = $GLOBALS['DATABASE']->fetch_array($diferent_users)) {
$user_array[] = $s['id'];
}
$random = rand(0, count($user_array) - 1);
do {
$random1 = rand(0, count($user_array) - 1);
} while ($random1 == $random);
do {
$random2 = rand(0, count($user_array) - 1);
} while ($random2 == $random1 || $random2 == $random);
$total_user = $GLOBALS['DATABASE']->query("SELECT SUM(tickets) as sum_tickets, user from `uni1_loteria` where `id` = '" . $user_array[$random] . "' ;");
$total_user1 = $GLOBALS['DATABASE']->query("SELECT SUM(tickets) as sum_tickets, user from `uni1_loteria` where `id` = '" . $user_array[$random1] . "' ;");
$total_user2 = $GLOBALS['DATABASE']->query("SELECT SUM(tickets) as sum_tickets, user from `uni1_loteria` where `id` = '" . $user_array[$random2] . "' ;");
$total_user = $GLOBALS['DATABASE']->fetch_array($total_user);
$total_user1 = $GLOBALS['DATABASE']->fetch_array($total_user1);
$total_user2 = $GLOBALS['DATABASE']->fetch_array($total_user2);
$total_user_prize = $ticket_prize_dm * $total_user['sum_tickets'];
$total_user_prize1 = $ticket_prize_dm / 2 * $total_user1['sum_tickets'];
$total_user_prize2 = $ticket_prize_dm / 4 * $total_user2['sum_tickets'];
if ($USER['id'] == $user_array[$random]) {
$USER['darkmatter'] += $total_user_prize;
} else {
$GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `darkmatter` = `darkmatter` + " . $total_user_prize . " where `id` = '" . $user_array[$random] . "' AND `universe` = '" . $UNI . "';");
}
if ($USER['id'] == $user_array[$random1]) {
$USER['darkmatter'] += $total_user_prize1;
} else {
$GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `darkmatter` = `darkmatter` + " . $total_user_prize1 . " where `id` = '" . $user_array[$random1] . "' AND `universe` = '" . $UNI . "';");
}
if ($USER['id'] == $user_array[$random2]) {
$USER['darkmatter'] += $total_user_prize2;
} else {
$GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `darkmatter` = `darkmatter` + " . $total_user_prize2 . " where `id` = '" . $user_array[$random2] . "' AND `universe` = '" . $UNI . "';");
}
$GLOBALS['DATABASE']->query("TRUNCATE TABLE `uni1_loteria_log`;");
$GLOBALS['DATABASE']->query("INSERT INTO `uni1_loteria_log` VALUES('" . $total_user['user'] . "','" . TIMESTAMP . "','" . $total_user_prize . "') ");
$GLOBALS['DATABASE']->query("INSERT INTO `uni1_loteria_log` VALUES('" . $total_user1['user'] . "','" . TIMESTAMP . "','" . $total_user_prize1 . "') ");
$GLOBALS['DATABASE']->query("INSERT INTO `uni1_loteria_log` VALUES('" . $total_user2['user'] . "','" . TIMESTAMP . "','" . $total_user_prize2 . "') ");
$GLOBALS['DATABASE']->query("TRUNCATE TABLE `uni1_loteria`;");
SendSimpleMessage($user_array[$random], $user_array[$random], TIMESTAMP, 1, 'Lotery', 'You just won', 'You just won ' . $total_user_prize . ' DM in the lotery');
//Enviamos el mensaje
SendSimpleMessage($user_array[$random1], $user_array[$random1], TIMESTAMP, 1, 'Lotery', 'You just won', 'You just won ' . $total_user_prize1 . ' DM in the lotery');
SendSimpleMessage($user_array[$random2], $user_array[$random2], TIMESTAMP, 1, 'Lotery', 'You just won', 'You just won ' . $total_user_prize2 . ' DM in the lotery');
$time = TIMESTAMP + 24 * 60 * 60;
$GLOBALS['DATABASE']->query("UPDATE `uni1_config` SET `lottery_time` = " . $time . " where `uni` = " . $UNI . ";");
$this->printMessage("Lottery restarting.", true, array('game.php?page=lottery', 2));
die;
} else {
$time = TIMESTAMP + 24 * 60 * 60;
$GLOBALS['DATABASE']->query("UPDATE `uni1_config` SET `lottery_time` = " . $time . " ;");
$this->printMessage("No tickets, postponing 2.", true, array('game.php?page=lottery', 2));
die;
}
} else {
$secs = $CONF['lottery_time'] - TIMESTAMP;
$diferent_users = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` from `uni1_loteria` ;");
if ($GLOBALS['DATABASE']->numRows($diferent_users) > 0) {
$lista = '<div class="ally_contents"><tr><td>Username</td><td>Tickets Bought</td></tr>';
while ($s = $GLOBALS['DATABASE']->fetch_array($diferent_users)) {
$total_user = $GLOBALS['DATABASE']->query("SELECT user,SUM(tickets) as sum_tickets from `uni1_loteria` where `id` = '" . $s['id'] . "' ;");
$total_user = $GLOBALS['DATABASE']->fetch_array($total_user);
$lista .= '<tr><td>' . $total_user['user'] . '</td><td>' . $total_user['sum_tickets'] . '</td></tr>';
}
$lista .= '</div>';
} else {
$lista = "<p><font color='red'>There are no tickets bought</font></p>";
}
$castigatori = $GLOBALS['DATABASE']->query("SELECT *FROM `uni1_loteria_log` ORDER BY `time` DESC LIMIT 5");
if ($GLOBALS['DATABASE']->numRows($castigatori) > 0) {
$lista_winners = "<table style='width:100%'><tr><td>Winner</td><td>Time</td><td>DM WON</td></tr>";
while ($x = $GLOBALS['DATABASE']->fetch_array($castigatori)) {
$lista_winners .= "<tr><td>" . $x['username'] . "</td><td>" . gmdate("M d Y H:i:s", $x['time']) . "</td><td>" . $x['prize'] . "</td></tr>";
}
$lista_winners .= "</table>";
} else {
$lista_winners = $LNG['NoWinners'];
}
$this->tplObj->assign_vars(array('metal_p' => pretty_number(floattostring($ticket_price_metal)), 'crystal_p' => pretty_number(floattostring($ticket_price_crystal)), 'deuterium_p' => pretty_number(floattostring($ticket_price_deuterium)), 'dm_win' => $ticket_prize_dm, 'secs' => $secs, 'user_lists' => $lista, 'max_tickets_per_player' => $max_users_tickets, 'winners' => $lista_winners, 'minimum_users' => $CONF['lottery_min']));
$this->display('page.lottery.default.tpl');
}
}
示例15: TargetEvent
function TargetEvent()
{
global $resource, $reslist;
$db = Database::get();
$fleetAttack = array();
$fleetDefend = array();
$userAttack = array();
$userDefend = array();
$incomingFleets = array();
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
$debris = array();
$planetDebris = array();
$debrisResource = array(901, 902);
$messageHTML = <<<HTML
<div class="raportMessage">
\t<table>
\t\t<tr>
\t\t\t<td colspan="2"><a href="game.php?page=raport&raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span class="%s">%s: %s</span> <span class="%s">%s: %s</span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s: <span class="reportSteal element901">%s</span> </span><span>%s: <span class="reportSteal element902">%s</span> </span><span>%s: <span class="reportSteal element903">%s</span></span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s: <span class="reportDebris element901">%s</span> </span><span>%s: <span class="reportDebris element902">%s</span></span></td>
\t\t</tr>
\t</table>
</div>
HTML;
//Minize HTML
$messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
$sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
$targetPlanet = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id']));
$sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
$targetUser = $db->selectSingle($sql, array(':userId' => $targetPlanet['id_owner']));
$targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
$planetUpdater = new ResourceUpdate();
list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
if ($this->_fleet['fleet_group'] != 0) {
$sql = "DELETE FROM %%AKS%% WHERE id = :acsId;";
$db->delete($sql, array(':acsId' => $this->_fleet['fleet_group']));
$sql = "SELECT * FROM %%FLEETS%% WHERE fleet_group = :acsId;";
$incomingFleetsResult = $db->select($sql, array(':acsId' => $this->_fleet['fleet_group']));
foreach ($incomingFleetsResult as $incomingFleetRow) {
$incomingFleets[$incomingFleetRow['fleet_id']] = $incomingFleetRow;
}
unset($incomingFleetsResult);
} else {
$incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
}
foreach ($incomingFleets as $fleetID => $fleetDetail) {
$sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
$fleetAttack[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner']));
$fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetAttack[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']);
$userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
}
$sql = "SELECT * FROM %%FLEETS%%\n\t\tWHERE fleet_mission\t\t= :mission\n\t\tAND fleet_end_id\t\t= :fleetEndId\n\t\tAND fleet_start_time \t<= :timeStamp\n\t\tAND fleet_end_stay \t\t>= :timeStamp;";
$targetFleetsResult = $db->select($sql, array(':mission' => 5, ':fleetEndId' => $this->_fleet['fleet_end_id'], ':timeStamp' => TIMESTAMP));
foreach ($targetFleetsResult as $fleetDetail) {
$fleetID = $fleetDetail['fleet_id'];
$sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
$fleetDefend[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner']));
$fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetDefend[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']);
$userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
}
unset($targetFleetsResult);
$fleetDefend[0]['player'] = $targetUser;
$fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
$fleetDefend[0]['unit'] = array();
foreach (array_merge($reslist['fleet'], $reslist['defense']) as $elementID) {
if (empty($targetPlanet[$resource[$elementID]])) {
continue;
}
$fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];
}
$userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
require_once 'includes/classes/missions/functions/calculateAttack.php';
$fleetIntoDebris = Config::get($this->_fleet['fleet_universe'])->Fleet_Cdr;
$defIntoDebris = Config::get($this->_fleet['fleet_universe'])->Defs_Cdr;
$combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
foreach ($fleetAttack as $fleetID => $fleetDetail) {
$fleetArray = '';
$totalCount = 0;
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);
foreach ($fleetDetail['unit'] as $elementID => $amount) {
$fleetArray .= $elementID . ',' . floattostring($amount) . ';';
$totalCount += $amount;
}
if ($totalCount == 0) {
if ($this->_fleet['fleet_id'] == $fleetID) {
$this->KillFleet();
} else {
$sql = 'DELETE %%FLEETS%%, %%FLEETS_EVENT%%
//.........这里部分代码省略.........