Advertisement
Guest User

Untitled

a guest
Jun 14th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.18 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 1.1.5.0
  8. * @ Author : DeZender
  9. * @ Release on : 09.06.2012
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. require( '.' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'boot.php' );
  15. require_once( MODEL_PATH . 'v2v.php' );
  16. require_once( MODEL_PATH . 'build.php' );
  17. class GPage extends VillagePage {
  18. var $pageState = null;
  19. var $targetVillage = array( 'x' => NULL, 'y' => NULL );
  20. var $troops = null;
  21. var $disableFirstTwoAttack = FALSE;
  22. var $attackWithCatapult = FALSE;
  23. var $transferType = 2;
  24. var $errorTable = array( );
  25. var $newVillageResources = array( 1 => 750, 2 => 750, 3 => 750, 4 => 750 );
  26. var $rallyPointLevel = 0;
  27. var $totalCatapultTroopsCount = 0;
  28. var $catapultCanAttackLastIndex = 0;
  29. var $availableCatapultTargetsString = '';
  30. var $catapultCanAttack = array( 0 => 0, 1 => 10, 2 => 11, 3 => 9, 4 => 6, 5 => 2, 6 => 4, 7 => 8, 8 => 7, 9 => 3, 10 => 5, 11 => 1, 12 => 22, 13 => 13, 14 => 19, 15 => 12, 16 => 35, 17 => 18, 18 => 29, 19 => 30, 20 => 37, 21 => 41, 22 => 15, 23 => 17, 24 => 26, 25 => 16, 26 => 25, 27 => 20, 28 => 14, 29 => 24, 30 => 28, 31 => 40, 32 => 21 );
  31. var $onlyOneSpyAction = FALSE;
  32. var $backTroopsProperty = array( );
  33.  
  34. function GPage() {
  35. parent::villagepage( );
  36. $this->viewFile = 'v2v.phtml';
  37. $this->contentCssClass = 'a2b';
  38. }
  39.  
  40. function onLoadBuildings($building) {
  41. if (( $building['item_id'] == 16 && $this->rallyPointLevel < $building['level'] )) {
  42. $this->rallyPointLevel = $building['level'];
  43. }
  44.  
  45. }
  46.  
  47. function load() {
  48. parent::load( );
  49.  
  50. if ($this->rallyPointLevel <= 0) {
  51. $this->redirect( 'build.php?id=39' );
  52. return null;
  53. }
  54.  
  55.  
  56. if (( ( isset( $_GET['d1'] ) || isset( $_GET['d2'] ) ) || isset( $_GET['d3'] ) )) {
  57. $this->pageState = 3;
  58. $this->handleTroopBack( );
  59. return null;
  60. }
  61.  
  62. $m = new WarModel( );
  63. $this->pageState = 1;
  64. $map_size = $this->setupMetadata['map_size'];
  65. $half_map_size = floor( $map_size / 2 );
  66. $this->hasHero = $this->data['hero_in_village_id'] == $this->data['selected_village_id'];
  67. $t_arr = explode( '|', $this->data['troops_num'] );
  68. foreach ($t_arr as $t_str) {
  69. $t2_arr = explode( ':', $t_str );
  70.  
  71. if ($t2_arr[0] == 0 - 1) {
  72. $t2_arr = explode( ',', $t2_arr[1] );
  73. foreach ($t2_arr as $t2_str) {
  74. $t = explode( ' ', $t2_str );
  75.  
  76. if ($t[0] == 99) {
  77. continue;
  78. }
  79.  
  80. $this->troops[] = array( 'troopId' => $t[0], 'number' => $t[1] );
  81. }
  82.  
  83. continue;
  84. }
  85. }
  86.  
  87. $attackOptions1 = '';
  88. $sendTroops = FALSE;
  89. $playerData = NULL;
  90. $villageRow = NULL;
  91.  
  92. if (!$this->isPost( )) {
  93. if (( isset( $_GET['id'] ) && is_numeric( $_GET['id'] ) )) {
  94. $vid = intval( $_GET['id'] );
  95.  
  96. if ($vid < 1) {
  97. $vid = 1;
  98. }
  99.  
  100. $villageRow = $m->getVillageDataById( $vid );
  101. }
  102. } else {
  103. if (isset( $_POST['id'] )) {
  104. $sendTroops = ( !$this->isGameTransientStopped( ) && !$this->isGameOver( ) );
  105. $vid = intval( $_POST['id'] );
  106. $villageRow = $m->getVillageDataById( $vid );
  107. } else {
  108. if (( isset( $_POST['dname'] ) && trim( $_POST['dname'] ) != '' )) {
  109. $villageRow = $m->getVillageDataByName( trim( $_POST['dname'] ) );
  110. } else {
  111. if (( ( ( isset( $_POST['x'] ) && isset( $_POST['y'] ) ) && trim( $_POST['x'] ) != '' ) && trim( $_POST['y'] ) != '' )) {
  112. $vid = $this->__getVillageId( $map_size, $this->__getCoordInRange( $map_size, intval( $_POST['x'] ) ), $this->__getCoordInRange( $map_size, intval( $_POST['y'] ) ) );
  113. $villageRow = $m->getVillageDataById( $vid );
  114. }
  115. }
  116. }
  117. }
  118.  
  119.  
  120. if ($villageRow == NULL) {
  121. if ($this->isPost( )) {
  122. $this->errorTable = v2v_p_entervillagedata;
  123. }
  124.  
  125. return null;
  126. }
  127.  
  128. $this->disableFirstTwoAttack = ( intval( $villageRow['player_id'] ) == 0 && $villageRow['is_oasis'] );
  129. $this->targetVillage['x'] = floor( ( $villageRow['id'] - 1 ) / $map_size );
  130. $this->targetVillage['y'] = $villageRow['id'] - ( $this->targetVillage['x'] * $map_size + 1 );
  131.  
  132. if ($half_map_size < $this->targetVillage['x']) {
  133. $this->targetVillage -= 'x' = $map_size;
  134. }
  135.  
  136.  
  137. if ($half_map_size < $this->targetVillage['y']) {
  138. $this->targetVillage -= 'y' = $map_size;
  139. }
  140.  
  141.  
  142. if ($villageRow['id'] == $this->data['selected_village_id']) {
  143. return null;
  144. }
  145.  
  146.  
  147. if (( 0 < intval( $villageRow['player_id'] ) && $m->getPlayType( $villageRow['player_id'] ) == PLAYERTYPE_ADMIN )) {
  148. return null;
  149. }
  150.  
  151. $spyOnly = FALSE;
  152.  
  153. if (( !$villageRow['is_oasis'] && intval( $villageRow['player_id'] ) == 0 )) {
  154. $this->transferType = 1;
  155. $humanTroopId = 0;
  156. $renderTroops = array( );
  157. foreach ($this->troops as $troop) {
  158. $renderTroops[$troop['troopId']] = 0;
  159.  
  160. if (( ( ( ( $troop['troopId'] == 10 || $troop['troopId'] == 20 ) || $troop['troopId'] == 30 ) || $troop['troopId'] == 109 ) || $troop['troopId'] == 60 )) {
  161. $humanTroopId = $troop['troopId'];
  162. $renderTroops[$humanTroopId] = $troop['number'];
  163. continue;
  164. }
  165. }
  166.  
  167. $canBuildNewVillage = ( isset( $renderTroops[$humanTroopId] ) && 3 <= $renderTroops[$humanTroopId] );
  168.  
  169. if ($canBuildNewVillage) {
  170. $count = (trim( $this->data['child_villages_id'] ) == '' ? 0 : sizeof( explode( ',', $this->data['child_villages_id'] ) ));
  171.  
  172. if (2 < $count) {
  173. $this->errorTable = v2v_p_cannotbuildnewvill;
  174. return null;
  175. }
  176.  
  177.  
  178. if (!$this->_canBuildNewVillage( )) {
  179. $this->errorTable = v2v_p_cannotbuildnewvill1;
  180. return null;
  181. }
  182.  
  183.  
  184. if (!$this->isResourcesAvailable( $this->newVillageResources )) {
  185. $this->errorTable = sprintf( v2v_p_cannotbuildnewvill2, $this->newVillageResources['1'] );
  186. return null;
  187. }
  188.  
  189.  
  190. if ($m->hasNewVillageTask( $this->player->playerId )) {
  191. $this->errorTable = v2v_p_cannotbuildnewvill3;
  192. return null;
  193. }
  194. } else {
  195. $this->errorTable = v2v_p_cannotbuildnewvill4;
  196. return null;
  197. }
  198.  
  199. $this->pageState = 2;
  200. } else {
  201. if ($this->isPost( )) {
  202. if (( !$villageRow['is_oasis'] && intval( $villageRow['player_id'] ) == 0 )) {
  203. $this->errorTable = v2v_p_novillagehere;
  204. return null;
  205. }
  206.  
  207.  
  208. if (( ( !isset( $_POST['c'] ) || intval( $_POST['c'] ) < 1 ) || 4 < intval( $_POST['c'] ) )) {
  209. return null;
  210. }
  211.  
  212. $this->transferType = ($this->disableFirstTwoAttack ? 4 : intval( $_POST['c'] ));
  213.  
  214. if (0 < intval( $villageRow['player_id'] )) {
  215. $playerData = $m->getPlayerDataById( intval( $villageRow['player_id'] ) );
  216.  
  217. if ($playerData['is_blocked']) {
  218. $this->errorTable = v2v_p_playerwas_blocked;
  219. return null;
  220. }
  221.  
  222.  
  223. if (0 < $playerData['protection_remain_sec']) {
  224. $this->errorTable = v2v_p_playerwas_inprotectedperiod;
  225. return null;
  226. }
  227. }
  228.  
  229. $totalTroopsCount = 0;
  230. $totalSpyTroopsCount = 0;
  231. $this->totalCatapultTroopsCount = 0;
  232. $hasTroopsSelected = FALSE;
  233. $renderTroops = array( );
  234.  
  235. if (isset( $_POST['t'] )) {
  236. foreach ($this->troops as $troop) {
  237. $num = 0;
  238.  
  239. if (( isset( $_POST['t'][$troop['troopId']] ) && 0 < intval( $_POST['t'][$troop['troopId']] ) )) {
  240. $num = ($troop['number'] < $_POST['t'][$troop['troopId']] ? $troop['number'] : intval( $_POST['t'][$troop['troopId']] ));
  241. }
  242.  
  243. $renderTroops[$troop['troopId']] = $num;
  244. $totalTroopsCount += $num;
  245.  
  246. if (0 < $num) {
  247. $hasTroopsSelected = TRUE;
  248. }
  249.  
  250.  
  251. if (( ( ( ( $troop['troopId'] == 4 || $troop['troopId'] == 14 ) || $troop['troopId'] == 23 ) || $troop['troopId'] == 103 ) || $troop['troopId'] == 54 )) {
  252. $totalSpyTroopsCount += $num;
  253. continue;
  254. }
  255.  
  256.  
  257. if (( ( ( ( $troop['troopId'] == 8 || $troop['troopId'] == 18 ) || $troop['troopId'] == 28 ) || $troop['troopId'] == 107 ) || $troop['troopId'] == 58 )) {
  258. += 'totalCatapultTroopsCount';
  259. = $num;
  260. continue;
  261. }
  262. }
  263. }
  264. ..................................
  265. .....................
  266. ...........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement