Guest User

Untitled

a guest
Jun 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.91 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. foreach($lang['tech'] as $Element => $ElementName) {
  78. if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
  79. $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
  80. if ($CurrentPlanet["field_current"] < ($CurrentMaxFields - $Queue['lenght'])) {
  81. $RoomIsOk = true;
  82. } else {
  83. $RoomIsOk = false;
  84. }
  85.  
  86. if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
  87. $HaveRessources = IsElementBuyable ($CurrentUser, $CurrentPlanet, $Element, true, false);
  88. $parse = array();
  89.  
  90. if ($siguiente==1) $parse['abrirtr'] = "<tr>";
  91.  
  92. $parse['dpath'] = $dpath;
  93. $parse['i'] = $Element;
  94. $BuildingLevel = $CurrentPlanet[$resource[$Element]];
  95. $parse['nivel'] = ($BuildingLevel == 0) ? "" : " (". $lang['level'] ." ". $BuildingLevel .")";
  96. $parse['n'] = $ElementName;
  97. $parse['descriptions'] = $lang['res']['descriptions'][$Element];
  98. $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
  99. $parse['time'] = ShowBuildTime($ElementBuildTime);
  100. $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
  101. $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
  102. $parse['click'] = '';
  103. $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
  104.  
  105. if ($Element == 31) {
  106. // Spécial Laboratoire
  107. if ($CurrentUser["b_tech_planet"] != 0 && // Si pas 0 y a une recherche en cours
  108. $game_config['BuildLabWhileRun'] != 1) { // Variable qui contient le parametre
  109. // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
  110. $parse['click'] = "<font color=#FF0000>". $lang['in_working'] ."</font>";
  111. }
  112. }
  113. if ($parse['click'] != '') {
  114. // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !!
  115. } elseif ($RoomIsOk && $CanBuildElement) {
  116. if ($Queue['lenght'] == 0) {
  117. if ($NextBuildLevel == 1) {
  118. if ( $HaveRessources == true ) {
  119. $parse['click'] = "<a href=\"?cmd=insert&building=". $Element ."\"><font color=#00FF00>". $lang['BuildFirstLevel'] ."</font></a>";
  120. } else {
  121. $parse['click'] = "<font color=#FF0000>". $lang['BuildFirstLevel'] ."</font>";
  122. }
  123. } else {
  124. if ( $HaveRessources == true ) {
  125. $parse['click'] = "<a href=\"?cmd=insert&building=". $Element ."\"><font color=#00FF00>". $lang['BuildNextLevel'] ." ". $NextBuildLevel ."</font></a>";
  126. } else {
  127. $parse['click'] = "<font color=#FF0000>". $lang['BuildNextLevel'] ." ". $NextBuildLevel ."</font>";
  128. }
  129. }
  130. } else {
  131. $parse['click'] = "<a href=\"?cmd=insert&building=". $Element ."\"><font color=#00FF00>". $lang['InBuildQueue'] ."</font></a>";
  132. }
  133. } elseif ($RoomIsOk && !$CanBuildElement) {
  134. if ($NextBuildLevel == 1) {
  135. $parse['click'] = "<font color=#FF0000>". $lang['BuildFirstLevel'] ."</font>";
  136. } else {
  137. $parse['click'] = "<font color=#FF0000>". $lang['BuildNextLevel'] ." ". $NextBuildLevel ."</font>";
  138. }
  139. } else {
  140. $parse['click'] = "<font color=#FF0000>". $lang['NoMoreSpace'] ."</font>";
  141. }
  142.  
  143. $BuildingPage .= parsetemplate($SubTemplate, $parse);
  144. }
  145. }
  146. }
  147. else
  148. $parse['click'] = "<font color=#FF0000>No hay espacio en el planeta</font>";
  149.  
  150. if ($siguiente==3)
  151. {
  152. $parse['cerrartr'] = "</tr>";
  153. $siguiente=1;
  154. }
  155. else $siguiente++;
  156.  
  157. $BuildingPage .= parsetemplate($SubTemplate, $parse);
  158. $parse = $lang;
  159.  
  160. // Faut il afficher la liste de construction ??
  161. if ($Queue['lenght'] > 0) {
  162. $parse['BuildListScript'] = InsertBuildListScript ( "buildings" );
  163. $parse['BuildList'] = $Queue['buildlist'];
  164. } else {
  165. $parse['BuildListScript'] = "";
  166. $parse['BuildList'] = "";
  167. }
  168.  
  169. $parse['planet_field_current'] = $CurrentPlanet["field_current"];
  170. $parse['planet_field_max'] = $CurrentPlanet['field_max'] + ($CurrentPlanet[$resource[33]] * 5);
  171. $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
  172.  
  173. $parse['BuildingsList'] = $BuildingPage;
  174.  
  175. $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
  176.  
  177. display($page, $lang['Builds']);
  178. }
  179.  
  180. // -----------------------------------------------------------------------------------------------------------
  181. // History version
  182. // 1.0 Mise en module initiale (creation)
  183. // 1.1 FIX interception cheat +1
  184. // 1.2 FIX interception cheat destruction a -1
  185.  
  186. ?>
Add Comment
Please, Sign In to add comment