PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/includes/pages/class.ShowFleet1Page.php

https://github.com/jstar88/LibreTitan
PHP | 265 lines | 186 code | 41 blank | 38 comment | 25 complexity | f2e73c4aeff8bec16aa760c781bc9da1 MD5 | raw file
  1. <?php
  2. /**
  3. * @project XG Proyect
  4. * @version 2.10.x build 0000
  5. * @copyright Copyright (C) 2008 - 2012
  6. */
  7. if(!defined('INSIDE')){ die(header ( 'location:../../' ));}
  8. class ShowFleet1Page
  9. {
  10. function __construct ( $CurrentUser , $CurrentPlanet )
  11. {
  12. global $resource, $pricelist, $reslist, $lang;
  13. #####################################################################################################
  14. // SOME DEFAULT VALUES
  15. #####################################################################################################
  16. // QUERYS
  17. $getCurrentAcs = doquery ( "SELECT * FROM {{table}} WHERE teilnehmer = '".$CurrentUser['id']."';" , "aks" );
  18. // ARRAYS
  19. $speed_values = array(10 => 100,9 => 90,8 => 80,7 => 70,6 => 60,5 => 50,4 => 40,3 => 30,2 => 20,1 => 10);
  20. $planet_type = array ( 'fl_planet' , 'fl_debris' , 'fl_moon' );
  21. // LOAD TEMPLATES REQUIRED
  22. $inputs_template = gettemplate ( 'fleet/fleet1_inputs' );
  23. $options_template = gettemplate ( 'fleet/fleet_options' );
  24. $shortcut_row_template = gettemplate ( 'fleet/fleet1_shortcuts_row' );
  25. $shortcut_noshortcuts = gettemplate ( 'fleet/fleet1_shortcuts_noshortcuts_row' );
  26. $shortcut_acs_row = gettemplate ( 'fleet/fleet1_shortcut_acs_row' );
  27. // LANGUAGE
  28. $parse = $lang;
  29. // COORDS
  30. $g = ( ( $_POST['galaxy'] == '' ) ? $CurrentPlanet['galaxy'] : $_POST['galaxy'] );
  31. $s = ( ( $_POST['system'] == '' ) ? $CurrentPlanet['system'] : $_POST['system'] );
  32. $p = ( ( $_POST['planet'] == '' ) ? $CurrentPlanet['planet'] : $_POST['planet'] );
  33. $t = ( ( $_POST['planet_type'] == '' ) ? $CurrentPlanet['planet_type'] : $_POST['planet_type'] );
  34. // OTHER VALUES
  35. $value = 0;
  36. $FleetHiddenBlock = '';
  37. #####################################################################################################
  38. // END DEFAULT VALUES
  39. #####################################################################################################
  40. #####################################################################################################
  41. // LOAD SHIPS INPUTS
  42. #####################################################################################################
  43. $fleet['fleetlist'] = '';
  44. $fleet['amount'] = 0;
  45. foreach ( $reslist['fleet'] as $n => $i )
  46. {
  47. if ( $i >= 201 && $i <= 215 && isset($_POST["ship$i"]) && $_POST["ship$i"] > "0" )
  48. {
  49. if ( ( $_POST["ship$i"] > $CurrentPlanet[$resource[$i]]) OR (!ctype_digit( $_POST["ship$i"] )))
  50. {
  51. header ( 'location:game.php?page=fleet' );
  52. }
  53. else
  54. {
  55. $fleet['fleetarray'][$i] = $_POST["ship$i"];
  56. $fleet['fleetlist'] .= $i . "," . $_POST["ship$i"] . ";";
  57. $fleet['amount'] += $_POST["ship$i"];
  58. $fleet['i'] = $i;
  59. $fleet['consumption'] = Fleets::ship_consumption ( $i, $CurrentUser );
  60. $fleet['speed'] = Fleets::fleet_max_speed ( "", $i, $CurrentUser );
  61. $fleet['capacity'] = $pricelist[$i]['capacity'];
  62. $fleet['ship'] = $_POST["ship$i"];
  63. $speedalls[$i] = Fleets::fleet_max_speed ( "", $i, $CurrentUser);
  64. $FleetHiddenBlock .= parsetemplate ( $inputs_template , $fleet );
  65. }
  66. }
  67. }
  68. if ( !isset($fleet['fleetlist']) )
  69. {
  70. header ( 'location:game.php?page=fleet' );
  71. }
  72. else
  73. {
  74. $speedallsmin = min ( $speedalls );
  75. }
  76. #####################################################################################################
  77. // LOAD PLANET TYPES OPTIONS
  78. #####################################################################################################
  79. $parse['options_planettype'] = '';
  80. foreach ( $planet_type as $type )
  81. {
  82. $value++;
  83. $options['value'] = $value;
  84. if ( $value == $t )
  85. {
  86. $options['selected'] = 'SELECTED';
  87. }
  88. else
  89. {
  90. $options['selected'] = '';
  91. }
  92. $options['title'] = $lang[$type];
  93. $parse['options_planettype'] .= parsetemplate ( $options_template , $options );
  94. }
  95. #####################################################################################################
  96. // LOAD SPEED OPTIONS
  97. #####################################################################################################
  98. $parse['options'] = '';
  99. foreach ( $speed_values as $value => $porcentage )
  100. {
  101. $speed_porcentage['value'] = $value;
  102. $speed_porcentage['selected'] = '';
  103. $speed_porcentage['title'] = $porcentage;
  104. $parse['options'] .= parsetemplate ( $options_template , $speed_porcentage );
  105. }
  106. #####################################################################################################
  107. // PARSE THE REST OF THE OPTIONS
  108. #####################################################################################################
  109. $parse['fleetblock'] = $FleetHiddenBlock;
  110. $parse['speedallsmin'] = $speedallsmin;
  111. $parse['fleetarray'] = str_rot13(base64_encode(serialize($fleet['fleetarray'])));
  112. $parse['galaxy'] = $CurrentPlanet['galaxy'];
  113. $parse['system'] = $CurrentPlanet['system'];
  114. $parse['planet'] = $CurrentPlanet['planet'];
  115. $parse['galaxy_post'] = intval($_POST['galaxy']);
  116. $parse['system_post'] = intval($_POST['system']);
  117. $parse['planet_post'] = intval($_POST['planet']);
  118. $parse['speedfactor'] = GetGameSpeedFactor();
  119. $parse['planet_type'] = $CurrentPlanet['planet_type'];
  120. $parse['metal'] = floor($CurrentPlanet['metal']);
  121. $parse['crystal'] = floor($CurrentPlanet['crystal']);
  122. $parse['deuterium'] = floor($CurrentPlanet['deuterium']);
  123. $parse['g'] = $g;
  124. $parse['s'] = $s;
  125. $parse['p'] = $p;
  126. #####################################################################################################
  127. // LOAD FLEET SHORTCUTS
  128. #####################################################################################################
  129. if ( $CurrentUser['fleet_shortcut'] )
  130. {
  131. $scarray = explode ( ";" , $CurrentUser['fleet_shortcut'] );
  132. foreach ( $scarray as $a => $b )
  133. {
  134. if ( $b != "" )
  135. {
  136. $c = explode ( ',' , $b );
  137. $shortcut['description'] = $c[0] ." ". $c[1] .":". $c[2] .":". $c[3] . " ";
  138. switch ( $c[4] )
  139. {
  140. case 1:
  141. $shortcut['description'] .= $lang['fl_planet_shortcut'];
  142. break;
  143. case 2:
  144. $shortcut['description'] .= $lang['fl_debris_shortcut'];
  145. break;
  146. case 3:
  147. $shortcut['description'] .= $lang['fl_moon_shortcut'];
  148. break;
  149. default:
  150. $shortcut['description'] .= '';
  151. break;
  152. }
  153. $shortcut['selected'] = '';
  154. $shortcut['value'] = $c['1'].';'.$c['2'].';'.$c['3'].';'.$c['4'];
  155. $shortcut['title'] = $shortcut['description'];
  156. $shortcut['shortcut_options'] .= parsetemplate( $options_template , $shortcut );
  157. }
  158. }
  159. $parse['shortcut'] = parsetemplate ( $shortcut_row_template , $shortcut );
  160. }
  161. else
  162. {
  163. $parse['fl_shorcut_message'] = $lang['fl_no_shortcuts'];
  164. $parse['shortcut'] = parsetemplate ( $shortcut_noshortcuts , $parse );
  165. }
  166. #####################################################################################################
  167. // LOAD COLONY SHORTCUTS
  168. #####################################################################################################
  169. $colonies = SortUserPlanets ( $CurrentUser );
  170. if ( mysql_num_rows ( $colonies ) > 1 )
  171. {
  172. while ( $row = mysql_fetch_array ( $colonies ) )
  173. {
  174. if ( $CurrentPlanet['galaxy'] <> $row['galaxy'] or
  175. $CurrentPlanet['system'] <> $row['system'] or
  176. $CurrentPlanet['planet'] <> $row['planet'] or
  177. $CurrentPlanet['planet_type'] <> $row['planet_type'] )
  178. {
  179. if ( $row['planet_type'] == 3 )
  180. {
  181. $row['name'] .= " " . $lang['fl_moon_shortcut'];
  182. }
  183. $colony['selected'] = '';
  184. $colony['value'] = $row['galaxy'].';'.$row['system'].';'.$row['planet'].';'.$row['planet_type'];
  185. $colony['title'] = $row['name'] ." ". $row['galaxy'] .":". $row['system'] .":". $row['planet'];
  186. $colony['shortcut_options'] .= parsetemplate( $options_template , $colony );
  187. }
  188. $parse['colonylist'] = parsetemplate ( $shortcut_row_template , $colony );
  189. }
  190. }
  191. else
  192. {
  193. $parse['fl_shorcut_message'] = $lang['fl_no_colony'];
  194. $parse['colonylist'] = parsetemplate ( $shortcut_noshortcuts , $parse );
  195. }
  196. #####################################################################################################
  197. // LOAD SAC SHORTCUTS
  198. #####################################################################################################
  199. $acs_fleets = '';
  200. while ( $row = mysql_fetch_array ( $getCurrentAcs ) )
  201. {
  202. $members = explode ( "," , $row['eingeladen'] );
  203. foreach ( $members as $a => $b )
  204. {
  205. if ( $b == $CurrentUser['id'] )
  206. {
  207. $acs['galaxy'] = $row['galaxy'];
  208. $acs['system'] = $row['system'];
  209. $acs['planet'] = $row['planet'];
  210. $acs['planet_type'] = $row['planet_type'];
  211. $acs['id'] = $row['id'];
  212. $acs['name'] = $row['name'];
  213. $acs_fleets .= parsetemplate ( $shortcut_acs_row , $acs );
  214. }
  215. }
  216. }
  217. $parse['asc'] = $acs_fleets;
  218. $parse['maxepedition'] = $_POST['maxepedition'];
  219. $parse['curepedition'] = $_POST['curepedition'];
  220. $parse['target_mission'] = $_POST['target_mission'];
  221. display ( parsetemplate ( gettemplate ( 'fleet/fleet1_table' ) , $parse ) );
  222. }
  223. }
  224. ?>