function GetBuildingTime($user, $planet, $Element, $destroy = false) { global $pricelist, $resource, $reslist, $game_config; //Get the cost $cost = GetBuildingPrice($user, $planet, $Element, true, $destroy, false); $cost = $cost['metal'] + $cost['crystal']; if (in_array($Element, $reslist['build'])) { // For buildings $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['14']] + 1)) * pow(0.5, $planet[$resource['15']]); $time = floor($time * 60 * 60); //Else if its a research } elseif (in_array($Element, $reslist['tech'])) { // For research //Intergalactic Research Network $lablevel = $planet[$resource['31']]; //If we have IRN if ($user[$resource[123]] > 0) { $empire = doquery("SELECT `" . $resource['31'] . "` FROM {{table}} WHERE `id_owner` ='" . $user['id'] . "' AND `id` <>'" . $user['current_planet'] . "' ORDER BY `" . $resource['31'] . "` DESC LIMIT 0 , " . $user[$resource[123]] . " ;", 'planets'); //Loop through colonies while ($colonie = mysql_fetch_array($empire)) { //Add there lab level to combined lab level $lablevel += $colonie[$resource['31']]; } } //IRN $time = $cost / $game_config['game_speed'] / (($lablevel + 1) * 2); $time = floor($time * 60 * 60); } elseif (in_array($Element, $reslist['defense']) || in_array($Element, $reslist['fleet'])) { // For shipyard / defense $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['21']] + 1)) * pow(1 / 2, $planet[$resource['15']]); $time = floor($time * 60 * 60); } return $time; }
/** * Cancel a building from the queue and give the resource to the player * * @param array $currentPlanet @see $planetrow * @param array $currentUser @see $user * @return bool True if the cancel the cancel is correct */ function CancelBuildingFromQueue(&$currentPlanet, &$currentUser) { if ($currentPlanet['b_building_id'] == 0) { return false; } $currentQueue = explode(';', $currentPlanet['b_building_id']); $firstElement = explode(',', $currentQueue[0]); array_shift($currentQueue); $queueSize = count($currentQueue); $forDestroy = $firstElement[4] == 'destroy' ? true : false; $elementPrice = GetBuildingPrice($currentUser, $currentPlanet, $firstElement[0], true, $forDestroy); $currentPlanet['metal'] += $elementPrice['metal']; $currentPlanet['crystal'] += $elementPrice['crystal']; $currentPlanet['deuterium'] += $elementPrice['deuterium']; if ($queueSize > 0) { $buildEndTime = time(); $newQueue = array(); for ($i = 0; $i < $queueSize; $i++) { $elementArray = explode(',', $currentQueue[$i]); if ($firstElement[0] == $elementArray[0]) { $elementArray[1]--; $elementArray[2] = GetBuildingTimeLevel($currentUser, $currentPlanet, $elementArray[0], $elementArray[1]); } $buildEndTime += $elementArray[2]; $elementArray[3] = $buildEndTime; $newQueue[$i] = implode(',', $elementArray); } } $currentPlanet['b_building_id'] = $queueSize > 0 ? implode(';', $newQueue) : 0; $currentPlanet['b_building'] = $queueSize > 0 ? $buildEndTime : 0; return true; }
private function CancelBuildingFromQueue(&$CurrentPlanet, &$CurrentUser) { $CurrentQueue = $CurrentPlanet['b_building_id']; if ($CurrentQueue != 0) { $QueueArray = explode(";", $CurrentQueue); $ActualCount = count($QueueArray); $CanceledIDArray = explode(",", $QueueArray[0]); $Element = $CanceledIDArray[0]; $BuildMode = $CanceledIDArray[4]; if ($ActualCount > 1) { array_shift($QueueArray); $NewCount = count($QueueArray); $BuildEndTime = time(); $PreElementArray = $CanceledIDArray; for ($ID = 0; $ID < $NewCount; $ID++) { $ListIDArray = explode(",", $QueueArray[$ID]); $temp = $ListIDArray; if ($ListIDArray[0] == $Element) { $ListIDArray = $PreElementArray; } $PreElementArray = $temp; $BuildEndTime += $ListIDArray[2]; $ListIDArray[3] = $BuildEndTime; $QueueArray[$ID] = implode(",", $ListIDArray); } unset($temp); $NewQueue = implode(";", $QueueArray); $ReturnValue = true; $BuildEndTime = '0'; } else { $NewQueue = '0'; $ReturnValue = false; $BuildEndTime = '0'; } if ($BuildMode == 'destroy') { $ForDestroy = true; } else { $ForDestroy = false; } if ($Element != false) { $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy); $CurrentPlanet['metal'] += $Needed['metal']; $CurrentPlanet['crystal'] += $Needed['crystal']; $CurrentPlanet['deuterium'] += $Needed['deuterium']; $CurrentPlanet['tritium'] += $Needed['tritium']; } } else { $NewQueue = '0'; $BuildEndTime = '0'; $ReturnValue = false; } $CurrentPlanet['b_building_id'] = $NewQueue; $CurrentPlanet['b_building'] = $BuildEndTime; return $ReturnValue; }
/** * CancelBuildingFromQueue * * @version 1 * @copyright 2008 by Chlorel for XNova */ function CancelBuildingFromQueue(&$CurrentPlanet, &$CurrentUser) { $CurrentQueue = $CurrentPlanet['b_building_id']; if ($CurrentQueue != 0) { // Creation du tableau de la liste de construction $QueueArray = explode(";", $CurrentQueue); // Comptage du nombre d'elements dans la liste $ActualCount = count($QueueArray); // Stockage de l'element a 'interrompre' $CanceledIDArray = explode(",", $QueueArray[0]); $Element = $CanceledIDArray[0]; $BuildMode = $CanceledIDArray[4]; // pour savoir si on construit ou detruit if ($ActualCount > 1) { array_shift($QueueArray); $NewCount = count($QueueArray); // Mise a jour de l'heure de fin de construction theorique du batiment $BuildEndTime = time(); for ($ID = 0; $ID < $NewCount; $ID++) { $ListIDArray = explode(",", $QueueArray[$ID]); $BuildEndTime += $ListIDArray[2]; $ListIDArray[3] = $BuildEndTime; $QueueArray[$ID] = implode(",", $ListIDArray); } $NewQueue = implode(";", $QueueArray); $ReturnValue = true; $BuildEndTime = '0'; } else { $NewQueue = '0'; $ReturnValue = false; $BuildEndTime = '0'; } // Ici on va rembourser les ressources engagées ... // Deja le mode (car quand on detruit ca ne coute que la moitié du prix de construction classique if ($BuildMode == 'destroy') { $ForDestroy = true; } else { $ForDestroy = false; } if ($Element != false) { $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy); $CurrentPlanet['metal'] += $Needed['metal']; $CurrentPlanet['crystal'] += $Needed['crystal']; $CurrentPlanet['deuterium'] += $Needed['deuterium']; } } else { $NewQueue = '0'; $BuildEndTime = '0'; $ReturnValue = false; } $CurrentPlanet['b_building_id'] = $NewQueue; $CurrentPlanet['b_building'] = $BuildEndTime; return $ReturnValue; }
/** * HandleElementBuildingQueue.php * * @version 2 * @copyright 2009 By MadnessRed for XNova Redesigned */ function HandleElementBuildingQueue($CurrentUser, &$CurrentPlanet) { global $resource; //Right, lets make a new shipyard queue management. //So some stuff in shipyard? //echo $CurrentPlanet['b_hangar_id']; //Lets stop it complaining, we should define $cost as an array here $cost = array(); if (strlen($CurrentPlanet['b_hangar_id']) > 0) { //Whats be built, so far nothing, $built = array(); $cost = 0; //Lets explode the queue into an array $queue = explode(';', $CurrentPlanet['b_hangar_id']); //Son't stop yet, we haven't started $stop = false; //Make an array $built = array(); //Clear the queue to add to it later. $CurrentPlanet['b_hangar_id'] = ''; //When was hanger last updated? $ProductionTime = $CurrentPlanet['b_hangar_lastupdate']; //Check a time was set if ($ProductionTime == 0) { $ProductionTime = time(); } //So how long since the update? $ProductionTime = time() - $ProductionTime; //echo "Last update: ".$CurrentPlanet['b_hangar_lastupdate']."<br />Time since then: ".$ProductionTime."<br />"; //Incase any script tries to check again before we get to write to database $CurrentPlanet['b_hangar_lastupdate'] = time(); //Add left overs from last attempt $ProductionTime += $CurrentPlanet['b_hangar']; //echo "Leftover time: ".$CurrentPlanet['b_hangar']."<br />"; //now, keeping the queue in that order. foreach ($queue as $todo) { //If its a blank entry, move on. if ($todo == '') { continue; } //Should we stop? if (!$stop) { //Explodew the queue $q = explode(',', $todo); //Add the build time to the temp array $q[2] = GetBuildingTime($CurrentUser, $CurrentPlanet, $q[0]); //echo "Build time: ".$q[2].'<br />Ammount: '.$q[1].'<br />Time to build in: '.$ProductionTime; //Now is there time to build all of these? if ($q[2] * $q[1] <= $ProductionTime) { $ProductionTime -= $q[2] * $q[1]; $built[$q[0]] += $q[1]; $CurrentPlanet[$resource[$q[0]]] += $q[1]; //$ncost = GetBuildingPrice(array(),$CurrentPlanet,$q[0],false,false,true); $ncost = GetBuildingPrice(array(), $CurrentPlanet, $q[0], false); if (!is_array($ncost)) { trigger_error("\$ncost returned from GetBuildingPrice was not the expected array. The following was returned.<br />" . nl2br(print_r($ncost, true)) . "<br />The arguments were:<br />GetBuildingPrice(array()," . $CurrentPlanet . "," . $q[0] . ",false,false,true);"); } //foreach($ncost as $key => $val){ $cost[$key] += ($val * $q[1]); } foreach ($ncost as $val) { $cost += $val * $q[1]; } } elseif ($q[2] <= $ProductionTime) { $canbuild = floor($ProductionTime / $q[2]); $ProductionTime -= $q[2] * $canbuild; $built[$q[0]] += $canbuild; $CurrentPlanet[$resource[$q[0]]] += $canbuild; //$ncost = GetBuildingPrice(array(),$CurrentPlanet,$q[0],false,false,true); $ncost = GetBuildingPrice(array(), $CurrentPlanet, $q[0], false); if (!is_array($ncost)) { trigger_error("\$ncost returned from GetBuildingPrice was not the expected array. The following was returned.<br />" . nl2br(print_r($ncost, true)) . "<br />The arguments were:<br />GetBuildingPrice(array()," . $CurrentPlanet . "," . $q[0] . ",false,false,true);"); } //foreach($ncost as $key => $val){ $cost[$key] += ($val * $canbuild); } foreach ($ncost as $val) { $cost += $val * $canbuild; } //And lets upt the rest back into the queue $CurrentPlanet['b_hangar_id'] .= $q[0] . "," . ($q[1] - $canbuild) . ";"; //And stop doing stuff. $stop = true; } else { $CurrentPlanet['b_hangar_id'] .= $todo . ";"; $stop = true; } } else { $CurrentPlanet['b_hangar_id'] .= $todo . ";"; } } //And how much time is left over? $CurrentPlanet['b_hangar'] = $ProductionTime; //Add what he build to the stats AddPoints($cost, false, $CurrentUser['id']); } else { $built = array(); $CurrentPlanet['b_hangar'] = 0; } //Update the database: if anything was built if (sizeof($built) > 0) { $qry = "UPDATE {{table}} SET "; foreach ($built as $i => $c) { $qry .= "`" . $resource[$i] . "` = '" . $CurrentPlanet[$resource[$i]] . "', "; } $qry .= "`b_hangar` = '" . $CurrentPlanet['b_hangar'] . "', "; $qry .= "`b_hangar_id` = '" . $CurrentPlanet['b_hangar_id'] . "', "; $qry .= "`b_hangar_lastupdate` = '" . time() . "' "; $qry .= "WHERE `id` = '" . $CurrentPlanet['id'] . "' LIMIT 1 ;"; doquery($qry, 'planets'); } else { $qry = "UPDATE {{table}} SET "; $qry .= "`b_hangar` = '" . $CurrentPlanet['b_hangar'] . "', "; $qry .= "`b_hangar_id` = '" . $CurrentPlanet['b_hangar_id'] . "', "; $qry .= "`b_hangar_lastupdate` = '" . time() . "' "; $qry .= "WHERE `id` = '" . $CurrentPlanet['id'] . "' LIMIT 1 ;"; doquery($qry, 'planets'); } return $built; }
function ShowBuildingInfoPage($CurrentUser, $CurrentPlanet, $BuildID) { global $dpath, $lang, $resource, $pricelist, $CombatCaps; includeLang('infos'); $GateTPL = ''; $DestroyTPL = ''; $TableHeadTPL = ''; $parse = $lang; // Données de base $parse['dpath'] = $dpath; $parse['name'] = $lang['info'][$BuildID]['name']; $parse['image'] = $BuildID; $parse['description'] = $lang['info'][$BuildID]['description']; if ($BuildID >= 1 && $BuildID <= 3) { // Cas des mines $PageTPL = gettemplate('info_buildings_table'); $DestroyTPL = gettemplate('info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_p_hour}</td><td class=\"c\">{nfo_difference}</td><td class=\"c\">{nfo_used_energy}</td><td class=\"c\">{nfo_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; } elseif ($BuildID == 4) { // Centrale Solaire $PageTPL = gettemplate('info_buildings_table'); $DestroyTPL = gettemplate('info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_energy}</td><td class=\"c\">{nfo_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th></tr>"; } elseif ($BuildID == 12) { // Centrale Fusion $PageTPL = gettemplate('info_buildings_table'); $DestroyTPL = gettemplate('info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_energy}</td><td class=\"c\">{nfo_difference}</td><td class=\"c\">{nfo_used_deuter}</td><td class=\"c\">{nfo_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; } elseif ($BuildID >= 14 && $BuildID <= 32) { // Batiments Generaux $PageTPL = gettemplate('info_buildings_general'); $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID == 33) { // Batiments Terraformer $PageTPL = gettemplate('info_buildings_general'); } elseif ($BuildID == 34) { // Dépot d'alliance $PageTPL = gettemplate('info_buildings_general'); $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID == 44) { // Silo de missiles $PageTPL = gettemplate('info_buildings_general'); $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID == 41) { // Batiments lunaires $PageTPL = gettemplate('info_buildings_general'); } elseif ($BuildID == 42) { // Phalange $PageTPL = gettemplate('info_buildings_table'); $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_range}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_range}</th></tr>"; $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID == 43) { // Porte de Saut $PageTPL = gettemplate('info_buildings_general'); $GateTPL = gettemplate('gate_fleet_table'); $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID >= 106 && $BuildID <= 199) { // Laboratoire $PageTPL = gettemplate('info_buildings_general'); } elseif ($BuildID >= 202 && $BuildID <= 215) { // Flotte $PageTPL = gettemplate('info_buildings_fleet'); $parse['element_typ'] = $lang['tech'][200]; $parse['rf_info_to'] = ShowRapidFireTo($BuildID); // Rapid Fire vers $parse['rf_info_fr'] = ShowRapidFireFrom($BuildID); // Rapid Fire de $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']); // Points de Structure $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']); // Points de Bouclier $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']); // Points d'Attaque $parse['capacity_pt'] = pretty_number($pricelist[$BuildID]['capacity']); // Capacitée de fret $parse['base_speed'] = pretty_number($pricelist[$BuildID]['speed']); // Vitesse de base $parse['base_conso'] = pretty_number($pricelist[$BuildID]['consumption']); // Consommation de base if ($BuildID == 202) { $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>"; // Vitesse rééquipée $parse['upd_conso'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['consumption2']) . ")</font>"; // Consommation apres rééquipement } elseif ($BuildID == 211) { $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>"; // Vitesse rééquipée } } elseif ($BuildID >= 401 && $BuildID <= 408) { // Defenses $PageTPL = gettemplate('info_buildings_defense'); $parse['element_typ'] = $lang['tech'][400]; $parse['rf_info_to'] = ShowRapidFireTo($BuildID); // Rapid Fire vers $parse['rf_info_fr'] = ShowRapidFireFrom($BuildID); // Rapid Fire de $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']); // Points de Structure $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']); // Points de Bouclier $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']); // Points d'Attaque } elseif ($BuildID >= 502 && $BuildID <= 503) { // Misilles $PageTPL = gettemplate('info_buildings_defense'); $parse['element_typ'] = $lang['tech'][400]; $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']); // Points de Structure $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']); // Points de Bouclier $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']); // Points d'Attaque } elseif ($BuildID >= 601 && $BuildID <= 615) { // Officiers $PageTPL = gettemplate('info_officiers_general'); } // ---- Tableau d'evolution if ($TableHeadTPL != '') { $parse['table_head'] = parsetemplate($TableHeadTPL, $lang); $parse['table_data'] = ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $TableTPL); } // La page principale $page = parsetemplate($PageTPL, $parse); if ($GateTPL != '') { if ($CurrentPlanet[$resource[$BuildID]] > 0) { $RestString = GetNextJumpWaitTime($CurrentPlanet); $parse['gate_start_link'] = BuildPlanetAdressLink($CurrentPlanet); if ($RestString['value'] != 0) { $parse['gate_time_script'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], true); $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>"; $parse['gate_script_go'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], false); } else { $parse['gate_time_script'] = ""; $parse['gate_wait_time'] = ""; $parse['gate_script_go'] = ""; } $parse['gate_dest_moons'] = BuildJumpableMoonCombo($CurrentUser, $CurrentPlanet); $parse['gate_fleet_rows'] = BuildFleetListRows($CurrentPlanet); $page .= parsetemplate($GateTPL, $parse); } } if ($DestroyTPL != '') { if ($CurrentPlanet[$resource[$BuildID]] > 0) { // ---- Destruction $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true); $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2; $parse['destroyurl'] = "buildings.php?cmd=destroy&building=" . $BuildID; // Non balisé les balises sont dans le tpl $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]]; // Niveau du batiment a detruire $parse['nfo_metal'] = $lang['Metal']; $parse['nfo_crysta'] = $lang['Crystal']; $parse['nfo_deuter'] = $lang['Deuterium']; $parse['metal'] = pretty_number($NeededRessources['metal']); // Cout en metal de la destruction $parse['crystal'] = pretty_number($NeededRessources['crystal']); // Cout en cristal de la destruction $parse['deuterium'] = pretty_number($NeededRessources['deuterium']); // Cout en deuterium de la destruction $parse['destroytime'] = pretty_time($DestroyTime); // Durée de la destruction // L'insert de destruction $page .= parsetemplate($DestroyTPL, $parse); } } return $page; }
function SetNextQueueElementOnTop(&$CurrentPlanet, $CurrentUser) { global $lang, $resource; if ($CurrentPlanet['b_building'] == 0) { $CurrentQueue = $CurrentPlanet['b_building_id']; if ($CurrentQueue != 0) { $QueueArray = explode(";", $CurrentQueue); $Loop = true; while ($Loop == true) { $ListIDArray = explode(",", $QueueArray[0]); $Element = $ListIDArray[0]; $Level = $ListIDArray[1]; $BuildTime = $ListIDArray[2]; $BuildEndTime = $ListIDArray[3]; $BuildMode = $ListIDArray[4]; $HaveNoMoreLevel = false; if ($BuildMode == 'destroy') { $ForDestroy = true; } else { $ForDestroy = false; } $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy); if ($ForDestroy) { if ($CurrentPlanet[$resource[$Element]] == 0) { $HaveRessources = false; $HaveNoMoreLevel = true; } } if ($HaveRessources == true) { $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy); $CurrentPlanet['metal'] -= $Needed['metal']; $CurrentPlanet['crystal'] -= $Needed['crystal']; $CurrentPlanet['deuterium'] -= $Needed['deuterium']; $CurrentPlanet['tritium'] -= $Needed['tritium']; $CurrentTime = time(); $BuildEndTime = $BuildEndTime; $NewQueue = implode(";", $QueueArray); if ($NewQueue == "") { $NewQueue = '0'; } $Loop = false; } else { $ElementName = $lang['tech'][$Element]; if ($HaveNoMoreLevel == true) { $Message = sprintf($lang['sys_nomore_level'], $ElementName); } else { $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy); $Message = sprintf($lang['sys_notenough_money'], $ElementName, pretty_number($CurrentPlanet['metal']), $lang['Metal'], pretty_number($CurrentPlanet['crystal']), $lang['Crystal'], pretty_number($CurrentPlanet['deuterium']), $lang['Deuterium'], pretty_number($CurrentPlanet['tritium']), $lang['Tritium'], pretty_number($Needed['metal']), $lang['Metal'], pretty_number($Needed['crystal']), $lang['Crystal'], pretty_number($Needed['deuterium']), $lang['Deuterium'], pretty_number($Needed['tritium']), $lang['Tritium']); } SendSimpleMessage($CurrentUser['id'], '', '', 99, $lang['sys_buildlist'], $lang['sys_buildlist_fail'], $Message); array_shift($QueueArray); $ActualCount = count($QueueArray); if ($ActualCount == 0) { $BuildEndTime = '0'; $NewQueue = '0'; $Loop = false; } } } } else { $BuildEndTime = '0'; $NewQueue = '0'; } $CurrentPlanet['b_building'] = $BuildEndTime; $CurrentPlanet['b_building_id'] = $NewQueue; $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`metal` = '" . $CurrentPlanet['metal'] . "' , "; $QryUpdatePlanet .= "`crystal` = '" . $CurrentPlanet['crystal'] . "' , "; $QryUpdatePlanet .= "`deuterium` = '" . $CurrentPlanet['deuterium'] . "' , "; $QryUpdatePlanet .= "`tritium` \t= '" . $CurrentPlanet['tritium'] . "' , "; $QryUpdatePlanet .= "`b_building` = '" . $CurrentPlanet['b_building'] . "' , "; $QryUpdatePlanet .= "`b_building_id` = '" . $CurrentPlanet['b_building_id'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); } return; }
public function ShowResearchPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet) { global $lang, $resource, $reslist, $phpEx, $dpath, $db, $displays, $_GET; include_once $svn_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $svn_root . 'includes/functions/GetElementPrice.' . $phpEx; $displays->assignContent("buildings/buildings_research"); $NoResearchMessage = ""; $bContinue = true; if ($CurrentPlanet[$resource[31]] == 0) { $displays->message($lang['bd_lab_required'], '', '', true); } if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) { $displays->assign('noresearch', $lang['bd_building_lab']); $bContinue = false; } if (isset($_GET['cmd']) && $bContinue) { $TheCommand = $_GET['cmd']; $Techno = intval($_GET['tech']); if (isset($Techno)) { if (!strstr($Techno, ",") && !strchr($Techno, " ") && !strchr($Techno, "+") && !strchr($Techno, "*") && !strchr($Techno, "~") && !strchr($Techno, "=") && !strchr($Techno, ";") && !strchr($Techno, "'") && !strchr($Techno, "#") && !strchr($Techno, "-") && !strchr($Techno, "_") && !strchr($Techno, "[") && !strchr($Techno, "]") && !strchr($Techno, ".") && !strchr($Techno, ":")) { if (in_array($Techno, $reslist['tech'])) { if (is_array($ThePlanet)) { $WorkingPlanet = $ThePlanet; } else { $WorkingPlanet = $CurrentPlanet; } switch ($TheCommand) { case 'cancel': if ($ThePlanet['b_tech_id'] == $Techno) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] += $costs['metal']; $WorkingPlanet['crystal'] += $costs['crystal']; $WorkingPlanet['deuterium'] += $costs['deuterium']; $WorkingPlanet['b_tech_id'] = 0; $WorkingPlanet["b_tech"] = 0; $CurrentUser['b_tech_planet'] = 0; $UpdateData = true; $InResearch = false; } break; case 'search': if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] -= $costs['metal']; $WorkingPlanet['crystal'] -= $costs['crystal']; $WorkingPlanet['deuterium'] -= $costs['deuterium']; $WorkingPlanet["b_tech_id"] = $Techno; $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno); $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"]; $UpdateData = true; $InResearch = true; } break; } if ($UpdateData == true) { $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', "; $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', "; $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', "; $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', "; $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';"; $db->query($QryUpdatePlanet, 'planets'); $QryUpdateUser = "******"; $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; $db->query($QryUpdateUser, 'users'); } $CurrentPlanet = $WorkingPlanet; if (is_array($ThePlanet)) { $ThePlanet = $WorkingPlanet; } else { $CurrentPlanet = $WorkingPlanet; if ($TheCommand == 'search') { $ThePlanet = $CurrentPlanet; } } } } else { die(header("location:game.php?page=buildings&mode=research")); } } else { $bContinue = false; } } $siguiente = 1; foreach ($reslist['tech'] as $Tech) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) { $displays->newblock("research"); $RowParse['tech_id'] = $Tech; $building_level = $CurrentUser[$resource[$Tech]]; if ($Tech == 106) { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")"; $RowParse['tech_level'] .= $CurrentUser['rpg_espion'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_espion'] * 5 . $lang['bd_spy'] . "</font></strong>"; } elseif ($Tech == 108) { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")"; $RowParse['tech_level'] .= $CurrentUser['rpg_commandant'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_commandant'] * 3 . $lang['bd_commander'] . "</font></strong>"; } else { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . " )"; } $RowParse['tech_name'] = $lang['tech'][$Tech]; $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech]; $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech); $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech); $RowParse['search_time'] = ShowBuildTime($SearchTime); $RowParse['tech_restp'] = "Restantes " . $this->GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true); $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech); if (!$InResearch) { $LevelToDo = 1 + $CurrentUser[$resource[$Tech]]; if ($CanBeDone) { if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } } else { $TechnoLink = "<a href=\"game.php?page=buildings&mode=research&cmd=search&tech=" . $Tech . "\">"; if ($LevelToDo == 1) { $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } $TechnoLink .= "</a>"; } } else { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } } } else { if ($ThePlanet["b_tech_id"] == $Tech) { $displays->newblock("script"); if ($ThePlanet['id'] != $CurrentPlanet['id']) { $bloc['tech_time'] = $ThePlanet["b_tech"] - time(); $bloc['tech_name'] = "de<br>" . $ThePlanet["name"]; $bloc['tech_home'] = $ThePlanet["id"]; $bloc['tech_id'] = $ThePlanet["b_tech_id"]; } else { $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time(); $bloc['tech_name'] = ""; $bloc['tech_home'] = $CurrentPlanet["id"]; $bloc['tech_id'] = $CurrentPlanet["b_tech_id"]; } foreach ($bloc as $name => $trans) { $displays->assign($name, $trans); } } else { $TechnoLink = "<center>-</center>"; } } $displays->gotoBlock("research"); $RowParse['tech_link'] = $TechnoLink; if ($siguiente % 3 == 0) { $RowParse['cerrar'] = "</tr><tr>"; } $siguiente++; foreach ($RowParse as $name => $trans) { $displays->assign($name, $trans); } unset($RowParse, $TechnoLink); } } $displays->display("Investigación"); }
/** * GetBuildingTime.php * @Licence GNU (GPL) * @version 3.0 * @copyright 2009 * @Team Space Beginner * **/ function GetBuildingTime($user, $planet, $Element, $destroy = false) { global $pricelist, $resource, $reslist, $game_config, $user; // Baukosten = Bauzeit $cost = GetBuildingPrice($user, $planet, $Element, true, $destroy, false); $cost = $cost['metal'] + $cost['crystal']; // Standart $bonusgeb = 60; // Gebaude $bonusfleet = 60; // Flotten $bonusforsch = 60; // Forschungen $bonusdeff = 60; // Verteidigung // Rasse Vorteile / Nachteile switch ($user['volk']) { case "A": $bonusgeb = 57; // + 5% $bonusfleet = 66; // -10% $bonusforsch = 57; // + 5% $bonusdeff = 60; break; case "B": $bonusgeb = 57; // + 5% $bonusfleet = 57; // + 5% $bonusforsch = 66; // -10% $bonusdeff = 60; break; case "C": $bonusgeb = 66; // -10% $bonusfleet = 57; // + 5% $bonusforsch = 57; // + 5% $bonusdeff = 60; break; } if (in_array($Element, $reslist['build'])) { // Gebäude + Rassen Bonus $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['14']] + 1)) * pow(0.5, $planet[$resource['15']]); $time = floor($time * 60 * $bonusgeb); } elseif (in_array($Element, $reslist['tech'])) { // Forschung + Rassen Bonus + Forschungsbeschleunigung $lablevel = $planet[$resource['31']]; $technodrom = $planet[$resource['27']]; if ($user[$resource[123]] > 0) { $empire = doquery("SELECT `" . $resource['31'] . "` FROM {{table}} WHERE `id_owner` ='" . $user['id'] . "' AND `id` <>'" . $user['current_planet'] . "' ORDER BY `" . $resource['31'] . "` DESC LIMIT 0 , " . $user[$resource[123]] . " ;", 'planets'); while ($colonie = mysql_fetch_array($empire)) { $lablevel += $colonie[$resource['31']]; } } $time = $cost / $game_config['game_speed'] / (($lablevel + 1) * 2) * pow(1 / 2, $planet[$resource['27']]); $time = floor($time * 60 * $bonusforsch); } elseif (in_array($Element, $reslist['defense'])) { // Verteidigung + Rassen Bonus $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['21']] + 1)) * pow(1 / 2, $planet[$resource['15']]); $time = floor($time * 60 * $bonusdeff); } elseif (in_array($Element, $reslist['fleet'])) { // Schiffe $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['21']] + 1)) * pow(1 / 2, $planet[$resource['15']]); $time = floor($time * 60 * $bonusfleet); } return $time; }
public function ShowResearchPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet) { global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET; include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx; $PageParse = $lang; $NoResearchMessage = ""; $bContinue = true; if ($CurrentPlanet[$resource[31]] == 0) { message($lang['bd_lab_required'], '', '', true); } if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) { $NoResearchMessage = $lang['bd_building_lab']; $bContinue = false; } if (isset($_GET['cmd'])) { $TheCommand = $_GET['cmd']; $Techno = intval($_GET['tech']); if (isset($Techno)) { if (!strstr($Techno, ",") && !strchr($Techno, " ") && !strchr($Techno, "+") && !strchr($Techno, "*") && !strchr($Techno, "~") && !strchr($Techno, "=") && !strchr($Techno, ";") && !strchr($Techno, "'") && !strchr($Techno, "#") && !strchr($Techno, "-") && !strchr($Techno, "_") && !strchr($Techno, "[") && !strchr($Techno, "]") && !strchr($Techno, ".") && !strchr($Techno, ":")) { if (in_array($Techno, $reslist['tech'])) { if (is_array($ThePlanet)) { $WorkingPlanet = $ThePlanet; } else { $WorkingPlanet = $CurrentPlanet; } switch ($TheCommand) { case 'cancel': if ($ThePlanet['b_tech_id'] == $Techno) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] += $costs['metal']; $WorkingPlanet['crystal'] += $costs['crystal']; $WorkingPlanet['deuterium'] += $costs['deuterium']; $WorkingPlanet['darkmatter'] += $costs['darkmatter']; $WorkingPlanet['b_tech_id'] = 0; $WorkingPlanet["b_tech"] = 0; $CurrentUser['b_tech_planet'] = 0; $UpdateData = true; $InResearch = false; } break; case 'search': if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] -= $costs['metal']; $WorkingPlanet['crystal'] -= $costs['crystal']; $WorkingPlanet['deuterium'] -= $costs['deuterium']; $WorkingPlanet['darkmatter'] -= $costs['darkmatter']; $WorkingPlanet["b_tech_id"] = $Techno; $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno); $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"]; $UpdateData = true; $InResearch = true; } break; } if ($UpdateData == true) { $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', "; $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', "; $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', "; $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', "; $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "', "; $QryUpdatePlanet .= "`darkmatter` = '" . $WorkingPlanet['darkmatter'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $QryUpdateUser = "******"; $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; doquery($QryUpdateUser, 'users'); } $CurrentPlanet = $WorkingPlanet; if (is_array($ThePlanet)) { $ThePlanet = $WorkingPlanet; } else { $CurrentPlanet = $WorkingPlanet; if ($TheCommand == 'search') { $ThePlanet = $CurrentPlanet; } } } } else { die(header("location:game.php?page=buildings&mode=research")); } } else { $bContinue = false; } header("Location: game.php?page=buildings&mode=research"); } $siguiente = 1; $BuildingPage = ""; $zaehler = 1; $TechRowTPL = gettemplate('buildings/buildings_research_row'); $TechScrTPL = gettemplate('buildings/buildings_research_script'); foreach ($lang['tech'] as $Tech => $TechName) { if ($Tech > 105 && $Tech <= 199) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) { $RowParse['dpath'] = $dpath; $RowParse['tech_id'] = $Tech; $building_level = $CurrentUser[$resource[$Tech]]; if ($Tech == 106) { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")"; $RowParse['tech_level'] .= $CurrentUser['rpg_espion'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_espion'] * ESPION . $lang['bd_spy'] . "</font></strong>"; } elseif ($Tech == 108) { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")"; $RowParse['tech_level'] .= $CurrentUser['rpg_commandant'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_commandant'] * COMMANDANT . $lang['bd_commander'] . "</font></strong>"; } else { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . " )"; } $RowParse['tech_name'] = $TechName; $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech]; $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech); $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech); $RowParse['search_time'] = ShowBuildTime($SearchTime); $RowParse['tech_restp'] = "Restantes " . $this->GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true); $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech); if ($siguiente == 1) { $parse['abrirtr'] = "<tr>"; } if (!$InResearch) { $LevelToDo = 1 + $CurrentUser[$resource[$Tech]]; if ($CanBeDone) { if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } } else { $TechnoLink = "<a href=\"game.php?page=buildings&mode=research&cmd=search&tech=" . $Tech . "\">"; if ($LevelToDo == 1) { $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } $TechnoLink .= "</a>"; } } else { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } } } else { if ($ThePlanet["b_tech_id"] == $Tech) { $bloc = $lang; if ($ThePlanet['id'] != $CurrentPlanet['id']) { $bloc['tech_time'] = $ThePlanet["b_tech"] - time(); $bloc['tech_name'] = "de<br>" . $ThePlanet["name"]; $bloc['tech_home'] = $ThePlanet["id"]; $bloc['tech_id'] = $ThePlanet["b_tech_id"]; } else { $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time(); $bloc['tech_name'] = ""; $bloc['tech_home'] = $CurrentPlanet["id"]; $bloc['tech_id'] = $CurrentPlanet["b_tech_id"]; } $TechnoLink = parsetemplate($TechScrTPL, $bloc); } else { $TechnoLink = "<center>-</center>"; } } if ($siguiente == 3) { $parse['cerrartr'] = "</tr>"; $siguiente = 1; } else { $siguiente++; } $TechRowTPL = gettemplate('buildings/buildings_research_row'); $RowParse['tech_link'] = $TechnoLink; $TechnoList .= parsetemplate($TechRowTPL, $RowParse); } } } $PageParse['noresearch'] = $NoResearchMessage; $PageParse['technolist'] = $TechnoList; $Page .= parsetemplate(gettemplate('buildings/buildings_research'), $PageParse); display($Page); }
function StartBuild($ACTUAL_TICK, $building, $planet) { global $MAX_BUILDING_LVL; $res = BUILD_ERR_DB; // Building queue full? $this->db->queryrow('SELECT installation_type FROM scheduler_instbuild WHERE planet_id=' . $planet['planet_id']); if ($this->db->num_rows() >= BUILDING_QUEUE_LEN) { return BUILD_ERR_QUEUE; } // Retrieve some BOT infos $sql = 'SELECT user_race, user_capital, pending_capital_choice FROM user WHERE user_id=' . $this->bot['user_id']; $userdata = $this->db->queryrow($sql); $race = $userdata['user_data']; // Planet selected is capital or not? $capital = $userdata['user_capital'] == $planet['planet_id'] ? 1 : 0; if ($userdata['pending_capital_choice']) { $capital = 0; } // Check if building hasn't reached max level if ($planet['building_' . ($building + 1)] == $MAX_BUILDING_LVL[$capital][$building]) { return BUILD_ERR_MAXLEVEL; } // Calculate resources needed for the building $resource_1 = GetBuildingPrice($building, 0, $planet, $race); $resource_2 = GetBuildingPrice($building, 1, $planet, $race); $resource_3 = GetBuildingPrice($building, 2, $planet, $race); // Check resources availability if ($planet['resource_1'] >= $resource_1 && $planet['resource_2'] >= $resource_2 && $planet['resource_3'] >= $resource_3) { // Calculate planet power consumption $buildings = $planet['building_1'] + $planet['building_2'] + $planet['building_3'] + $planet['building_4'] + $planet['building_10'] + $planet['building_6'] + $planet['building_7'] + $planet['building_8'] + $planet['building_9'] + $planet['building_11'] + $planet['building_12'] + $planet['building_13']; /* I think we don't need this check here... if (($building==11 && $planet['building_1']<4) || ($building==10 && $planet['building_1']<3) || ($building==6 && $planet['building_1']<5) || ($building==8 && $planet['building_1']<9) || ($building==7 && $planet['building_7']<1) || ($building==9 && ($planet['building_6']<5 ||$planet['building_7']<1)) || ($building==12 && ($planet['building_6']<1 || $planet['building_7']<1)) ) { return BUILD_ERR_REQUIRED; }*/ // If we are building a power plant, or there is energy still available if ($building == 4 || $buildings <= ($capital ? $planet['building_5'] * 11 + 14 : $planet['building_5'] * 15 + 3)) { // Remove resources needed from the planet $sql = 'UPDATE planets SET resource_1=resource_1-' . $resource_1 . ', resource_2=resource_2-' . $resource_2 . ', resource_3=resource_3-' . $resource_3 . ' WHERE planet_id= ' . $planet['planet_id']; if (!$this->db->query($sql)) { $this->sdl->log('<b>Error:</b> Cannot remove resources need for construction from planet #' . $planet['planet_id'] . '!', TICK_LOG_FILE_NPC); } // Check planet activity $sql = 'SELECT build_finish FROM scheduler_instbuild WHERE planet_id=' . $planet['planet_id'] . ' ORDER BY build_finish DESC'; $userquery = $this->db->queryrow($sql); if ($this->db->num_rows() > 0) { $build_start = $userquery['build_finish']; // BOT take a little bonus here: future level of the building is not // considered, also for simplicity. $build_finish = $build_start + GetBuildingTimeTicks($building, $planet, $race); } else { $build_start = $ACTUAL_TICK; $build_finish = $build_start + GetBuildingTimeTicks($building, $planet, $race); } $sql = 'INSERT INTO scheduler_instbuild (installation_type,planet_id,build_start,build_finish) VALUES ("' . $building . '", "' . $planet['planet_id'] . '", "' . $build_start . '", "' . $build_finish . '")'; if (!$this->db->query($sql)) { $this->sdl->log('<b>Error:</b> cannot add building <b>#' . $building . '</b> to the planet <b>#' . $planet['planet_id'] . '</b>', TICK_LOG_FILE_NPC); } else { $this->sdl->log('Construction of <b>#' . $building . '</b> started on planet <b>#' . $planet['planet_id'] . '</b>', TICK_LOG_FILE_NPC); $res = BUILD_SUCCESS; } } else { $this->sdl->log('Insufficient energy on planet <b>#' . $planet['planet_id'] . '</b> for building <b>#' . $building . '</b>', TICK_LOG_FILE_NPC); $res = BUILD_ERR_ENERGY; } } else { $this->sdl->log('Insufficient resources on planet <b>#' . $planet['planet_id'] . '</b> for building <b>#' . $building . '</b>', TICK_LOG_FILE_NPC); $res = BUILD_ERR_RESOURCES; } return $res; }
public function SetNextQueueElementOnTop($USER, $PLANET, $TIME) { global $LNG, $resource, $db; if (empty($PLANET['b_building_id'])) { $PLANET['b_building'] = 0; $PLANET['b_building_id'] = ''; return array($USER, $PLANET); } $QueueArray = explode(";", $PLANET['b_building_id']); $Loop = true; $BuildEndTime = $TIME; while ($Loop == true) { $ListIDArray = explode(",", $QueueArray[0]); $Element = $ListIDArray[0]; $Level = $ListIDArray[1]; $BuildTime = $ListIDArray[2]; $BuildEndTime = $ListIDArray[3]; $BuildMode = $ListIDArray[4]; $ForDestroy = $BuildMode == 'destroy' ? true : false; $HaveNoMoreLevel = false; $HaveRessources = IsElementBuyable($USER, $PLANET, $Element, true, $ForDestroy); if ($ForDestroy && $PLANET[$resource[$Element]] == 0) { $HaveRessources = false; $HaveNoMoreLevel = true; } if ($HaveRessources == true) { $Needed = GetBuildingPrice($USER, $PLANET, $Element, true, $ForDestroy); $PLANET['metal'] -= $Needed['metal']; $PLANET['crystal'] -= $Needed['crystal']; $PLANET['deuterium'] -= $Needed['deuterium']; $USER['darkmatter'] -= $Needed['darkmatter']; $NewQueue = implode(";", $QueueArray); $Loop = false; } else { if ($USER['hof'] == 1) { if ($HaveNoMoreLevel == true) { $Message = sprintf($LNG['sys_nomore_level'], $LNG['tech'][$Element]); } else { $Needed = GetBuildingPrice($USER, $PLANET, $Element, true, $ForDestroy); $Message = sprintf($LNG['sys_notenough_money'], $PLANET['name'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $LNG['tech'][$Element], pretty_number($PLANET['metal']), $LNG['Metal'], pretty_number($PLANET['crystal']), $LNG['Crystal'], pretty_number($PLANET['deuterium']), $LNG['Deuterium'], pretty_number($Needed['metal']), $LNG['Metal'], pretty_number($Needed['crystal']), $LNG['Crystal'], pretty_number($Needed['deuterium']), $LNG['Deuterium']); } SendSimpleMessage($USER['id'], '', $BuildEndTime - $BuildTime, 99, $LNG['sys_buildlist'], $LNG['sys_buildlist_fail'], $Message); } array_shift($QueueArray); if (count($QueueArray) == 0) { $BuildEndTime = 0; $NewQueue = ''; $Loop = false; } else { $BaseTime = $BuildEndTime - $BuildTime; foreach ($QueueArray as $ID => $QueueInfo) { $ListIDArray = explode(",", $QueueInfo); $BaseTime += $ListIDArray[2]; $ListIDArray[3] = $BaseTime; $QueueArray[$ID] = implode(",", $ListIDArray); } } } } $PLANET['b_building'] = $BuildEndTime; $PLANET['b_building_id'] = $NewQueue; return array($USER, $PLANET); }
function HandleTechnologieBuild(&$CurrentPlanet, &$CurrentUser) { global $resource; if ($CurrentUser['b_tech_planet'] != 0) { // Y a une technologie en cours sur une de mes colonies if ($CurrentUser['b_tech_planet'] != $CurrentPlanet['id']) { // Et ce n'est pas sur celle ci !! $WorkingPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $CurrentUser['b_tech_planet'] . "';", 'planets', true); } if ($WorkingPlanet) { $ThePlanet = $WorkingPlanet; } else { $ThePlanet = $CurrentPlanet; } if ($ThePlanet['b_tech'] <= time() && $ThePlanet['b_tech_id'] != 0) { // La recherche en cours est terminée ... $CurrentUser[$resource[$ThePlanet['b_tech_id']]]++; // Mise a jour de la planete sur laquelle la technologie a été recherchée $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech` = '0', "; $QryUpdatePlanet .= "`b_tech_id` = '0' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $ThePlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); // Mes a jour de la techno sur l'enregistrement Utilisateur // Et tant qu'a faire des stats points $QryUpdateUser = "******"; $QryUpdateUser .= "`" . $resource[$ThePlanet['b_tech_id']] . "` = '" . $CurrentUser[$resource[$ThePlanet['b_tech_id']]] . "', "; $QryUpdateUser .= "`b_tech_planet` = '0' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; doquery($QryUpdateUser, 'users'); $costs = GetBuildingPrice($CurrentUser, $ThePlanet, $ThePlanet['b_tech_id']); AddPoints($costs['metal'] + $costs['crystal'] + $costs['deuterium'], true, $CurrentUser['id']); //MadnessRed - Update stats $ThePlanet["b_tech_id"] = 0; if (isset($WorkingPlanet)) { $WorkingPlanet = $ThePlanet; } else { $CurrentPlanet = $ThePlanet; } $Result['WorkOn'] = ""; $Result['OnWork'] = false; } elseif ($ThePlanet["b_tech_id"] == 0) { // Il n'y a rien a l'ouest ... // Pas de Technologie en cours devait y avoir un bug lors de la derniere connexion // On met l'enregistrement informant d'une techno en cours de recherche a jours doquery("UPDATE {{table}} SET `b_tech_planet` = '0' WHERE `id` = '" . $CurrentUser['id'] . "';", 'users'); $Result['WorkOn'] = ""; $Result['OnWork'] = false; } else { // Bin on bosse toujours ici ... Alors ne nous derangez pas !!! $Result['WorkOn'] = $ThePlanet; $Result['OnWork'] = true; } } else { $Result['WorkOn'] = ""; $Result['OnWork'] = false; } return $Result; }
function Show_Main() { global $db; global $game; global $NUM_BUILDING, $BUILDING_DESCRIPTION, $BUILDING_NAME, $BUILDING_DATA, $MAX_BUILDING_LVL, $NEXT_TICK, $ACTUAL_TICK; $capital = $game->player['user_capital'] == $game->planet['planet_id'] ? 1 : 0; if ($game->player['pending_capital_choice']) { $capital = 0; } // Clickids: $game->register_click_id(11); // Retrieve construction queue for the planet ordered by time $sql = 'SELECT * FROM scheduler_instbuild WHERE planet_id="' . $game->planet['planet_id'] . '" ORDER by build_start ASC'; $schedulerquery = $db->query($sql); if (($queued = $db->num_rows()) > 0) { // Timer ID $t = 3; while ($scheduler = $db->fetchrow($schedulerquery)) { // From now on the level of the building is currently developed at the final stage: $game->planet['building_' . ($scheduler['installation_type'] + 1)]++; $game->out('<table border=0 cellpadding=1 cellspacing=1 width=330 class="style_outer"><tr><td> <table border=0 cellpadding=1 cellspacing=1 width=330 class="style_inner"><tr><td> ' . constant($game->sprache("TEXT11")) . ' <b>' . $BUILDING_NAME[$game->player['user_race']][$scheduler['installation_type']] . ' (' . constant($game->sprache("TEXT12")) . ' ' . $game->planet['building_' . ($scheduler['installation_type'] + 1)] . ')</b><br> ' . constant($game->sprache("TEXT13")) . ' <b id="timer' . $t . '" title="time1_' . ($NEXT_TICK + TICK_DURATION * 60 * ($scheduler['build_finish'] - $ACTUAL_TICK)) . '_type1_1"> </b><br> <a href="' . parse_link_ex('a=building&a2=abort_build&id=' . $scheduler['installation_type'], LINK_CLICKID) . '"><b>' . constant($game->sprache("TEXT14")) . '</b></a> </td></tr></table> </td></tr></table><br>'); // Prepare another timer $t++; $game->set_autorefresh($NEXT_TICK + TICK_DURATION * 60 * ($scheduler['build_finish'] - $ACTUAL_TICK) + TICK_DURATION); } } // Calculate available energy power $avail = $game->planet['building_5'] * 11 + 14; if (!$capital) { $avail = $game->planet['building_5'] * 15 + 3; } // Calculate energy power consumption $used = $game->planet['building_1'] + $game->planet['building_2'] + $game->planet['building_3'] + $game->planet['building_4'] + $game->planet['building_10'] + $game->planet['building_6'] + $game->planet['building_7'] + $game->planet['building_8'] + $game->planet['building_9'] + $game->planet['building_11'] + $game->planet['building_12'] + $game->planet['building_13']; $game->out(constant($game->sprache("TEXT16")) . ' <b id="timer2" title="time1_' . $NEXT_TICK . '_type1_3"> </b> ' . constant($game->sprache("TEXT17")) . '<br>' . constant($game->sprache("TEXT18")) . ' ' . $used . '/' . $avail . ' ' . constant($game->sprache("TEXT19")) . '<br><br>'); $game->out('<span class="sub_caption">' . constant($game->sprache($queued ? "TEXT21" : "TEXT20")) . ' ' . HelpPopup('building_1') . ' :</span><br><br>'); $game->out('<table border=0 cellpadding=2 cellspacing=2 width=90% class="style_outer"> <tr><td width=100%> <table border=0 cellpadding=2 cellspacing=2 width=100% class="style_inner"> <tr> <td width=130><b>' . constant($game->sprache("TEXT29")) . '</b></td> <td width=155><b>' . constant($game->sprache("TEXT22")) . '</b></td> <td width=75><b>' . constant($game->sprache("TEXT23")) . '</b></td> <td width=130><b>' . constant($game->sprache("TEXT24")) . '</b></td> </tr>'); for ($tt = 0; $tt <= $NUM_BUILDING; $tt++) { if ($tt > 9) { $t = $tt - 1; } else { $t = $tt; } if ($tt == 9) { $t = 12; } if (areRequirementsMet($t)) { // Check if building has reached maximum level if ($game->planet['building_' . ($t + 1)] >= $MAX_BUILDING_LVL[$capital][$t]) { $met = $min = $lat = $build_time = 0; $build_text = constant($game->sprache("TEXT28")); } else { // Calculate required resources for next building level $met = GetBuildingPrice($t, 0); $min = GetBuildingPrice($t, 1); $lat = GetBuildingPrice($t, 2); $fut = GetFuturePts($t); // Calculate points gained for this building $points = round(pow($game->planet['building_' . ($t + 1)] + 1, 1.5) - pow($game->planet['building_' . ($t + 1)], 1.5)); if ($game->planet['resource_1'] >= $met && $game->planet['resource_2'] >= $min && $game->planet['resource_3'] >= $lat && $game->planet['planet_available_points'] >= $fut) { $build_text = '<a href="' . parse_link_ex('a=building&a2=start_build&id=' . $t, LINK_CLICKID) . '"><span style="color: green">' . constant($game->sprache("TEXT25")) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span></a>'; if ($game->planet['building_' . ($t + 1)] > 0) { $build_text = '<a href="' . parse_link_ex('a=building&a2=start_build&id=' . $t, LINK_CLICKID) . '"><span style="color: green">' . constant($game->sprache("TEXT27")) . ' ' . ($game->planet['building_' . ($t + 1)] + 1) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span></a>'; } } else { $build_text = '<span style="color: red">' . constant($game->sprache("TEXT25")) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span>'; if ($game->planet['building_' . ($t + 1)] > 0) { $build_text = '<span style="color: red">' . constant($game->sprache("TEXT27")) . ' ' . ($game->planet['building_' . ($t + 1)] + 1) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span>'; } } // Calculate required construction time $build_time = GetBuildingTime($t); } $game->out(' <tr> <td><b><a href="javascript:void(0);" onmouseover="return overlib(\'' . $BUILDING_DESCRIPTION[$game->player['user_race']][$t] . '\', CAPTION, \'' . $BUILDING_NAME[$game->player['user_race']][$t] . '\', WIDTH, 400, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $BUILDING_NAME[$game->player['user_race']][$t] . '</b></td> <td><img src="' . $game->GFX_PATH . 'menu_metal_small.gif"> ' . $met . ' <img src="' . $game->GFX_PATH . 'menu_mineral_small.gif">' . $min . ' <img src="' . $game->GFX_PATH . 'menu_latinum_small.gif"> ' . $lat . ' </td> <td>' . $build_time . '</td> <td>' . $build_text . '</td> </tr>'); } } $game->out('</table></td></tr></table>'); }
function ResearchBuildingPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet) { global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET; $NoResearchMessage = ""; $bContinue = true; // Deja est qu'il y a un laboratoire sur la planete ??? if ($CurrentPlanet[$resource[31]] == 0) { message($lang['no_laboratory'], $lang['Research']); } // Ensuite ... Est ce que la labo est en cours d'upgrade ? if (!CheckLabSettingsInQueue($CurrentPlanet)) { $NoResearchMessage = $lang['labo_on_update']; $bContinue = false; } // Boucle d'interpretation des eventuelles commandes if ($CurrentUser['urlaubs_modus'] == 0) { if (isset($_GET['cmd'])) { $TheCommand = $_GET['cmd']; $Techno = ltrim($_GET['tech'], 0); //########Auto Ban Funktion v.1######## //######Author = The_Revenge/Xire###### //################BEGIN################ if (preg_match('/\\D/', $Techno, $match)) { $user = doquery("SELECT * FROM {{table}} WHERE `id` ='{$CurrentUser['id']}';", "users"); while ($usern = mysql_fetch_array($user)) { $username = $usern['username']; doquery("UPDATE {{table}} SET bana='1', banaday='{$bantime}' WHERE id='{$CurrentUser['id']}'", "users"); doquery("INSERT INTO {{table}} SET\r\n\t\t\t\t\t`who` = '{$username}',\r\n\t\t\t\t\t`theme`= '" . $lang['CHEATATTEMPT_TITLE'] . "',\r\n\t\t\t\t\t`who2` = '{$usern['id']}',\r\n\t\t\t\t\t`time` = '{$time}',\r\n\t\t\t\t\t`longer` = '{$bantime}',\r\n\t\t\t\t\t`author` = 'SYSTEM: R',\r\n\t\t\t\t\t`email` = 'n'", 'banned'); } message($lang['CHEATATTEMPT'], $lang['CHEATATTEMPT_TITLE']); die; } //########Auto Ban Funktion v.1######## //######Author = The_Revenge/Xire###### //#################END################# if (is_numeric($Techno)) { if (in_array($Techno, $reslist['tech'])) { // Bon quand on arrive ici ... On sait deja qu'on a une technologie valide if (is_array($ThePlanet)) { $WorkingPlanet = $ThePlanet; } else { $WorkingPlanet = $CurrentPlanet; } switch ($TheCommand) { case 'cancel': if ($ThePlanet['b_tech_id'] == $Techno) { $nedeed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Techno); $CurrentPlanet['metal'] = $CurrentPlanet['metal'] + $nedeed['metal']; $CurrentPlanet['crystal'] = $CurrentPlanet['crystal'] + $nedeed['crystal']; $CurrentPlanet['deuterium'] = $CurrentPlanet['deuterium'] + $nedeed['deuterium']; $WorkingPlanet['b_tech_id'] = 0; $WorkingPlanet["b_tech"] = 0; $CurrentUser['b_tech_planet'] = $WorkingPlanet["id"]; $UpdateData = 1; $InResearch = false; } break; case 'search': if (!strchr($Techno, " ")) { if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] -= $costs['metal']; $WorkingPlanet['crystal'] -= $costs['crystal']; $WorkingPlanet['deuterium'] -= $costs['deuterium']; $WorkingPlanet["b_tech_id"] = $Techno; $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno); $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"]; $UpdateData = 1; $InResearch = true; } } break; } if ($UpdateData == 1) { $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', "; $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', "; $QryUpdatePlanet .= "`metal` = '" . $CurrentPlanet['metal'] . "', "; $QryUpdatePlanet .= "`crystal` = '" . $CurrentPlanet['crystal'] . "', "; $QryUpdatePlanet .= "`deuterium` = '" . $CurrentPlanet['deuterium'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $QryUpdateUser = "******"; $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; doquery($QryUpdateUser, 'users'); } if (is_array($ThePlanet)) { $ThePlanet = $WorkingPlanet; } else { $CurrentPlanet = $WorkingPlanet; if ($TheCommand == 'search') { $ThePlanet = $CurrentPlanet; } } } } else { $bContinue = false; } } } $TechRowTPL = gettemplate('buildings_research_row'); $TechScrTPL = gettemplate('buildings_research_script'); foreach ($lang['tech'] as $Tech => $TechName) { if ($Tech > 105 && $Tech <= 199) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) { $RowParse = $lang; $RowParse['dpath'] = $dpath; $RowParse['tech_id'] = $Tech; $building_level = $CurrentUser[$resource[$Tech]]; $RowParse['tech_level'] = $building_level == 0 ? "" : "( " . $lang['level'] . " " . $building_level . " )"; $RowParse['tech_name'] = $TechName; $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech]; $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech); $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech); $RowParse['search_time'] = ShowBuildTime($SearchTime); $RowParse['tech_restp'] = $lang['Rest_ress'] . " " . GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true); $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech); // Arbre de decision de ce que l'on met dans la derniere case de la ligne if (!$InResearch) { $LevelToDo = 1 + $CurrentUser[$resource[$Tech]]; if ($CanBeDone) { if (!CheckLabSettingsInQueue($CurrentPlanet)) { // Le laboratoire est cours de construction ou d'evolution // Et dans la config du systeme, on ne permet pas la recherche pendant // que le labo est en construction ou evolution ! if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>"; } } else { $TechnoLink = "<a href='#' onclick=\"document.location.replace('buildings.php?mode=research&cmd=search&tech=" . $Tech . "')\">"; if ($LevelToDo == 1) { $TechnoLink .= "<font color=#00FF00>" . $lang['Rechercher'] . "</font>"; } else { $TechnoLink .= "<font color=#00FF00>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>"; } $TechnoLink .= "</a>"; } } else { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>"; } } } else { // Y a une construction en cours if ($ThePlanet["b_tech_id"] == $Tech) { // C'est le technologie en cours de recherche $bloc = $lang; if ($ThePlanet['id'] != $CurrentPlanet['id']) { // Ca se passe sur une autre planete $bloc['tech_time'] = $ThePlanet["b_tech"] - time(); $bloc['tech_name'] = $lang['on'] . "<br>" . $ThePlanet["name"]; $bloc['tech_home'] = $ThePlanet["id"]; $bloc['tech_id'] = $ThePlanet["b_tech_id"]; $TechnoLink = "<center>Wir zur Zeit auf Planet<br>" . $ThePlanet["name"] . " geforscht.</center>"; } else { // Ca se passe sur la planete actuelle $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time(); $bloc['tech_name'] = ""; $bloc['tech_home'] = $CurrentPlanet["id"]; $bloc['tech_id'] = $CurrentPlanet["b_tech_id"]; $TechnoLink = parsetemplate($TechScrTPL, $bloc); } } else { // Technologie pas en cours recherche $TechnoLink = "<center>-</center>"; } } $RowParse['tech_link'] = $TechnoLink; $TechnoList .= parsetemplate($TechRowTPL, $RowParse); } } } $PageParse = $lang; $PageParse['noresearch'] = $NoResearchMessage; $PageParse['technolist'] = $TechnoList; $Page .= parsetemplate(gettemplate('buildings_research'), $PageParse); display($Page, $lang['Research']); }
public function __construct() { global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $db, $pricelist; include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.' . PHP_EXT; include_once ROOT_PATH . 'includes/functions/GetElementPrice.' . PHP_EXT; $template = new template(); $template->page_header(); $template->page_topnav(); $template->page_leftmenu(); $template->page_planetmenu(); $template->page_footer(); if ($PLANET[$resource[31]] == 0) { $template->message($LNG['bd_lab_required']); exit; } $bContinue = $this->CheckLabSettingsInQueue($PLANET) ? true : false; $PLANET[$resource[31] . '_inter'] = $this->CheckAndGetLabLevel($USER, $PLANET); $TheCommand = request_var('cmd', ''); $Element = request_var('tech', 0); $PlanetRess = new ResourceUpdate(); if ($USER['urlaubs_modus'] == 0 && !empty($TheCommand) && $bContinue) { switch ($TheCommand) { case 'cancel': if (empty($USER['b_tech'])) { break; } $costs = GetBuildingPrice($USER, $PLANET, $USER['b_tech_id']); if ($PLANET['id'] == $USER['b_tech_planet']) { $PLANET['metal'] += $costs['metal']; $PLANET['crystal'] += $costs['crystal']; $PLANET['deuterium'] += $costs['deuterium']; } else { $db->query("UPDATE " . PLANETS . " SET `metal` = `metal` + '" . $costs['metal'] . "', `crystal` = `crystal` + '" . $costs['crystal'] . "', `deuterium` = `deuterium` + '" . $costs['deuterium'] . "' WHERE `id` = '" . $USER['b_tech_planet'] . "';"); } $USER['darkmatter'] += $costs['darkmatter']; $USER['b_tech_id'] = 0; $USER['b_tech'] = 0; $USER['b_tech_planet'] = 0; break; case 'search': if (!empty($USER['b_tech']) || empty($Element) || !in_array($Element, $reslist['tech']) || $USER[$resource[$Element]] >= $pricelist[$Element]['max'] || !IsTechnologieAccessible($USER, $PLANET, $Element) || !IsElementBuyable($USER, $PLANET, $Element)) { break; } $costs = GetBuildingPrice($USER, $PLANET, $Element); $PLANET['metal'] -= $costs['metal']; $PLANET['crystal'] -= $costs['crystal']; $PLANET['deuterium'] -= $costs['deuterium']; $USER['darkmatter'] -= $costs['darkmatter']; $USER['b_tech_id'] = $Element; $USER['b_tech'] = TIMESTAMP + GetBuildingTime($USER, $PLANET, $Element); $USER['b_tech_planet'] = $PLANET['id']; break; } } $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $ScriptInfo = array(); foreach ($reslist['tech'] as $ID => $Element) { if (IsTechnologieAccessible($USER, $PLANET, $Element)) { $CanBeDone = IsElementBuyable($USER, $PLANET, $Element); if (isset($pricelist[$Element]['max']) && $USER[$resource[$Element]] >= $pricelist[$Element]['max']) { $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_maxlevel'] . "</font>"; } elseif ($USER['b_tech_id'] == 0) { $LevelToDo = 1 + $USER[$resource[$Element]]; if ($CanBeDone && $this->CheckLabSettingsInQueue($PLANET)) { $TechnoLink = "<a href=\"game.php?page=buildings&mode=research&cmd=search&tech=" . $Element . "\"><font color=\"#00FF00\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font></a>"; } else { $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>"; } } else { if ($USER['b_tech_id'] == $Element) { if ($USER['b_tech_planet'] == $PLANET['id']) { $template->loadscript('research.js'); $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => '', 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']); } else { $THEPLANET = $db->uniquequery("SELECT `name` FROM " . PLANETS . " WHERE `id` = '" . $USER['b_tech_planet'] . "';"); $template->loadscript('research.js'); $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => $LNG['bd_on'] . '<br>' . $THEPLANET['name'], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']); } $TechnoLink = '<div id="research"></div>'; } else { $TechnoLink = '<center>-</center>'; } } $ResearchList[] = array('id' => $Element, 'maxinfo' => isset($pricelist[$Element]['max']) && $pricelist[$Element]['max'] != 255 ? sprintf($LNG['bd_max_lvl'], $pricelist[$Element]['max']) : '', 'name' => $LNG['tech'][$Element], 'descr' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'restprice' => $this->GetRestPrice($Element), 'elvl' => $Element == 106 ? $USER['rpg_espion'] * ESPION . " (" . $LNG['tech'][610] . ")" : ($Element == 108 ? $USER['rpg_commandant'] * COMMANDANT . " (" . $LNG['tech'][611] . ")" : false), 'lvl' => $USER[$resource[$Element]], 'link' => $TechnoLink); } } $template->assign_vars(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'ScriptInfo' => json_encode($ScriptInfo), 'bd_building_lab' => $LNG['bd_building_lab'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_lvl' => $LNG['bd_lvl'], 'fgf_time' => $LNG['fgf_time'])); $template->show('buildings_research.tpl'); }
function IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, $Incremental = true, $ForDestroy = false) { if ($CurrentUser['vacation']) { return false; } $array = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, $Incremental, $ForDestroy); foreach ($array as $ResType => $resorceNeeded) { if ($resorceNeeded > $CurrentPlanet[$ResType]) { return false; } } return true; }
public function SetNextQueueTechOnTop() { global $resource, $db, $LNG; if (empty($this->USER['b_tech_queue'])) { $this->USER['b_tech'] = 0; $this->USER['b_tech_id'] = 0; $this->USER['b_tech_planet'] = 0; $this->USER['b_tech_queue'] = ''; return false; } $QueueArray = explode(";", $this->USER['b_tech_queue']); $Loop = true; while ($Loop == true) { $ListIDArray = explode(",", $QueueArray[0]); if ($Planet != $this->PLANET['id']) { $PLANET = $db->uniquequery("SELECT * FROM " . PLANETS . " WHERE `id` = '" . $ListIDArray[4] . "';"); } else { $PLANET = $this->PLANET; } $PLANET[$resource[31] . '_inter'] = $this->CheckAndGetLabLevel($this->USER, $PLANET); $Element = $ListIDArray[0]; $Level = $ListIDArray[1]; $BuildTime = GetBuildingTime($this->USER, $PLANET, $Element); $BuildEndTime = $this->USER['b_tech'] + $BuildTime; $Planet = $ListIDArray[4]; $QueueArray[0] = implode(",", array($Element, $Level, $BuildTime, $BuildEndTime, $Planet)); $ForDestroy = $BuildMode == 'destroy' ? true : false; $HaveNoMoreLevel = false; $HaveRessources = IsElementBuyable($this->USER, $this->PLANET, $Element, true, false); if ($ListIDArray[4] != $this->PLANET['id']) { $PlanetRess = new ResourceUpdate(false); list(, $PLANET) = $PlanetRess->CalcResource($this->USER, $PLANET, true, $BuildEndTime); } if ($HaveRessources == true) { $Needed = GetBuildingPrice($this->USER, $PLANET, $Element); $this->PLANET['metal'] -= $Needed['metal']; $this->PLANET['crystal'] -= $Needed['crystal']; $this->PLANET['deuterium'] -= $Needed['deuterium']; $this->USER['darkmatter'] -= $Needed['darkmatter']; $this->USER['b_tech_id'] = $Element; $this->USER['b_tech'] = $BuildEndTime; $this->USER['b_tech_planet'] = $Planet; $NewQueue = implode(';', $QueueArray); $Loop = false; } else { if ($this->USER['hof'] == 1) { $Needed = GetBuildingPrice($this->USER, $PlanetTechBuilds, $Element, true, $ForDestroy); $Message = sprintf($LNG['sys_notenough_money'], $this->PLANET['name'], $this->PLANET['id'], $this->PLANET['galaxy'], $this->PLANET['system'], $this->PLANET['planet'], $LNG['tech'][$Element], pretty_number($this->PLANET['metal']), $LNG['Metal'], pretty_number($this->PLANET['crystal']), $LNG['Crystal'], pretty_number($this->PLANET['deuterium']), $LNG['Deuterium'], pretty_number($Needed['metal']), $LNG['Metal'], pretty_number($Needed['crystal']), $LNG['Crystal'], pretty_number($Needed['deuterium']), $LNG['Deuterium']); SendSimpleMessage($this->USER['id'], '', $this->TIME, 99, $LNG['sys_techlist'], $LNG['sys_buildlist_fail'], $Message); } array_shift($QueueArray); if (count($QueueArray) == 0) { $BuildEndTime = 0; $NewQueue = ''; $Loop = false; } else { $BaseTime = $BuildEndTime - $BuildTime; foreach ($QueueArray as $ID => $QueueInfo) { $ListIDArray = explode(",", $QueueInfo); $ListIDArray[2] = GetBuildingTime($this->USER, $Planet, $ListIDArray[0]); $BaseTime += $ListIDArray[2]; $ListIDArray[3] = $BaseTime; $QueueArray[$ID] = implode(",", $ListIDArray); } } } } $this->USER['b_tech'] = $BuildEndTime; $this->USER['b_tech_queue'] = $NewQueue; }
public function __construct() { global $ProdGrid, $LNG, $resource, $reslist, $CONF, $db, $PLANET, $USER; include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php'; include_once ROOT_PATH . 'includes/functions/GetElementPrice.php'; $TheCommand = request_var('cmd', ''); $Element = request_var('building', 0); $ListID = request_var('listid', 0); $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); if (!empty($Element) && $USER['urlaubs_modus'] == 0 && (IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['allow'][$PLANET['planet_type']])) || $TheCommand == "cancel" || $TheCommand == "remove") { if ($Element == 31 && $USER["b_tech_planet"] != 0 || ($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) { $TheCommand = ''; } switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue($PlanetRess); break; case 'remove': $this->RemoveBuildingFromQueue($ListID, $PlanetRess); break; case 'insert': $this->AddBuildingToQueue($Element, true); break; case 'destroy': $this->AddBuildingToQueue($Element, false); break; } } $PlanetRess->SavePlanetToDB(); $Queue = $this->ShowBuildingQueue(); $template = new template(); $CanBuildElement = count($Queue) < MAX_BUILDING_QUEUE_SIZE ? true : false; $BuildingPage = ""; $CurrentMaxFields = CalculateMaxPlanetFields($PLANET); $RoomIsOk = $PLANET["field_current"] < $CurrentMaxFields - count($Queue) ? true : false; $BuildEnergy = $USER[$resource[113]]; $BuildLevelFactor = 10; $BuildTemp = $PLANET['temp_max']; foreach ($reslist['allow'][$PLANET['planet_type']] as $ID => $Element) { if (!IsTechnologieAccessible($USER, $PLANET, $Element)) { continue; } $HaveRessources = IsElementBuyable($USER, $PLANET, $Element, true, false); if (in_array($Element, $reslist['prod'])) { $BuildLevel = $PLANET[$resource[$Element]]; $Need = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1); $BuildLevel += 1; $Prod = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1); $EnergyNeed = $Prod - $Need; } else { unset($EnergyNeed); } $parse['click'] = ''; $NextBuildLevel = $PLANET[$resource[$Element]] + 1; if ($RoomIsOk && $CanBuildElement) { $parse['click'] = $HaveRessources == true ? "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><span style=\"color:#00FF00\">" . ($PLANET['b_building'] != 0 ? $LNG['bd_add_to_list'] : ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel)) . "</span></a>" : "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>"; } elseif ($RoomIsOk && !$CanBuildElement) { $parse['click'] = "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>"; } else { $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_no_more_fields'] . "</span>"; } if (($Element == 6 || $Element == 31) && $USER['b_tech'] > TIMESTAMP) { $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>"; } elseif (($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) { $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>"; } $BuildInfoList[] = array('id' => $Element, 'name' => $LNG['tech'][$Element], 'descriptions' => $LNG['res']['descriptions'][$Element], 'level' => $PLANET[$resource[$Element]], 'destroyress' => array_map('pretty_number', GetBuildingPrice($USER, $PLANET, $Element, true, true)), 'destroytime' => pretty_time(GetBuildingTime($USER, $PLANET, $Element, true)), 'price' => GetElementPrice($USER, $PLANET, $Element, true), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'EnergyNeed' => isset($EnergyNeed) ? sprintf($EnergyNeed < 0 ? $LNG['bd_need_engine'] : $LNG['bd_more_engine'], pretty_number(abs($EnergyNeed)), $LNG['Energy']) : "", 'BuildLink' => $parse['click'], 'restprice' => $this->GetRestPrice($Element)); } if ($PLANET['b_building'] != 0) { $template->execscript('ReBuildView();Buildlist();'); $template->loadscript('buildlist.js'); $template->assign_vars(array('data' => json_encode(array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $Queue)))); } $template->assign_vars(array('BuildInfoList' => $BuildInfoList, 'bd_lvl' => $LNG['bd_lvl'], 'bd_next_level' => $LNG['bd_next_level'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Norio' => $LNG['Norio'], 'Darkmatter' => $LNG['Darkmatter'], 'bd_dismantle' => $LNG['bd_dismantle'], 'fgf_time' => $LNG['fgf_time'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_jump_gate_action' => $LNG['bd_jump_gate_action'], 'bd_price_for_destroy' => $LNG['bd_price_for_destroy'], 'bd_destroy_time' => $LNG['bd_destroy_time'])); $template->show("buildings_overview.tpl"); }
function ShowBuildingInfoPage($CurrentUser, $CurrentPlanet, $BuildID) { global $dpath, $lang, $sn_data; $sn_groups =& $sn_data['groups']; $unit_data =& $sn_data[$BuildID]; lng_include('infos'); $GateTPL = ''; $DestroyTPL = ''; $TableHeadTPL = ''; $parse = $lang; // Données de base $parse['dpath'] = $dpath; $parse['name'] = $lang['tech'][$BuildID]; $parse['image'] = $BuildID; $parse['description'] = $lang['info'][$BuildID]['description']; if ($BuildID >= 1 && $BuildID <= 3) { // Cas des mines $PageTPL = gettemplate('info_buildings_table'); $DestroyTPL = gettemplate('info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_p_hour}</td><td class=\"c\">{nfo_difference}</td><td class=\"c\">{nfo_used_energy}</td><td class=\"c\">{nfo_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; } elseif ($BuildID == 4) { // Centrale Solaire $PageTPL = gettemplate('info_buildings_table'); $DestroyTPL = gettemplate('info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_energy}</td><td class=\"c\">{nfo_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th></tr>"; } elseif ($BuildID == 12) { // Centrale Fusion $PageTPL = gettemplate('info_buildings_table'); $DestroyTPL = gettemplate('info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_energy}</td><td class=\"c\">{nfo_difference}</td><td class=\"c\">{nfo_used_deuter}</td><td class=\"c\">{nfo_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; } elseif ($BuildID >= 14 && $BuildID <= 32) { // Batiments Generaux $PageTPL = gettemplate('info_buildings_general'); $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID == 33) { // Batiments Terraformer $PageTPL = gettemplate('info_buildings_general'); } elseif ($BuildID == 34) { // Dépot d'alliance $PageTPL = gettemplate('info_buildings_general'); $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID == 35) { // nano $PageTPL = gettemplate('info_buildings_general'); $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID == 44) { // Silo de missiles $PageTPL = gettemplate('info_buildings_general'); $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID == 41) { // Batiments lunaires $PageTPL = gettemplate('info_buildings_general'); } elseif ($BuildID == 42) { // Phalange $PageTPL = gettemplate('info_buildings_table'); $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_range}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_range}</th></tr>"; $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif ($BuildID == 43) { // Porte de Saut $PageTPL = gettemplate('info_buildings_general'); $GateTPL = gettemplate('gate_fleet_table'); $DestroyTPL = gettemplate('info_buildings_destroy'); } elseif (in_array($BuildID, $sn_data['groups']['tech'])) { // Laboratoire $PageTPL = gettemplate('info_buildings_general'); } elseif (in_array($BuildID, $sn_data['groups']['fleet'])) { // Flotte $PageTPL = gettemplate('info_buildings_fleet'); $parse['element_typ'] = $lang['tech'][SHIP_FLEET]; $rapid_fire = eco_render_rapid_fire($BuildID); $parse['rf_info_to'] = $rapid_fire['to']; // Rapid Fire vers $parse['rf_info_fr'] = $rapid_fire['from']; // Rapid Fire de $parse['hull_pt'] = pretty_number(($sn_data[$BuildID]['metal'] + $sn_data[$BuildID]['crystal']) / 10); // Points de Structure $parse['shield_pt'] = pretty_number($sn_data[$BuildID]['shield']); // Points de Bouclier $parse['attack_pt'] = pretty_number($sn_data[$BuildID]['attack']); // Points d'Attaque $parse['capacity_pt'] = pretty_number($sn_data[$BuildID]['capacity']); // Capacitée de fret $parse['base_speed'] = pretty_number($sn_data[$BuildID]['speed']); // Vitesse de base $parse['base_conso'] = pretty_number($sn_data[$BuildID]['consumption']); // Consommation de base if ($BuildID == SHIP_CARGO_SMALL) { $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($sn_data[$BuildID]['speed2']) . ")</font>"; // Vitesse rééquipée $parse['upd_conso'] = "<font color=\"yellow\">(" . pretty_number($sn_data[$BuildID]['consumption2']) . ")</font>"; // Consommation apres rééquipement } elseif ($BuildID == SHIP_BOMBER) { $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($sn_data[$BuildID]['speed2']) . ")</font>"; // Vitesse rééquipée } } elseif (in_array($BuildID, $sn_data['groups']['defense_active'])) { // Defenses $PageTPL = gettemplate('info_buildings_defense'); $parse['element_typ'] = $lang['tech'][400]; $rapid_fire = eco_render_rapid_fire($BuildID); $parse['rf_info_to'] = $rapid_fire['to']; // Rapid Fire vers $parse['rf_info_fr'] = $rapid_fire['from']; // Rapid Fire de $parse['hull_pt'] = pretty_number(($sn_data[$BuildID]['metal'] + $sn_data[$BuildID]['crystal']) / 10); // Points de Structure $parse['shield_pt'] = pretty_number($sn_data[$BuildID]['shield']); // Points de Bouclier $parse['attack_pt'] = pretty_number($sn_data[$BuildID]['attack']); // Points d'Attaque } elseif ($BuildID >= 502 && $BuildID <= 503) { // Misilles $PageTPL = gettemplate('info_buildings_defense'); $parse['element_typ'] = $lang['tech'][400]; $parse['hull_pt'] = pretty_number($sn_data[$BuildID]['metal'] + $sn_data[$BuildID]['crystal']); // Points de Structure $parse['shield_pt'] = pretty_number($sn_data[$BuildID]['shield']); // Points de Bouclier $parse['attack_pt'] = pretty_number($sn_data[$BuildID]['attack']); // Points d'Attaque } elseif (in_array($BuildID, $sn_data['groups']['mercenaries'])) { // Officiers $PageTPL = gettemplate('info_officiers_general'); $mercenary = $sn_data[$BuildID]; $mercenary_bonus = $mercenary['bonus']; $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}"; switch ($mercenary['bonus_type']) { case BONUS_PERCENT: $mercenary_bonus = "{$mercenary_bonus}%"; break; case BONUS_ADD: break; case BONUS_ABILITY: $mercenary_bonus = ''; break; default: break; } $parse['EFFECT'] = $lang['info'][$BuildID]['effect']; $parse['mercenary_bonus'] = $mercenary_bonus; $parse['max_level'] = $mercenary['max']; } // ---- Tableau d'evolution if ($TableHeadTPL != '') { $parse['table_head'] = parsetemplate($TableHeadTPL, $lang); $parse['table_data'] = ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $TableTPL); } // La page principale $page = parsetemplate($PageTPL, $parse); if ($GateTPL != '') { if ($CurrentPlanet[$unit_data['name']] > 0) { $RestString = GetNextJumpWaitTime($CurrentPlanet); $parse['gate_start_link'] = uni_render_coordinates_href($CurrentPlanet, '', 3); if ($RestString['value'] != 0) { $parse['gate_time_script'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], true); $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>"; $parse['gate_script_go'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], false); } else { $parse['gate_time_script'] = ""; $parse['gate_wait_time'] = ""; $parse['gate_script_go'] = ""; } $parse['gate_dest_moons'] = BuildJumpableMoonCombo($CurrentUser, $CurrentPlanet); $parse['gate_fleet_rows'] = BuildFleetListRows($CurrentPlanet); $page .= parsetemplate($GateTPL, $parse); } } if ($DestroyTPL != '') { if ($CurrentPlanet[$unit_data['name']] > 0) { // ---- Destruction $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true); $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2; $parse['destroyurl'] = "buildings.php?mode=" . QUE_STRUCTURES . "&action=destroy&unit_id={$BuildID}"; // Non balisé les balises sont dans le $parse['levelvalue'] = $CurrentPlanet[$unit_data['name']]; // Niveau du batiment a detruire $parse['nfo_metal'] = $lang['Metal']; $parse['nfo_crysta'] = $lang['Crystal']; $parse['nfo_deuter'] = $lang['Deuterium']; $parse['metal'] = pretty_number($NeededRessources['metal']); // Cout en metal de la destruction $parse['crystal'] = pretty_number($NeededRessources['crystal']); // Cout en cristal de la destruction $parse['deuterium'] = pretty_number($NeededRessources['deuterium']); // Cout en deuterium de la destruction $parse['destroytime'] = pretty_time($DestroyTime); // Durée de la destruction // L'insert de destruction $page .= parsetemplate($DestroyTPL, $parse); } } return $page; }
protected function Research($Techno) { if (IsTechnologieAccessible($this->user, $this->CurrentPlanet, $Techno) && IsElementBuyable($this->user, $this->CurrentPlanet, $Techno)) { $costs = GetBuildingPrice($this->user, $this->CurrentPlanet, $Techno); $this->CurrentPlanet['metal'] -= $costs['metal']; $this->CurrentPlanet['crystal'] -= $costs['crystal']; $this->CurrentPlanet['deuterium'] -= $costs['deuterium']; $this->CurrentPlanet["b_tech_id"] = $Techno; $this->CurrentPlanet["b_tech"] = time() + GetBuildingTime($this->user, $this->CurrentPlanet, $Techno); $this->user["b_tech_planet"] = $this->CurrentPlanet["id"]; $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech_id` = '" . $this->CurrentPlanet['b_tech_id'] . "', "; $QryUpdatePlanet .= "`b_tech` = '" . $this->CurrentPlanet['b_tech'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $this->CurrentPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $QryUpdateUser = "******"; $QryUpdateUser .= "`b_tech_planet` = '" . $this->user['b_tech_planet'] . "' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $this->user['id'] . "';"; doquery($QryUpdateUser, 'users'); } }
/** * HandleElementBuildingQueue.php * * @version 2 * @copyright 2009 By MadnessRed for XNova Redesigned */ function HandleElementBuildingQueue($CurrentUser, &$CurrentPlanet, $ProductionTime) { global $resource; // Pendant qu'on y est, si on verifiait ce qui se passe dans la queue de construction du chantier ? //Right, lets make a new shipyard queue management. //So some stuff in shipyard? //echo $CurrentPlanet['b_hangar_id']; //Lets stop it complaining, we should define $cost as an array here $cost = array(); if (strlen($CurrentPlanet['b_hangar_id']) > 0) { //Whats be built, so far nothing, $built = array(); $cost = 0; //lets explode the queue into an array $queue = explode(';', $CurrentPlanet['b_hangar_id']); //don't stop yet, we haven't started $stop = false; //make an array $built = array(); //Clear the queue to add to it later. $CurrentPlanet['b_hangar_id'] = ''; //Add left overs from last attempt $ProductionTime += $CurrentPlanet['b_hangar']; //now, keeping the queue in that order. foreach ($queue as $todo) { //Should we stop? if (!$stop) { //Explodew the queue $q = explode(',', $todo); //Add the build time to the temp array $q[2] = GetBuildingTime($CurrentUser, $CurrentPlanet, $q[0]); //Now is there time to build all of these? if ($q[2] * $q[1] <= $ProductionTime) { $ProductionTime -= $q[2] * $q[1]; $built[$q[0]] += $q[1]; $CurrentPlanet[$resource[$q[0]]] += $q[1]; //$ncost = GetBuildingPrice(array(),$CurrentPlanet,$q[0],false,false,true); $ncost = GetBuildingPrice(array(), $CurrentPlanet, $q[0], false); if (!is_array($ncost)) { trigger_error("\$ncost returned from GetBuildingPrice was not the expected array. The following was returned.<br />" . nl2br(print_r($ncost, true)) . "<br />The arguments were:<br />GetBuildingPrice(array()," . $CurrentPlanet . "," . $q[0] . ",false,false,true);"); } //foreach($ncost as $key => $val){ $cost[$key] += ($val * $q[1]); } foreach ($ncost as $val) { $cost += $val * $q[1]; } } elseif ($q[2] <= $ProductionTime) { $canbuild = floor($ProductionTime / $q[2]); $ProductionTime -= $q[2] * $canbuild; $built[$q[0]] += $canbuild; $CurrentPlanet[$resource[$q[0]]] += $canbuild; //$ncost = GetBuildingPrice(array(),$CurrentPlanet,$q[0],false,false,true); $ncost = GetBuildingPrice(array(), $CurrentPlanet, $q[0], false); if (!is_array($ncost)) { trigger_error("\$ncost returned from GetBuildingPrice was not the expected array. The following was returned.<br />" . nl2br(print_r($ncost, true)) . "<br />The arguments were:<br />GetBuildingPrice(array()," . $CurrentPlanet . "," . $q[0] . ",false,false,true);"); } //foreach($ncost as $key => $val){ $cost[$key] += ($val * $canbuild); } foreach ($ncost as $val) { $cost += $val * $canbuild; } //And lets upt the rest back into the queue $CurrentPlanet['b_hangar_id'] .= $q[0] . "," . ($q[1] - $canbuild) . ";"; //And stop doing stuff. $stop = true; } else { $CurrentPlanet['b_hangar_id'] .= $todo . ";"; $stop = true; } } else { $CurrentPlanet['b_hangar_id'] .= $todo . ";"; } } //And how much time is left over? $CurrentPlanet['b_hangar'] = $ProductionTime; //Add what he build to the stats //AddPoints($cost,false,$CurrentUser['id']); } else { $built = array(); $CurrentPlanet['b_hangar'] = 0; } //print_r($built); return $built; }
function CheckPlanetBuildingQueue(&$CurrentPlanet, &$CurrentUser) { global $resource; $RetValue = false; if ($CurrentPlanet['b_building_id'] != 0) { $CurrentQueue = $CurrentPlanet['b_building_id']; if ($CurrentQueue != 0) { $QueueArray = explode(";", $CurrentQueue); $ActualCount = count($QueueArray); } $BuildArray = explode(",", $QueueArray[0]); $BuildEndTime = floor($BuildArray[3]); $BuildMode = $BuildArray[4]; $Element = $BuildArray[0]; array_shift($QueueArray); if ($BuildMode == 'destroy') { $ForDestroy = true; } else { $ForDestroy = false; } if ($BuildEndTime <= time()) { $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy); $Units = $Needed['metal'] + $Needed['crystal'] + $Needed['deuterium']; $current = intval($CurrentPlanet['field_current']); $max = intval($CurrentPlanet['field_max']); if ($CurrentPlanet['planet_type'] == 3) { if ($Element == 41) { $current += 1; $max += FIELDS_BY_MOONBASIS_LEVEL; $CurrentPlanet[$resource[$Element]]++; } elseif ($Element != 0) { if ($ForDestroy == false) { $current += 1; $CurrentPlanet[$resource[$Element]]++; } else { $current -= 1; $CurrentPlanet[$resource[$Element]]--; } } } elseif ($CurrentPlanet['planet_type'] == 1) { if ($ForDestroy == false) { $current += 1; $CurrentPlanet[$resource[$Element]]++; } else { $current -= 1; $CurrentPlanet[$resource[$Element]]--; } } if (count($QueueArray) == 0) { $NewQueue = 0; } else { $NewQueue = implode(";", $QueueArray); } $CurrentPlanet['b_building'] = 0; $CurrentPlanet['b_building_id'] = $NewQueue; $CurrentPlanet['field_current'] = $current; $CurrentPlanet['field_max'] = $max; $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`" . $resource[$Element] . "` = '" . $CurrentPlanet[$resource[$Element]] . "', "; $QryUpdatePlanet .= "`b_building` = '" . $CurrentPlanet['b_building'] . "' , "; $QryUpdatePlanet .= "`b_building_id` = '" . $CurrentPlanet['b_building_id'] . "' , "; $QryUpdatePlanet .= "`field_current` = '" . $CurrentPlanet['field_current'] . "', "; $QryUpdatePlanet .= "`field_max` = '" . $CurrentPlanet['field_max'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $RetValue = true; } else { $RetValue = false; } } else { $CurrentPlanet['b_building'] = 0; $CurrentPlanet['b_building_id'] = 0; $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_building` = '" . $CurrentPlanet['b_building'] . "' , "; $QryUpdatePlanet .= "`b_building_id` = '" . $CurrentPlanet['b_building_id'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $RetValue = false; } return $RetValue; }
function ResearchBuildingPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet) { global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET; $NoResearchMessage = ""; $bContinue = true; if ($CurrentPlanet[$resource[31]] == 0) { message($lang['no_laboratory'], $lang['Research']); } if (!CheckLabSettingsInQueue($CurrentPlanet)) { $NoResearchMessage = $lang['labo_on_update']; $bContinue = false; } if (isset($_GET['cmd'])) { $TheCommand = $_GET['cmd']; $Techno = intval($_GET['tech']); if (is_numeric($Techno)) { if (in_array($Techno, $reslist['tech'])) { if (is_array($ThePlanet)) { $WorkingPlanet = $ThePlanet; } else { $WorkingPlanet = $CurrentPlanet; } switch ($TheCommand) { case 'cancel': if ($ThePlanet['b_tech_id'] == $Techno) { $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Techno, true, $ForDestroy); $CurrentPlanet['metal'] += $Needed['metal']; $CurrentPlanet['crystal'] += $Needed['crystal']; $CurrentPlanet['deuterium'] += $Needed['deuterium']; $WorkingPlanet['b_tech_id'] = 0; $WorkingPlanet["b_tech"] = 0; $CurrentUser['b_tech_planet'] = 0; $UpdateData = true; $InResearch = false; } break; case 'search': if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] -= $costs['metal']; $WorkingPlanet['crystal'] -= $costs['crystal']; $WorkingPlanet['deuterium'] -= $costs['deuterium']; $WorkingPlanet["b_tech_id"] = $Techno; $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno); $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"]; $UpdateData = true; $InResearch = true; } break; } if ($UpdateData == true) { $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', "; $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', "; $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', "; $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', "; $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $QryUpdateUser = "******"; $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; doquery($QryUpdateUser, 'users'); } if (is_array($ThePlanet)) { $ThePlanet = $WorkingPlanet; } else { $CurrentPlanet = $WorkingPlanet; if ($TheCommand == 'search') { $ThePlanet = $CurrentPlanet; } } } } else { $bContinue = false; } } $TechRowTPL = gettemplate('buildings_research_row'); $TechScrTPL = gettemplate('buildings_research_script'); foreach ($lang['tech'] as $Tech => $TechName) { if ($Tech > 105 && $Tech <= 199) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) { $RowParse = $lang; $RowParse['dpath'] = $dpath; $RowParse['tech_id'] = $Tech; $building_level = $CurrentUser[$resource[$Tech]]; $RowParse['tech_level'] = $building_level == 0 ? "" : "( " . $lang['level'] . " " . $building_level . " )"; $RowParse['tech_name'] = $TechName; $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech]; $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech); $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech); $RowParse['search_time'] = ShowBuildTime($SearchTime); $RowParse['tech_restp'] = $lang['Rest_ress'] . " " . GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true); $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech); if (!$InResearch) { $LevelToDo = 1 + $CurrentUser[$resource[$Tech]]; if ($CanBeDone) { if (!CheckLabSettingsInQueue($CurrentPlanet)) { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>"; } } else { $TechnoLink = "<a href=\"buildings.php?mode=research&cmd=search&tech=" . $Tech . "\">"; if ($LevelToDo == 1) { $TechnoLink .= "<font color=#00FF00>" . $lang['Rechercher'] . "</font>"; } else { $TechnoLink .= "<font color=#00FF00>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>"; } $TechnoLink .= "</a>"; } } else { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>"; } } } else { if ($ThePlanet["b_tech_id"] == $Tech) { $bloc = $lang; if ($ThePlanet['id'] != $CurrentPlanet['id']) { $bloc['tech_time'] = $ThePlanet["b_tech"] - time(); $bloc['tech_name'] = $lang['on'] . "<br>" . $ThePlanet["name"]; $bloc['tech_home'] = $ThePlanet["id"]; $bloc['tech_id'] = $ThePlanet["b_tech_id"]; } else { $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time(); $bloc['tech_name'] = ""; $bloc['tech_home'] = $CurrentPlanet["id"]; $bloc['tech_id'] = $CurrentPlanet["b_tech_id"]; } $TechnoLink = parsetemplate($TechScrTPL, $bloc); } else { $TechnoLink = "<center>-</center>"; } } $RowParse['tech_link'] = $TechnoLink; $TechnoList .= parsetemplate($TechRowTPL, $RowParse); } } } $PageParse = $lang; $PageParse['noresearch'] = $NoResearchMessage; $PageParse['technolist'] = $TechnoList; $Page .= parsetemplate(gettemplate('buildings_research'), $PageParse); display($Page, $lang['Research']); }
public function __construct($CurrentUser, $CurrentPlanet, $BuildID) { global $dpath, $lang, $resource, $pricelist, $CombatCaps, $phpEx, $xgp_root; $GateTPL = ''; $DestroyTPL = ''; $TableHeadTPL = ''; $parse = $lang; $parse['dpath'] = $dpath; $parse['name'] = $lang['info'][$BuildID]['name']; $parse['image'] = $BuildID; $parse['description'] = $lang['info'][$BuildID]['description']; if ($BuildID >= 1 && $BuildID <= 3) { $PageTPL = gettemplate('infos/info_buildings_table'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_prod_p_hour}</td><td class=\"c\">{in_difference}</td><td class=\"c\">{in_used_energy}</td><td class=\"c\">{in_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; } elseif ($BuildID == 4) { $PageTPL = gettemplate('infos/info_buildings_table'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_prod_energy}</td><td class=\"c\">{in_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th></tr>"; } elseif ($BuildID == 12) { $PageTPL = gettemplate('infos/info_buildings_table'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_prod_energy}</td><td class=\"c\">{in_difference}</td><td class=\"c\">{in_used_deuter}</td><td class=\"c\">{in_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; } elseif ($BuildID >= 14 && $BuildID <= 32) { $PageTPL = gettemplate('infos/info_buildings_general'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); } elseif ($BuildID == 33) { $PageTPL = gettemplate('infos/info_buildings_general'); } elseif ($BuildID == 34) { $PageTPL = gettemplate('infos/info_buildings_general'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); } elseif ($BuildID == 44) { $PageTPL = gettemplate('infos/info_buildings_general'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); } elseif ($BuildID == 41) { $PageTPL = gettemplate('infos/info_buildings_general'); } elseif ($BuildID == 42) { $PageTPL = gettemplate('infos/info_buildings_table'); $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_range}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_range}</th></tr>"; $DestroyTPL = gettemplate('infos/info_buildings_destroy'); } elseif ($BuildID == 43) { $PageTPL = gettemplate('infos/info_buildings_general'); $GateTPL = gettemplate('infos/info_gate_table'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); if ($_POST) { message($this->DoFleetJump($CurrentUser, $CurrentPlanet), "game.php?page=infos&gid=43", 2); } } elseif ($BuildID >= 106 && $BuildID <= 199) { $PageTPL = gettemplate('infos/info_buildings_general'); } elseif ($BuildID >= 202 && $BuildID <= 224) { $PageTPL = gettemplate('infos/info_buildings_fleet'); $parse['element_typ'] = $lang['tech'][200]; $parse['rf_info_to'] = $this->ShowRapidFireTo($BuildID); $parse['rf_info_fr'] = $this->ShowRapidFireFrom($BuildID); $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']); $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']); $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']); $parse['capacity_pt'] = pretty_number($pricelist[$BuildID]['capacity']); $parse['base_speed'] = pretty_number($pricelist[$BuildID]['speed']); $parse['base_conso'] = pretty_number($pricelist[$BuildID]['consumption']); if ($BuildID == 202) { $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>"; $parse['upd_conso'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['consumption2']) . ")</font>"; } elseif ($BuildID == 211) { $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>"; } } elseif ($BuildID >= 401 && $BuildID <= 411) { $PageTPL = gettemplate('infos/info_buildings_defense'); $parse['element_typ'] = $lang['tech'][400]; $parse['rf_info_to'] = $this->ShowRapidFireTo($BuildID); $parse['rf_info_fr'] = $this->ShowRapidFireFrom($BuildID); $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']); $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']); $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']); } elseif ($BuildID >= 502 && $BuildID <= 503) { $PageTPL = gettemplate('infos/info_buildings_defense'); $parse['element_typ'] = $lang['tech'][400]; $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']); $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']); $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']); } elseif ($BuildID >= 601 && $BuildID <= 615) { $PageTPL = gettemplate('infos/info_officiers_general'); } if ($TableHeadTPL != '') { $parse['table_head'] = parsetemplate($TableHeadTPL, $lang); $parse['table_data'] = $this->ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $TableTPL); } $page = parsetemplate($PageTPL, $parse); if ($GateTPL != '') { if ($CurrentPlanet[$resource[$BuildID]] > 0) { $RestString = $this->GetNextJumpWaitTime($CurrentPlanet); $parse['gate_start_link'] = BuildPlanetAdressLink($CurrentPlanet); if ($RestString['value'] != 0) { include $xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx; $parse['gate_time_script'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], true); $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>"; $parse['gate_script_go'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], false); } else { $parse['gate_time_script'] = ""; $parse['gate_wait_time'] = ""; $parse['gate_script_go'] = ""; } $parse['gate_dest_moons'] = $this->BuildJumpableMoonCombo($CurrentUser, $CurrentPlanet); $parse['gate_fleet_rows'] = $this->BuildFleetListRows($CurrentPlanet); $page .= parsetemplate($GateTPL, $parse); } } if ($DestroyTPL != '') { if ($CurrentPlanet[$resource[$BuildID]] > 0) { $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true); $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2; $parse['destroyurl'] = "game.php?page=buildings&cmd=destroy&building=" . $BuildID; $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]]; $parse['nfo_metal'] = $lang['Metal']; $parse['nfo_crysta'] = $lang['Crystal']; $parse['nfo_deuter'] = $lang['Deuterium']; $parse['metal'] = pretty_number($NeededRessources['metal']); $parse['crystal'] = pretty_number($NeededRessources['crystal']); $parse['deuterium'] = pretty_number($NeededRessources['deuterium']); $parse['destroytime'] = pretty_time($DestroyTime); $page .= parsetemplate($DestroyTPL, $parse); } } return display($page); }
/** * Tis file is part of XNova:Legacies * * @license http://www.gnu.org/licenses/gpl-3.0.txt * @see http://www.xnova-ng.org/ * * Copyright (c) 2009-Present, XNova Support Team <http://www.xnova-ng.org> * All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * --> NOTICE <-- * This file is part of the core development branch, changing its contents will * make you unable to use the automatic updates manager. Please refer to the * documentation for further information about customizing XNova. * */ function CancelBuildingFromQueue(&$CurrentPlanet, &$CurrentUser) { $CurrentQueue = $CurrentPlanet['b_building_id']; if ($CurrentQueue != 0) { // Creation du tableau de la liste de construction $QueueArray = explode(";", $CurrentQueue); // Comptage du nombre d'elements dans la liste $ActualCount = count($QueueArray); // Stockage de l'element a 'interrompre' $CanceledIDArray = explode(",", $QueueArray[0]); $Element = $CanceledIDArray[0]; $BuildMode = $CanceledIDArray[4]; // pour savoir si on construit ou detruit $nb_item = $Element; if ($ActualCount > 1) { array_shift($QueueArray); $NewCount = count($QueueArray); // Mise a jour de l'heure de fin de construction theorique du batiment $BuildEndTime = time(); for ($ID = 0; $ID < $NewCount; $ID++) { $ListIDArray = explode(",", $QueueArray[$ID]); // Pour diminuer le niveau et le temps de construction // si le bâtiment qui est annulé se trouve plusieurs fois dans la queue // Exemple de queue de construction : // Mine de métal (Niveau 40) | Silo de missile (Niveau 30) | Silo de missiles (Niveau 31) | Mine de métal (Niveau 41) // Si on supprime le premier bâtiment, on aura dans la queue de construction : // Silo de missile (Niveau 30) | Silo de missiles (Niveau 31) | Mine de métal (Niveau 40) if ($nb_item == $ListIDArray[0]) { $ListIDArray[1] -= 1; $ListIDArray[2] = GetBuildingTimeLevel($CurrentUser, $CurrentPlanet, $ListIDArray[0], $ListIDArray[1]); } $BuildEndTime += $ListIDArray[2]; $ListIDArray[3] = $BuildEndTime; $QueueArray[$ID] = implode(",", $ListIDArray); } $NewQueue = implode(";", $QueueArray); $ReturnValue = true; $BuildEndTime = '0'; } else { $NewQueue = '0'; $ReturnValue = false; $BuildEndTime = '0'; } // Ici on va rembourser les ressources engagées ... // Deja le mode (car quand on detruit ca ne coute que la moitié du prix de construction classique if ($BuildMode == 'destroy') { $ForDestroy = true; } else { $ForDestroy = false; } if ($Element != false) { $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy); $CurrentPlanet['metal'] += $Needed['metal']; $CurrentPlanet['crystal'] += $Needed['crystal']; $CurrentPlanet['deuterium'] += $Needed['deuterium']; } } else { $NewQueue = '0'; $BuildEndTime = '0'; $ReturnValue = false; } $CurrentPlanet['b_building_id'] = $NewQueue; $CurrentPlanet['b_building'] = $BuildEndTime; return $ReturnValue; }
function ResearchBuildingPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet) { global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET; $NoResearchMessage = ""; $bContinue = true; // Deja est qu'il y a un laboratoire sur la planete ??? if ($CurrentPlanet[$resource[31]] == 0) { message($lang['no_laboratory'], $lang['Research']); } // Ensuite ... Est ce que la labo est en cours d'upgrade ? if (!CheckLabSettingsInQueue($CurrentPlanet)) { $NoResearchMessage = $lang['labo_on_update']; $bContinue = false; } // Boucle d'interpretation des eventuelles commandes if (isset($_GET['cmd'])) { $TheCommand = $_GET['cmd']; $Techno = (int) $_GET['tech']; if (is_numeric($Techno)) { if (in_array($Techno, $reslist['tech'])) { // Bon quand on arrive ici ... On sait deja qu'on a une technologie valide if (is_array($ThePlanet)) { $WorkingPlanet = $ThePlanet; } else { $WorkingPlanet = $CurrentPlanet; } switch ($TheCommand) { case 'cancel': if ($ThePlanet['b_tech_id'] == $Techno) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] += $costs['metal']; $WorkingPlanet['crystal'] += $costs['crystal']; $WorkingPlanet['deuterium'] += $costs['deuterium']; $WorkingPlanet['appolonium'] += $costs['appolonium']; if ($WorkingPlanet['id'] == $CurrentPlanet['id']) { $CurrentPlanet['metal'] += $costs['metal']; $CurrentPlanet['crystal'] += $costs['crystal']; $CurrentPlanet['deuterium'] += $costs['deuterium']; $CurrentPlanet['appolonium'] += $costs['appolonium']; } $WorkingPlanet['b_tech_id'] = 0; $WorkingPlanet["b_tech"] = 0; $CurrentUser['b_tech_planet'] = 0; $UpdateData = true; $InResearch = false; } break; case 'search': if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] -= $costs['metal']; $WorkingPlanet['crystal'] -= $costs['crystal']; $WorkingPlanet['deuterium'] -= $costs['deuterium']; $WorkingPlanet['appolonium'] -= $costs['appolonium']; $WorkingPlanet["b_tech_id"] = $Techno; $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno); $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"]; $UpdateData = true; $InResearch = true; } break; } if ($UpdateData == true) { $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', "; $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', "; $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', "; $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', "; $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "', "; $QryUpdatePlanet .= "`appolonium` = '" . $WorkingPlanet['appolonium'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $QryUpdateUser = "******"; $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; doquery($QryUpdateUser, 'users'); } if (is_array($ThePlanet)) { $ThePlanet = $WorkingPlanet; } else { $CurrentPlanet = $WorkingPlanet; if ($TheCommand == 'search') { $ThePlanet = $CurrentPlanet; } } } } else { $bContinue = false; } } $TechRowTPL = gettemplate('buildings_research_row'); $TechScrTPL = gettemplate('buildings_research_script'); foreach ($lang['tech'] as $Tech => $TechName) { if ($Tech > 105 && $Tech <= 199) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) { $RowParse = $lang; $RowParse['dpath'] = $dpath; $RowParse['tech_id'] = $Tech; $building_level = $CurrentUser[$resource[$Tech]]; $RowParse['tech_level'] = $building_level == 0 ? "" : "( " . $lang['level'] . " " . $building_level . " )"; $RowParse['tech_name'] = $TechName; $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech]; $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech); $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech); $RowParse['search_time'] = ShowBuildTime($SearchTime); $RowParse['tech_restp'] = $lang['Rest_ress'] . " " . GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true); $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech); // Arbre de decision de ce que l'on met dans la derniere case de la ligne if (!$InResearch) { $LevelToDo = 1 + $CurrentUser[$resource[$Tech]]; if ($CanBeDone) { if (!CheckLabSettingsInQueue($CurrentPlanet)) { // Le laboratoire est cours de construction ou d'evolution // Et dans la config du systeme, on ne permet pas la recherche pendant // que le labo est en construction ou evolution ! if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>"; } } else { $TechnoLink = "<a href=\"buildings.php?mode=research&cmd=search&tech=" . $Tech . "\">"; if ($LevelToDo == 1) { $TechnoLink .= "<font color=#00FF00>" . $lang['Rechercher'] . "</font>"; } else { $TechnoLink .= "<font color=#00FF00>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>"; } $TechnoLink .= "</a>"; } } else { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>"; } } } else { // Y a une construction en cours if ($ThePlanet["b_tech_id"] == $Tech) { // C'est le technologie en cours de recherche $bloc = $lang; if ($ThePlanet['id'] != $CurrentPlanet['id']) { // Ca se passe sur une autre planete $bloc['tech_time'] = $ThePlanet["b_tech"] - time(); $bloc['tech_name'] = $lang['on'] . "<br>" . $ThePlanet["name"]; $bloc['tech_home'] = $ThePlanet["id"]; $bloc['tech_id'] = $ThePlanet["b_tech_id"]; } else { // Ca se passe sur la planete actuelle $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time(); $bloc['tech_name'] = ""; $bloc['tech_home'] = $CurrentPlanet["id"]; $bloc['tech_id'] = $CurrentPlanet["b_tech_id"]; } $TechnoLink = parsetemplate($TechScrTPL, $bloc); } else { // Technologie pas en cours recherche $TechnoLink = "<center>-</center>"; } } $RowParse['tech_link'] = $TechnoLink; $TechnoList .= parsetemplate($TechRowTPL, $RowParse); } } } $PageParse = $lang; $PageParse['noresearch'] = $NoResearchMessage; $PageParse['technolist'] = $TechnoList; $Page .= parsetemplate(gettemplate('buildings_research'), $PageParse); display($Page, $lang['Research']); }
public function ShowBuildingsPage(&$CurrentPlanet, $CurrentUser) { global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root; include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx; CheckPlanetUsedFields($CurrentPlanet); $parse = $lang; $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 35, 44); $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43); if (isset($_GET['cmd'])) { $bDoItNow = false; $TheCommand = $_GET['cmd']; $Element = $_GET['building']; $ListID = $_GET['listid']; if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) { unset($Element); } if (isset($Element)) { if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) { if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) { $bDoItNow = true; } } else { header("location:game.php?page=buildings"); } } elseif (isset($ListID)) { $bDoItNow = true; } if ($bDoItNow == true) { switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser); break; case 'remove': $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID); break; case 'insert': $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true); break; case 'destroy': $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false); break; } } } SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser); $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser); $this->BuildingSavePlanetRecord($CurrentPlanet); if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) { $CanBuildElement = true; } else { $CanBuildElement = false; } $BuildingPage = ""; $zaehler = 1; $siguiente = 1; foreach ($lang['tech'] as $BuildID => $ElementName) { if (in_array($BuildID, $Allowed[$CurrentPlanet['planet_type']])) { $parse = $lang; $parse['dpath'] = $dpath; $parse['name'] = $lang['info'][$BuildID]['name']; $parse['image'] = $BuildID; $parse['description'] = $lang['info'][$BuildID]['description']; $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true); $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2; $parse['destroyurl'] = "game.php?page=buildings&cmd=destroy&building=" . $BuildID; $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]]; $parse['nfo_metal'] = $lang['Metal']; $parse['nfo_crysta'] = $lang['Crystal']; $parse['nfo_deuter'] = $lang['Deuterium']; $parse['metal'] = pretty_number($NeededRessources['metal']); $parse['crystal'] = pretty_number($NeededRessources['crystal']); $parse['deuterium'] = pretty_number($NeededRessources['deuterium']); $parse['destroytime'] = pretty_time($DestroyTime); $infodiv .= parsetemplate(gettemplate('buildings/buildings_info_row'), $parse); } } foreach ($lang['tech'] as $Element => $ElementName) { if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) { $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet); if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) { $RoomIsOk = true; } else { $RoomIsOk = false; } if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false); $parse = array(); $parse = $lang; $parse['dpath'] = $dpath; if ($siguiente == 1) { $parse['abrirtr'] = "<tr>"; } $parse['i'] = $Element; $BuildingLevel = $CurrentPlanet[$resource[$Element]]; $parse['nivel'] = $BuildingLevel == 0 ? " (" . $lang['bd_lvl'] . " 0)" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")"; $BuildLevelFactor = $CurrentPlanet[$resource[$Element] . "_porcent"]; $BuildTemp = $CurrentPlanet['temp_max']; $CurrentBuildtLvl = $BuildingLevel; $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1; $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05); $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05); if ($Element != 12) { $ActualNeed = floor($Prod[4]); } else { $ActualNeed = floor($Prod[3]); } $BuildLevel++; $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05); $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05); if ($Element != 12) { $EnergyNeed = pretty_number(abs(floor($Prod[4] - $ActualNeed))); } else { $EnergyNeed = pretty_number(abs(floor($Prod[3] - $ActualNeed))); } if ($Element >= 1 && $Element <= 3) { $parse['build_need_diff'] = "Next Level:<br>Verbraucht <font color=#FF0000>" . $EnergyNeed . "</font> " . $lang['Energy'] . " mehr"; $BuildLevel = 0; } elseif ($Element == 4 || $Element == 12) { $parse['build_need_diff'] = "Next Level:<br>Produziert <font color=#00FF00>" . $EnergyNeed . "</font> mehr " . $lang['Energy']; $BuildLevel = 0; } elseif ($Element == 43 && $BuildingLevel != 0) { $parse['build_need_diff'] = "<a href=\"javascript:f('game.php?page=infos&gid=43','');\">Springen</a>"; $BuildLevel = 0; } if ($BuildingLevel != 0) { $parse['cancel'] = "<a href=\"javascript:infodiv('" . $Element . "-cancel');javascript:animatedcollapse.toggle('" . $Element . "-cancel')\">Abreißen</a>"; } $parse['n'] = $ElementName; $parse['descriptions'] = $lang['res']['descriptions'][$Element]; $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $parse['time'] = ShowBuildTime($ElementBuildTime); $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element, true, true); $parse['click'] = ''; $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1; if ($RoomIsOk && $CanBuildElement) { if ($Queue['lenght'] == 0) { if ($NextBuildLevel == 1) { if ($HaveRessources == true) { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>"; } } else { if ($HaveRessources == true) { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>"; } } } else { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>"; } } elseif ($RoomIsOk && !$CanBuildElement) { if ($NextBuildLevel == 1) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>"; } } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>"; } if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>"; } if ($Element == 21 && $CurrentPlanet["b_hangar"] != 0) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>"; } if ($siguiente == 3) { $parse['cerrartr'] = "</tr>"; $siguiente = 1; } else { $siguiente++; } $BuildingPage .= parsetemplate(gettemplate('buildings/buildings_builds_row'), $parse); } } } if ($Queue['lenght'] > 0) { include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx; $parse['BuildListScript'] = InsertBuildListScript("buildings"); $parse['BuildList'] = $Queue['buildlist']; } else { $parse['BuildListScript'] = ""; $parse['BuildList'] = ""; } $parse['BuildingsList'] = $BuildingPage; $parse['infodiv'] = $infodiv; display(parsetemplate(gettemplate('buildings/buildings_builds'), $parse)); }
function CheckPlanetBuildingQueue(&$CurrentPlanet, &$CurrentUser) { global $lang, $resource; // Table des batiments donnant droit de l'experience minier $XPBuildings = array(1, 2, 3); $RetValue = false; if ($CurrentPlanet['b_building_id'] != 0) { $CurrentQueue = $CurrentPlanet['b_building_id']; if ($CurrentQueue != 0) { $QueueArray = explode(";", $CurrentQueue); $ActualCount = count($QueueArray); } $BuildArray = explode(",", $QueueArray[0]); $BuildEndTime = floor($BuildArray[3]); $BuildMode = $BuildArray[4]; $Element = $BuildArray[0]; array_shift($QueueArray); if ($BuildMode == 'destroy') { $ForDestroy = true; } else { $ForDestroy = false; } if ($BuildEndTime <= time()) { // Mise a jours des points $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy); $Units = $Needed['metal'] + $Needed['crystal'] + $Needed['deuterium']; if ($ForDestroy == false) { // Mise a jours de l'XP Minier if (in_array($Element, $XPBuildings)) { $AjoutXP = $Units / 1000; $CurrentUser['xpminier'] += $AjoutXP; } } else { // Mise a jours de l'XP Minier if (in_array($Element, $XPBuildings)) { $AjoutXP = $Units * 3 / 1000; $CurrentUser['xpminier'] -= $AjoutXP; } } $current = intval($CurrentPlanet['field_current']); $max = intval($CurrentPlanet['field_max']); // Pour une lune if ($CurrentPlanet['planet_type'] == 3) { if ($Element == 41) { // Base Lunaire $current += 1; $max += FIELDS_BY_MOONBASIS_LEVEL; $CurrentPlanet[$resource[$Element]]++; } elseif ($Element != 0) { if ($ForDestroy == false) { $current += 1; $CurrentPlanet[$resource[$Element]]++; } else { $current -= 1; $CurrentPlanet[$resource[$Element]]--; } } } elseif ($CurrentPlanet['planet_type'] == 1) { if ($ForDestroy == false) { $current += 1; $CurrentPlanet[$resource[$Element]]++; } else { $current -= 1; $CurrentPlanet[$resource[$Element]]--; } } if (count($QueueArray) == 0) { $NewQueue = 0; } else { $NewQueue = implode(";", $QueueArray); } $CurrentPlanet['b_building'] = 0; $CurrentPlanet['b_building_id'] = $NewQueue; $CurrentPlanet['field_current'] = $current; $CurrentPlanet['field_max'] = $max; $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`" . $resource[$Element] . "` = '" . $CurrentPlanet[$resource[$Element]] . "', "; // Mise a 0 de l'heure de fin de construction ... // Ca va activer la mise en place du batiment suivant de la queue $QryUpdatePlanet .= "`b_building` = '" . $CurrentPlanet['b_building'] . "' , "; $QryUpdatePlanet .= "`b_building_id` = '" . $CurrentPlanet['b_building_id'] . "' , "; $QryUpdatePlanet .= "`field_current` = '" . $CurrentPlanet['field_current'] . "', "; $QryUpdatePlanet .= "`field_max` = '" . $CurrentPlanet['field_max'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $QryUpdateUser = "******"; $QryUpdateUser .= "`xpminier` = '" . $CurrentUser['xpminier'] . "' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; doquery($QryUpdateUser, 'users'); $RetValue = true; } else { $RetValue = false; } } else { $CurrentPlanet['b_building'] = 0; $CurrentPlanet['b_building_id'] = 0; $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_building` = '" . $CurrentPlanet['b_building'] . "' , "; $QryUpdatePlanet .= "`b_building_id` = '" . $CurrentPlanet['b_building_id'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $RetValue = false; } return $RetValue; }
private function AddBuildingToQueue($Element, $AddMode = true) { global $PLANET, $USER, $resource; $CurrentQueue = $USER['b_tech_queue']; if (!empty($CurrentQueue)) { $QueueArray = explode(";", $CurrentQueue); $ActualCount = count($QueueArray); } else { $QueueArray = array(); $ActualCount = 0; } if (MAX_RESEACH_QUEUE_SIZE <= $ActualCount) { return false; } $BuildLevel = $USER[$resource[$Element]] + 1; if ($ActualCount == 0) { if (!IsElementBuyable($USER, $PLANET, $Element)) { return; } $Resses = GetBuildingPrice($USER, $PLANET, $Element); $BuildTime = GetBuildingTime($USER, $PLANET, $Element); $PLANET['metal'] -= $Resses['metal']; $PLANET['crystal'] -= $Resses['crystal']; $PLANET['deuterium'] -= $Resses['deuterium']; $USER['darkmatter'] -= $Resses['darkmatter']; $BuildEndTime = TIMESTAMP + $BuildTime; $USER['b_tech_queue'] = $Element . "," . $BuildLevel . "," . $BuildTime . "," . $BuildEndTime . "," . $PLANET['id']; $USER['b_tech'] = $BuildEndTime; $USER['b_tech_id'] = $Element; $USER['b_tech_planet'] = $PLANET['id']; } else { $InArray = 0; foreach ($QueueArray as $QueueSub) { $QueueSubArray = explode(",", $QueueSub); if ($QueueSubArray[0] == $Element) { $InArray++; } } $USER[$resource[$Element]] += $InArray; $BuildTime = GetBuildingTime($USER, $PLANET, $Element); $USER[$resource[$Element]] -= $InArray; $LastQueue = explode(",", $QueueArray[$ActualCount - 1]); $BuildEndTime = $LastQueue[3] + $BuildTime; $BuildLevel += $InArray; $USER['b_tech_queue'] = $CurrentQueue . ";" . $Element . "," . $BuildLevel . "," . $BuildTime . "," . $BuildEndTime . "," . $PLANET['id']; } }