Guest User

Untitled

a guest
Jun 20th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.01 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * BatimentBuildingPage.php
  5. *
  6. * @version 1.1
  7. * @copyright 2008 by Chlorel for XNova
  8. */
  9.  
  10. function BatimentBuildingPage (&$CurrentPlanet, $CurrentUser) {
  11. global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
  12.  
  13. CheckPlanetUsedFields ( $CurrentPlanet );
  14.  
  15. // Tables des batiments possibles par type de planete
  16. $Allowed['1'] = array( 1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
  17. $Allowed['3'] = array( 12, 14, 15, 21, 22, 23, 24, 34, 41, 42, 43);
  18.  
  19. // Boucle d'interpretation des eventuelles commandes
  20. if (isset($_GET['cmd'])) {
  21. // On passe une commande
  22. $bDoItNow = false;
  23. $TheCommand = $_GET['cmd'];
  24. $Element = $_GET['building'];
  25. $ListID = $_GET['listid'];
  26. if ( isset ( $Element )) {
  27. if ( !strchr ( $Element, " ") ) {
  28. if (in_array( trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
  29. $bDoItNow = true;
  30. }
  31. }
  32. } elseif ( isset ( $ListID )) {
  33. $bDoItNow = true;
  34. }
  35. if ($bDoItNow == true) {
  36. switch($TheCommand){
  37. case 'cancel':
  38. // Interrompre le premier batiment de la queue
  39. CancelBuildingFromQueue ( $CurrentPlanet, $CurrentUser );
  40. break;
  41. case 'remove':
  42. // Supprimer un element de la queue (mais pas le premier)
  43. // $RemID -> element de la liste a supprimer
  44. RemoveBuildingFromQueue ( $CurrentPlanet, $CurrentUser, $ListID );
  45. break;
  46. case 'insert':
  47. // Insere un element dans la queue
  48. AddBuildingToQueue ( $CurrentPlanet, $CurrentUser, $Element, true );
  49. break;
  50. case 'destroy':
  51. // Detruit un batiment deja construit sur la planete !
  52. AddBuildingToQueue ( $CurrentPlanet, $CurrentUser, $Element, false );
  53. break;
  54. default:
  55. break;
  56. } // switch
  57. }
  58. }
  59.  
  60. SetNextQueueElementOnTop ( $CurrentPlanet, $CurrentUser );
  61.  
  62. $Queue = ShowBuildingQueue ( $CurrentPlanet, $CurrentUser );
  63.  
  64. // On enregistre ce que l'on a modifié dans planet !
  65. BuildingSavePlanetRecord ( $CurrentPlanet );
  66. // On enregistre ce que l'on a eventuellement modifié dans users
  67. BuildingSaveUserRecord ( $CurrentUser );
  68.  
  69. if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
  70. $CanBuildElement = true;
  71. } else {
  72. $CanBuildElement = false;
  73. }
  74.  
  75. $SubTemplate = gettemplate('buildings_builds_row');
  76. $BuildingPage = "";
  77. $zaehler = 1;
  78. $siguiente = 1;
  79. foreach($lang['tech'] as $Element => $ElementName) {
  80. if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
  81. $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
  82. if ($CurrentPlanet["field_current"] < ($CurrentMaxFields - $Queue['lenght'])) {
  83. $RoomIsOk = true;
  84. } else {
  85. $RoomIsOk = false;
  86. }
  87.  
  88. if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
  89. $HaveRessources = IsElementBuyable ($CurrentUser, $CurrentPlanet, $Element, true, false);
  90. $parse = array();
  91.  
  92. if ($siguiente==1) $parse['abrirtr'] = "<tr>";
  93.  
  94. $parse['dpath'] = $dpath;
  95. $parse['i'] = $Element;
  96. $BuildingLevel = $CurrentPlanet[$resource[$Element]];
  97. $parse['nivel'] = ($BuildingLevel == 0) ? "" : " (". $lang['level'] ." ". $BuildingLevel .")";
  98. $parse['n'] = $ElementName;
  99. $parse['descriptions'] = $lang['res']['descriptions'][$Element];
  100. $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
  101. $parse['time'] = ShowBuildTime($ElementBuildTime);
  102. $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
  103. $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
  104. $parse['click'] = '';
  105. $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
  106.  
  107. if ($Element == 31) {
  108. // Spécial Laboratoire
  109. if ($CurrentUser["b_tech_planet"] != 0 && // Si pas 0 y a une recherche en cours
  110. $game_config['BuildLabWhileRun'] != 1) { // Variable qui contient le parametre
  111. // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
  112. $parse['click'] = "<font color=#FF0000>". $lang['in_working'] ."</font>";
  113. }
  114. }
  115. if ($parse['click'] != '') {
  116. // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !!
  117. } elseif ($RoomIsOk && $CanBuildElement) {
  118. if ($Queue['lenght'] == 0) {
  119. if ($NextBuildLevel == 1) {
  120. if ( $HaveRessources == true ) {
  121. $parse['click'] = "<a href=\"?cmd=insert&building=". $Element ."\"><font color=#00FF00>". $lang['BuildFirstLevel'] ."</font></a>";
  122. } else {
  123. $parse['click'] = "<font color=#FF0000>". $lang['BuildFirstLevel'] ."</font>";
  124. }
  125. } else {
  126. if ( $HaveRessources == true ) {
  127. $parse['click'] = "<a href=\"?cmd=insert&building=". $Element ."\"><font color=#00FF00>". $lang['BuildNextLevel'] ." ". $NextBuildLevel ."</font></a>";
  128. } else {
  129. $parse['click'] = "<font color=#FF0000>". $lang['BuildNextLevel'] ." ". $NextBuildLevel ."</font>";
  130. }
  131. }
  132. } else {
  133. $parse['click'] = "<a href=\"?cmd=insert&building=". $Element ."\"><font color=#00FF00>". $lang['InBuildQueue'] ."</font></a>";
  134. }
  135. } elseif ($RoomIsOk && !$CanBuildElement) {
  136. if ($NextBuildLevel == 1) {
  137. $parse['click'] = "<font color=#FF0000>". $lang['BuildFirstLevel'] ."</font>";
  138. } else {
  139. $parse['click'] = "<font color=#FF0000>". $lang['BuildNextLevel'] ." ". $NextBuildLevel ."</font>";
  140. }
  141. } else {
  142. $parse['click'] = "<font color=#FF0000>". $lang['NoMoreSpace'] ."</font>";
  143. }
  144.  
  145. $BuildingPage .= parsetemplate($SubTemplate, $parse);
  146. }
  147. }
  148. }
  149.  
  150. $parse = $lang;
  151.  
  152. // Faut il afficher la liste de construction ??
  153. if ($Queue['lenght'] > 0) {
  154. $parse['BuildListScript'] = InsertBuildListScript ( "buildings" );
  155. $parse['BuildList'] = $Queue['buildlist'];
  156. } else {
  157. $parse['BuildListScript'] = "";
  158. $parse['BuildList'] = "";
  159. }
  160.  
  161. $parse['planet_field_current'] = $CurrentPlanet["field_current"];
  162. $parse['planet_field_max'] = $CurrentPlanet['field_max'] + ($CurrentPlanet[$resource[33]] * 5);
  163. $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
  164.  
  165. $parse['BuildingsList'] = $BuildingPage;
  166.  
  167. $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
  168.  
  169. display($page, $lang['Builds']);
  170. else
  171. $parse['click'] = "<font color=#FF0000>No hay espacio en el planeta</font>";
  172.  
  173. if ($siguiente==3)
  174. {
  175. $parse['cerrartr'] = "</tr>";
  176. $siguiente=1;
  177. }
  178. else $siguiente++;
  179.  
  180. $BuildingPage .= parsetemplate($SubTemplate, $parse);
  181. }
  182.  
  183. // -----------------------------------------------------------------------------------------------------------
  184. // History version
  185. // 1.0 Mise en module initiale (creation)
  186. // 1.1 FIX interception cheat +1
  187. // 1.2 FIX interception cheat destruction a -1
  188.  
  189. ?>
Add Comment
Please, Sign In to add comment