PageRenderTime 71ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 1ms

/build_decoded.php

https://github.com/minea94/DboorZ
PHP | 1682 lines | 1618 code | 42 blank | 22 comment | 510 complexity | e534ff882a0cea1154609995335272e0 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*********************/
  3. /* */
  4. /* Dezend for PHP5 */
  5. /* NWS */
  6. /* Nulled.WS */
  7. /* */
  8. /*********************/
  9. require( ".".DIRECTORY_SEPARATOR."app".DIRECTORY_SEPARATOR."boot.php" );
  10. require_once( MODEL_PATH."build.php" );
  11. class GPage extends VillagePage
  12. {
  13. public $productionPane = TRUE;
  14. public $buildingView = "";
  15. public $buildingIndex = -1;
  16. public $buildProperties = NULL;
  17. public $newBuilds = NULL;
  18. public $troopsUpgrade;
  19. public $troopsUpgradeType;
  20. public $buildingTribeFactor;
  21. public $troops = array( );
  22. public $selectedTabIndex = 0;
  23. public $villageOases;
  24. public $childVillages;
  25. public $hasHero = FALSE;
  26. public $totalCpRate;
  27. public $totalCpValue;
  28. public $neededCpValue;
  29. public $childVillagesCount;
  30. public $showBuildingForm;
  31. public $embassyProperty;
  32. public $merchantProperty;
  33. public $rallyPointProperty;
  34. public $crannyProperty = array( 'buildingCount' => 0, 'totalSize' => 0 );
  35. public $warriorMessage = "";
  36. public $dataList;
  37. public $pageSize = 40;
  38. public $pageCount;
  39. public $pageIndex;
  40. public function GPage( )
  41. {
  42. parent::villagepage( );
  43. $this->viewFile = "build.phtml";
  44. $this->contentCssClass = "build";
  45. }
  46. public function onLoadBuildings( $building )
  47. {
  48. $GameMetadata = $GLOBALS['GameMetadata'];
  49. if ( $this->buildingIndex == 0 - 1 && isset( $_GET['bid'] ) && is_numeric( $_GET['bid'] ) && $_GET['bid'] == $building['item_id'] )
  50. {
  51. $this->buildingIndex = $building['index'];
  52. }
  53. if ( $building['item_id'] == 23 && 0 < $building['level'] )
  54. {
  55. ++$this->crannyProperty['buildingCount'];
  56. $this->crannyProperty['totalSize'] += $this->crannyProperty['buildingCount'];
  57. }
  58. }
  59. public function load( )
  60. {
  61. parent::load( );
  62. if ( $this->buildingIndex == 0 - 1 && isset( $_GET['id'] ) && is_numeric( $_GET['id'] ) && isset( $this->buildings[$_GET['id']] ) )
  63. {
  64. $this->buildingIndex = intval( $_GET['id'] );
  65. }
  66. $this->buildProperties = $this->getBuildingProperties( $this->buildingIndex );
  67. if ( $this->buildProperties == NULL )
  68. {
  69. $this->redirect( "village1.php" );
  70. }
  71. else if ( $this->buildProperties['emptyPlace'] )
  72. {
  73. $this->villagesLinkPostfix .= "&id=".$this->buildingIndex;
  74. $this->newBuilds = array(
  75. "available" => array( ),
  76. "soon" => array( )
  77. );
  78. foreach ( $this->gameMetadata['items'] as $item_id => $build )
  79. {
  80. if ( $item_id <= 4 || !isset( $build['for_tribe_id'][$this->tribeId] ) )
  81. {
  82. continue;
  83. }
  84. $canBuild = $this->canCreateNewBuild( $item_id );
  85. if ( $canBuild != 0 - 1 )
  86. {
  87. if ( $canBuild )
  88. {
  89. if ( !isset( $this->newBuilds['available'][$build['levels'][0]['time_consume']] ) )
  90. {
  91. $this->newBuilds['available'][$build['levels'][0]['time_consume']] = array( );
  92. }
  93. $this->newBuilds['available'][$build['levels'][0]['time_consume']][$item_id] = $build;
  94. }
  95. else
  96. {
  97. $dependencyCount = 0;
  98. foreach ( $build['pre_requests'] as $reqId => $reqValue )
  99. {
  100. if ( $reqValue != NULL )
  101. {
  102. $build['pre_requests_dependencyCount'][$reqId] = $reqValue - $this->_getMaxBuildingLevel( $reqId );
  103. $dependencyCount += $build['pre_requests_dependencyCount'][$reqId];
  104. }
  105. }
  106. if ( !isset( $this->newBuilds['soon'][$dependencyCount] ) )
  107. {
  108. $this->newBuilds['soon'][$dependencyCount] = array( );
  109. }
  110. $this->newBuilds['soon'][$dependencyCount][$item_id] = $build;
  111. }
  112. }
  113. }
  114. ksort( $this->newBuilds['available'], SORT_NUMERIC );
  115. ksort( $this->newBuilds['soon'], SORT_NUMERIC );
  116. }
  117. else
  118. {
  119. $bitemId = $this->buildProperties['building']['item_id'];
  120. $this->villagesLinkPostfix .= "&id=".$this->buildingIndex;
  121. if ( 4 < $bitemId )
  122. {
  123. $this->villagesLinkPostfix .= "&bid=".$bitemId;
  124. }
  125. $this->buildingTribeFactor = isset( $this->gameMetadata['items'][$bitemId]['for_tribe_id'][$this->data['tribe_id']] ) ? $this->gameMetadata['items'][$bitemId]['for_tribe_id'][$this->data['tribe_id']] : 1;
  126. if ( $this->buildings[$this->buildingIndex]['level'] == 0 )
  127. {
  128. return;
  129. }
  130. switch ( $bitemId )
  131. {
  132. case 12 :
  133. case 13 :
  134. $this->productionPane = FALSE;
  135. $this->buildingView = "Blacksmith_Armoury";
  136. $this->handleBlacksmithArmoury( );
  137. break;
  138. case 15 :
  139. if ( 10 <= $this->buildings[$this->buildingIndex]['level'] )
  140. {
  141. $this->buildingView = "MainBuilding";
  142. $this->handleMainBuilding( );
  143. }
  144. break;
  145. case 16 :
  146. $this->productionPane = FALSE;
  147. $this->buildingView = "RallyPoint";
  148. $this->handleRallyPoint( );
  149. break;
  150. case 17 :
  151. $this->productionPane = FALSE;
  152. $this->buildingView = "Marketplace";
  153. $this->handleMarketplace( );
  154. break;
  155. case 18 :
  156. $this->productionPane = FALSE;
  157. $this->buildingView = "Embassy";
  158. $this->handleEmbassy( );
  159. break;
  160. case 19 :
  161. case 20 :
  162. case 21 :
  163. case 29 :
  164. case 30 :
  165. case 36 :
  166. $this->_getOnlyMyTroops( );
  167. $this->productionPane = $bitemId == 36;
  168. $this->buildingView = "TroopBuilding";
  169. $this->handleTroopBuilding( );
  170. break;
  171. case 22 :
  172. $this->productionPane = FALSE;
  173. $this->buildingView = "Academy";
  174. $this->handleAcademy( );
  175. break;
  176. case 23 :
  177. $this->productionPane = TRUE;
  178. $this->buildingView = "Cranny";
  179. break;
  180. case 24 :
  181. $this->productionPane = FALSE;
  182. $this->buildingView = "TownHall";
  183. $this->handleTownHall( );
  184. break;
  185. case 25 :
  186. case 26 :
  187. $this->productionPane = FALSE;
  188. $this->buildingView = "Residence_Palace";
  189. $this->handleResidencePalace( );
  190. break;
  191. case 37 :
  192. $this->productionPane = FALSE;
  193. $this->buildingView = "HerosMansion";
  194. $this->handleHerosMansion( );
  195. break;
  196. case 40 :
  197. $this->productionPane = FALSE;
  198. break;
  199. case 42 :
  200. $this->_getOnlyMyTroops( );
  201. $this->productionPane = TRUE;
  202. $this->buildingView = "Warrior";
  203. $this->handleWarrior( );
  204. }
  205. }
  206. }
  207. public function handleBlacksmithArmoury( )
  208. {
  209. $this->troopsUpgradeType = $this->buildings[$this->buildingIndex]['item_id'] == 12 ? QS_TROOP_UPGRADE_ATTACK : QS_TROOP_UPGRADE_DEFENSE;
  210. $this->troopsUpgrade = array( );
  211. $_arr = explode( ",", $this->data['troops_training'] );
  212. $_c = 0;
  213. foreach ( $_arr as $troopStr )
  214. {
  215. ++$_c;
  216. $attack_level = explode( " ", $troopStr );
  217. $defense_level = explode( " ", $troopStr );
  218. $researches_done = explode( " ", $troopStr );
  219. $troopId = explode( " ", $troopStr );
  220. list( $troopId, $researches_done, $defense_level, $attack_level ) = $troopId;
  221. $tlevel = $this->troopsUpgradeType == QS_TROOP_UPGRADE_ATTACK ? $attack_level : $defense_level;
  222. if ( $troopId != 99 && $_c <= 8 && $tlevel < 20 && $researches_done == 1 )
  223. {
  224. $this->troopsUpgrade[$troopId] = $tlevel;
  225. }
  226. }
  227. if ( isset( $_GET['a'], $_GET['k'] ) && $_GET['k'] == $this->data['update_key'] && !isset( $this->queueModel->tasksInQueue[$this->troopsUpgradeType] ) && isset( $this->troopsUpgrade[intval( $_GET['a'] )] ) && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  228. {
  229. $troopId = intval( $_GET['a'] );
  230. $level = $this->troopsUpgrade[$troopId];
  231. $buildingMetadata = $this->gameMetadata['items'][$this->buildProperties['building']['item_id']]['troop_upgrades'][$troopId][$level];
  232. if ( !$this->isResourcesAvailable( $buildingMetadata['resources'] ) )
  233. {
  234. }
  235. else
  236. {
  237. $calcConsume = intval( $buildingMetadata['time_consume'] / $this->gameSpeed * ( 10 / ( $this->buildProperties['building']['level'] + 9 ) ) );
  238. $newTask = new QueueTask( $this->troopsUpgradeType, $this->player->playerId, $calcConsume );
  239. $newTask->villageId = $this->data['selected_village_id'];
  240. $newTask->procParams = $troopId." ".( $level + 1 );
  241. $newTask->tag = $buildingMetadata['resources'];
  242. $this->queueModel->addTask( $newTask );
  243. }
  244. }
  245. }
  246. public function handleMainBuilding( )
  247. {
  248. if ( $this->isPost( ) && isset( $_POST['drbid'] ) && 19 <= intval( $_POST['drbid'] ) && intval( $_POST['drbid'] ) <= sizeof( $this->buildings ) && isset( $this->buildings[$_POST['drbid']] ) && 0 < $this->buildings[$_POST['drbid']]['level'] && !isset( $this->queueModel->tasksInQueue[QS_BUILD_DROP] ) && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  249. {
  250. $item_id = $this->buildings[$_POST['drbid']]['item_id'];
  251. $calcConsume = intval( $this->gameMetadata['items'][$item_id]['levels'][$this->buildings[$_POST['drbid']]['level'] - 1]['time_consume'] / $this->gameSpeed * ( $this->data['time_consume_percent'] / 400 ) );
  252. $newTask = new QueueTask( QS_BUILD_DROP, $this->player->playerId, $calcConsume );
  253. $newTask->villageId = $this->data['selected_village_id'];
  254. $newTask->buildingId = $item_id;
  255. $newTask->procParams = $this->buildings[$_POST['drbid']]['index'];
  256. $this->queueModel->addTask( $newTask );
  257. }
  258. else if ( isset( $_GET['qid'] ) && is_numeric( $_GET['qid'] ) && isset( $_GET['k'] ) && $_GET['k'] == $this->data['update_key'] && isset( $_GET['d'] ) && isset( $this->queueModel->tasksInQueue[QS_BUILD_DROP] ) && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  259. {
  260. $this->queueModel->cancelTask( $this->player->playerId, intval( $_GET['qid'] ) );
  261. }
  262. }
  263. public function handleRallyPoint( )
  264. {
  265. if ( isset( $_GET['d'] ) )
  266. {
  267. $this->queueModel->cancelTask( $this->player->playerId, intval( $_GET['d'] ) );
  268. }
  269. $this->rallyPointProperty = array(
  270. "troops_in_village" => array(
  271. "troopsTable" => $this->_getTroopsList( "troops_num" ),
  272. "troopsIntrapTable" => $this->_getTroopsList( "troops_intrap_num" )
  273. ),
  274. "troops_out_village" => array(
  275. "troopsTable" => $this->_getTroopsList( "troops_out_num" ),
  276. "troopsIntrapTable" => $this->_getTroopsList( "troops_out_intrap_num" )
  277. ),
  278. "troops_in_oases" => array( ),
  279. "war_to_village" => $this->queueModel->tasksInQueue['war_troops']['to_village'],
  280. "war_from_village" => $this->queueModel->tasksInQueue['war_troops']['from_village'],
  281. "war_to_oasis" => $this->queueModel->tasksInQueue['war_troops']['to_oasis']
  282. );
  283. $village_oases_id = trim( $this->data['village_oases_id'] );
  284. if ( $village_oases_id != "" )
  285. {
  286. $m = new BuildModel( );
  287. $result = $m->getOasesDataById( $village_oases_id );
  288. while ( $result->next( ) )
  289. {
  290. $this->rallyPointProperty['troops_in_oases'][$result->row['id']] = array(
  291. "oasisRow" => $result->row,
  292. "troopsTable" => $this->_getOasisTroopsList( $result->row['troops_num'] ),
  293. "war_to" => isset( $this->rallyPointProperty['war_to_oasis'][$result->row['id']] ) ? $this->rallyPointProperty['war_to_oasis'][$result->row['id']] : NULL
  294. );
  295. }
  296. $m->dispose( );
  297. }
  298. }
  299. public function _canCancelWarTask( $taskType, $taskId )
  300. {
  301. if ( !QueueTask::iscancelabletask( $taskType ) )
  302. {
  303. return FALSE;
  304. }
  305. $timeout = QueueTask::getmaxcanceltimeout( $taskType );
  306. if ( 0 - 1 < $timeout )
  307. {
  308. $_task = NULL;
  309. foreach ( $this->queueModel->tasksInQueue[$taskType] as $t )
  310. {
  311. if ( !( $t['id'] == $taskId ) )
  312. {
  313. continue;
  314. }
  315. $_task = $t;
  316. break;
  317. break;
  318. }
  319. if ( $_task == NULL )
  320. {
  321. return FALSE;
  322. }
  323. $elapsedTime = $t['elapsedTime'];
  324. if ( $timeout < $elapsedTime )
  325. {
  326. return FALSE;
  327. }
  328. }
  329. return TRUE;
  330. }
  331. public function _getOasisTroopsList( $troops_num )
  332. {
  333. $GameMetadata = $GLOBALS['GameMetadata'];
  334. $m = new BuildModel( );
  335. $returnTroops = array( );
  336. if ( trim( $troops_num ) != "" )
  337. {
  338. $t_arr = explode( "|", $troops_num );
  339. foreach ( $t_arr as $t_str )
  340. {
  341. $t2_arr = explode( ":", $t_str );
  342. $vid = $t2_arr[0];
  343. $villageData = $m->getVillageData2ById( $vid );
  344. $returnTroops[$vid] = array( "villageData" => $villageData, "cropConsumption" => 0, "hasHero" => FALSE, "troops" => array( ) );
  345. $t2_arr = explode( ",", $t2_arr[1] );
  346. foreach ( $t2_arr as $t2_str )
  347. {
  348. $tnum = explode( " ", $t2_str );
  349. $tid = explode( " ", $t2_str );
  350. list( $tid, $tnum ) = $tid;
  351. if ( $tid == 99 )
  352. {
  353. continue;
  354. }
  355. if ( $tnum == 0 - 1 )
  356. {
  357. $tnum = 1;
  358. $returnTroops[$vid]['hasHero'] = TRUE;
  359. }
  360. else
  361. {
  362. $returnTroops[$vid]['troops'][$tid] = $tnum;
  363. }
  364. $returnTroops[$vid]['cropConsumption'] += $GameMetadata['troops'][$tid]['crop_consumption'] * $tnum;
  365. }
  366. }
  367. }
  368. $m->dispose( );
  369. return $returnTroops;
  370. }
  371. public function _getTroopsList( $key )
  372. {
  373. $GameMetadata = $GLOBALS['GameMetadata'];
  374. $m = new BuildModel( );
  375. $returnTroops = array( );
  376. if ( trim( $this->data[$key] ) != "" )
  377. {
  378. $t_arr = explode( "|", $this->data[$key] );
  379. foreach ( $t_arr as $t_str )
  380. {
  381. $t2_arr = explode( ":", $t_str );
  382. $vid = intval( $t2_arr[0] );
  383. $villageData = NULL;
  384. if ( $vid == 0 - 1 )
  385. {
  386. $vid = $this->data['selected_village_id'];
  387. $villageData = array( "id" => $vid, "village_name" => $this->data['village_name'], "player_id" => $this->player->playerId, "player_name" => buildings_p_thisvillage );
  388. }
  389. else
  390. {
  391. $villageData = $m->getVillageData2ById( $vid );
  392. }
  393. $returnTroops[$vid] = array( "villageData" => $villageData, "cropConsumption" => 0, "hasHero" => FALSE, "troops" => array( ) );
  394. if ( $vid == $this->data['selected_village_id'] )
  395. {
  396. $returnTroops[$vid]['hasHero'] = intval( $this->data['hero_in_village_id'] ) == intval( $this->data['selected_village_id'] );
  397. if ( $returnTroops[$vid]['hasHero'] )
  398. {
  399. $returnTroops[$vid]['cropConsumption'] += $GameMetadata['troops'][$this->data['hero_troop_id']]['crop_consumption'];
  400. }
  401. }
  402. $t2_arr = explode( ",", $t2_arr[1] );
  403. foreach ( $t2_arr as $t2_str )
  404. {
  405. $tnum = explode( " ", $t2_str );
  406. $tid = explode( " ", $t2_str );
  407. list( $tid, $tnum ) = $tid;
  408. if ( $tid == 99 )
  409. {
  410. continue;
  411. }
  412. if ( $tnum == 0 - 1 )
  413. {
  414. $tnum = 1;
  415. $returnTroops[$vid]['hasHero'] = TRUE;
  416. }
  417. else
  418. {
  419. $returnTroops[$vid]['troops'][$tid] = $tnum;
  420. }
  421. $returnTroops[$vid]['cropConsumption'] += $GameMetadata['troops'][$tid]['crop_consumption'] * $tnum;
  422. }
  423. }
  424. }
  425. $m->dispose( );
  426. return $returnTroops;
  427. }
  428. public function handleMarketplace( )
  429. {
  430. $this->selectedTabIndex = isset( $_GET['t'] ) && is_numeric( $_GET['t'] ) && 1 <= intval( $_GET['t'] ) && intval( $_GET['t'] ) <= 3 ? intval( $_GET['t'] ) : 0;
  431. $itemId = $this->buildings[$this->buildingIndex]['item_id'];
  432. $itemLevel = $this->buildings[$this->buildingIndex]['level'];
  433. $tribeMetadata = $this->gameMetadata['tribes'][$this->data['tribe_id']];
  434. $tradeOfficeLevel = $this->_getMaxBuildingLevel( 28 );
  435. $capacityFactor = $tradeOfficeLevel == 0 ? 1 : $this->gameMetadata['items'][28]['levels'][$tradeOfficeLevel - 1]['value'] / 100;
  436. $capacityFactor *= $this->gameMetadata['game_speed'];
  437. $total_merchants_num = $this->gameMetadata['items'][$itemId]['levels'][$itemLevel - 1]['value'];
  438. $exist_num = $total_merchants_num - $this->queueModel->tasksInQueue['out_merchants_num'] - $this->data['offer_merchants_count'];
  439. if ( $exist_num < 0 )
  440. {
  441. $exist_num = 0;
  442. }
  443. $this->merchantProperty = array( "speed" => $tribeMetadata['merchants_velocity'] * $this->gameMetadata['game_speed'], "capacity" => floor( $tribeMetadata['merchants_capacity'] * $capacityFactor ), "total_num" => $total_merchants_num, "exits_num" => $exist_num, "confirm_snd" => FALSE, "same_village" => FALSE, "vRow" => NULL );
  444. if ( $this->selectedTabIndex == 0 )
  445. {
  446. $m = new BuildModel( );
  447. if ( $this->isPost( ) || isset( $_GET['vid2'] ) )
  448. {
  449. $resources = array( "1" => isset( $_POST['r1'] ) ? intval( $_POST['r1'] ) : 0, "2" => isset( $_POST['r2'] ) ? intval( $_POST['r2'] ) : 0, "3" => isset( $_POST['r3'] ) ? intval( $_POST['r3'] ) : 0, "4" => isset( $_POST['r4'] ) ? intval( $_POST['r4'] ) : 0 );
  450. $this->merchantProperty['confirm_snd'] = $this->isPost( ) ? isset( $_POST['act'] ) && $_POST['act'] == 1 : isset( $_GET['vid2'] );
  451. $map_size = $this->setupMetadata['map_size'];
  452. $doSend = FALSE;
  453. if ( $this->merchantProperty['confirm_snd'] )
  454. {
  455. $vRow = NULL;
  456. if ( trim( $_POST['y'] ) != "" )
  457. {
  458. $vid = $this->__getVillageId( $map_size, $this->__getCoordInRange( $map_size, intval( $_POST['x'] ) ), $this->__getCoordInRange( $map_size, intval( $_POST['y'] ) ) );
  459. $vRow = $m->getVillageDataById( $vid );
  460. }
  461. else
  462. {
  463. if ( isset( $_POST['vname'] ) && trim( $_POST['vname'] ) != "" )
  464. {
  465. $vRow = $m->getVillageDataByName( trim( $_POST['vname'] ) );
  466. }
  467. else
  468. {
  469. if ( isset( $_GET['vid2'] ) )
  470. {
  471. $vRow = $m->getVillageDataById( intval( $_GET['vid2'] ) );
  472. if ( $vRow != NULL )
  473. {
  474. $_POST['x'] = $vRow['rel_x'];
  475. $_POST['y'] = $vRow['rel_y'];
  476. }
  477. }
  478. }
  479. }
  480. }
  481. else
  482. {
  483. $doSend = TRUE;
  484. $vRow = $m->getVillageDataById( intval( $_POST['vid2'] ) );
  485. $this->merchantProperty['showError'] = FALSE;
  486. $_POST['r1'] = $_POST['r2'] = $_POST['r3'] = $_POST['r4'] = "";
  487. }
  488. if ( 0 < intval( $vRow['player_id'] ) && $m->getPlayType( intval( $vRow['player_id'] ) ) == PLAYERTYPE_ADMIN )
  489. {
  490. $this->merchantProperty['showError'] = FALSE;
  491. $this->merchantProperty['confirm_snd'] = FALSE;
  492. }
  493. else
  494. {
  495. $this->merchantProperty['vRow'] = $vRow;
  496. $vid = $this->merchantProperty['to_vid'] = $vRow != NULL ? $vRow['id'] : 0;
  497. $rel_x = $vRow['rel_x'];
  498. $rel_y = $vRow['rel_y'];
  499. $this->merchantProperty['same_village'] = $vid == $this->data['selected_village_id'];
  500. $this->merchantProperty['available_res'] = $this->isResourcesAvailable( $resources );
  501. $this->merchantProperty['vRow_merchant_num'] = ceil( ( $resources[1] + $resources[2] + $resources[3] + $resources[4] ) / $this->merchantProperty['capacity'] );
  502. $this->merchantProperty['confirm_snd'] = 0 < $vid && $this->merchantProperty['available_res'] && 0 < $this->merchantProperty['vRow_merchant_num'] && $this->merchantProperty['vRow_merchant_num'] <= $this->merchantProperty['exits_num'] && !$this->merchantProperty['same_village'];
  503. $this->merchantProperty['showError'] = !$this->merchantProperty['confirm_snd'];
  504. $distance = WebHelper::getdistance( $this->data['rel_x'], $this->data['rel_y'], $rel_x, $rel_y, $this->setupMetadata['map_size'] / 2 );
  505. $this->merchantProperty['vRow_time'] = intval( $distance / $this->merchantProperty['speed'] * 3600 );
  506. if ( !$this->merchantProperty['showError'] && $doSend && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  507. {
  508. $this->merchantProperty['confirm_snd'] = FALSE;
  509. $this->merchantProperty -= "exits_num";
  510. $newTask = new QueueTask( QS_MERCHANT_GO, $this->player->playerId, $this->merchantProperty['vRow_time'] );
  511. $newTask->villageId = $this->data['selected_village_id'];
  512. $newTask->toPlayerId = $vRow['player_id'];
  513. $newTask->toVillageId = $vid;
  514. $newTask->procParams = $this->merchantProperty['vRow_merchant_num']."|".( $resources[1]." ".$resources[2]." ".$resources[3]." ".$resources[4] );
  515. $newTask->tag = $resources;
  516. $this->queueModel->addTask( $newTask );
  517. }
  518. }
  519. }
  520. $m->dispose( );
  521. }
  522. else if ( $this->selectedTabIndex == 1 )
  523. {
  524. $m = new BuildModel( );
  525. $showOfferList = TRUE;
  526. if ( isset( $_GET['oid'] ) && 0 < intval( $_GET['oid'] ) )
  527. {
  528. $oRow = $m->getOffer2( intval( $_GET['oid'] ), $this->data['rel_x'], $this->data['rel_y'], $this->setupMetadata['map_size'] / 2 );
  529. if ( $oRow != NULL )
  530. {
  531. $aid = 0;
  532. if ( $oRow['alliance_only'] && 0 < intval( $this->data['alliance_id'] ) )
  533. {
  534. $aid = $m->getPlayerAllianceId( $oRow['player_id'] );
  535. }
  536. $res2 = explode( "|", $oRow['offer'] );
  537. $res1 = explode( "|", $oRow['offer'] );
  538. list( $res1, $res2 ) = $res1;
  539. $resArr1 = explode( " ", $res1 );
  540. $needResources = array( "1" => $resArr1[0], "2" => $resArr1[1], "3" => $resArr1[2], "4" => $resArr1[3] );
  541. $res1_item_id = 0;
  542. $res1_value = 0;
  543. $i = 0;
  544. $_c = sizeof( $resArr1 );
  545. while ( $i < $_c )
  546. {
  547. if ( 0 < $resArr1[$i] )
  548. {
  549. $res1_item_id = $i + 1;
  550. $res1_value = $resArr1[$i];
  551. break;
  552. }
  553. ++$i;
  554. }
  555. $resArr1 = explode( " ", $res2 );
  556. $giveResources = array( "1" => $resArr1[0], "2" => $resArr1[1], "3" => $resArr1[2], "4" => $resArr1[3] );
  557. $res2_item_id = 0;
  558. $res2_value = 0;
  559. $i = 0;
  560. $_c = sizeof( $resArr1 );
  561. while ( $i < $_c )
  562. {
  563. if ( 0 < $resArr1[$i] )
  564. {
  565. $res2_item_id = $i + 1;
  566. $res2_value = $resArr1[$i];
  567. break;
  568. }
  569. ++$i;
  570. }
  571. $distance = $oRow['timeInSeconds'] / 3600 * $oRow['merchants_speed'];
  572. $acceptResult = $this->_canAcceptOffer( $needResources, $giveResources, $oRow['village_id'], $oRow['alliance_only'], $aid, $oRow['max_time'], $distance );
  573. if ( $acceptResult == 5 && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  574. {
  575. $showOfferList = FALSE;
  576. $this->merchantProperty['offerProperty'] = array( "player_id" => $oRow['player_id'], "player_name" => $oRow['player_name'], "res1_item_id" => $res1_item_id, "res1_value" => $res1_value, "res2_item_id" => $res2_item_id, "res2_value" => $res2_value );
  577. $merchantNum = ceil( ( $giveResources[1] + $giveResources[2] + $giveResources[3] + $giveResources[4] ) / $this->merchantProperty['capacity'] );
  578. $newTask = new QueueTask( QS_MERCHANT_GO, $this->player->playerId, $distance / ( $this->gameMetadata['tribes'][$this->data['tribe_id']]['merchants_velocity'] * $this->gameMetadata['game_speed'] ) * 3600 );
  579. $newTask->villageId = $this->data['selected_village_id'];
  580. $newTask->toPlayerId = $oRow['player_id'];
  581. $newTask->toVillageId = $oRow['village_id'];
  582. $newTask->procParams = $merchantNum."|".( $giveResources[1]." ".$giveResources[2]." ".$giveResources[3]." ".$giveResources[4] );
  583. $newTask->tag = $giveResources;
  584. $this->queueModel->addTask( $newTask );
  585. $newTask = new QueueTask( QS_MERCHANT_GO, $oRow['player_id'], $oRow['timeInSeconds'] );
  586. $newTask->villageId = $oRow['village_id'];
  587. $newTask->toPlayerId = $this->player->playerId;
  588. $newTask->toVillageId = $this->data['selected_village_id'];
  589. $newTask->procParams = $oRow['merchants_num']."|".( $needResources[1]." ".$needResources[2]." ".$needResources[3]." ".$needResources[4] );
  590. $newTask->tag = array( "1" => 0, "2" => 0, "3" => 0, "4" => 0 );
  591. $this->queueModel->addTask( $newTask );
  592. $m->removeMerchantOffer( intval( $_GET['oid'] ), $oRow['player_id'], $oRow['village_id'] );
  593. }
  594. }
  595. }
  596. $this->merchantProperty['showOfferList'] = $showOfferList;
  597. if ( $showOfferList )
  598. {
  599. $rowsCount = $m->getAllOffersCount( $this->data['selected_village_id'], $this->data['rel_x'], $this->data['rel_y'], $this->setupMetadata['map_size'] / 2, $this->gameMetadata['tribes'][$this->data['tribe_id']]['merchants_velocity'] * $this->gameMetadata['game_speed'] );
  600. $this->pageCount = 0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1;
  601. $this->pageIndex = isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) && intval( $_GET['p'] ) < $this->pageCount ? intval( $_GET['p'] ) : 0;
  602. $this->merchantProperty['all_offers'] = $m->getAllOffers( $this->data['selected_village_id'], $this->data['rel_x'], $this->data['rel_y'], $this->setupMetadata['map_size'] / 2, $this->gameMetadata['tribes'][$this->data['tribe_id']]['merchants_velocity'] * $this->gameMetadata['game_speed'], $this->pageIndex, $this->pageSize );
  603. }
  604. $m->dispose( );
  605. }
  606. else
  607. {
  608. if ( $this->selectedTabIndex == 2 )
  609. {
  610. $m = new BuildModel( );
  611. $this->merchantProperty['showError'] = FALSE;
  612. $this->merchantProperty['showError2'] = FALSE;
  613. $this->merchantProperty['showError3'] = FALSE;
  614. if ( $this->isPost( ) )
  615. {
  616. if ( isset( $_POST['m1'] ) && 0 < intval( $_POST['m1'] ) && isset( $_POST['m2'] ) && 0 < intval( $_POST['m2'] ) && isset( $_POST['rid1'] ) && 0 < intval( $_POST['rid1'] ) && isset( $_POST['rid2'] ) && 0 < intval( $_POST['rid2'] ) )
  617. {
  618. $resources1 = array( "1" => isset( $_POST['rid1'] ) && intval( $_POST['rid1'] ) == 1 ? intval( $_POST['m1'] ) : 0, "2" => isset( $_POST['rid1'] ) && intval( $_POST['rid1'] ) == 2 ? intval( $_POST['m1'] ) : 0, "3" => isset( $_POST['rid1'] ) && intval( $_POST['rid1'] ) == 3 ? intval( $_POST['m1'] ) : 0, "4" => isset( $_POST['rid1'] ) && intval( $_POST['rid1'] ) == 4 ? intval( $_POST['m1'] ) : 0 );
  619. $resources2 = array( "1" => isset( $_POST['rid2'] ) && intval( $_POST['rid2'] ) == 1 ? intval( $_POST['m2'] ) : 0, "2" => isset( $_POST['rid2'] ) && intval( $_POST['rid2'] ) == 2 ? intval( $_POST['m2'] ) : 0, "3" => isset( $_POST['rid2'] ) && intval( $_POST['rid2'] ) == 3 ? intval( $_POST['m2'] ) : 0, "4" => isset( $_POST['rid2'] ) && intval( $_POST['rid2'] ) == 4 ? intval( $_POST['m2'] ) : 0 );
  620. if ( intval( $_POST['rid1'] ) == intval( $_POST['rid2'] ) || intval( $resources1[1] + $resources1[2] + $resources1[3] + $resources1[4] ) <= 0 || intval( $resources2[1] + $resources2[2] + $resources2[3] + $resources2[4] ) <= 0 )
  621. {
  622. $this->merchantProperty['showError'] = TRUE;
  623. }
  624. else if ( 10 < ceil( ( $resources2[1] + $resources2[2] + $resources2[3] + $resources2[4] ) / ( $resources1[1] + $resources1[2] + $resources1[3] + $resources1[4] ) ) )
  625. {
  626. $this->merchantProperty['showError'] = TRUE;
  627. $this->merchantProperty['showError3'] = TRUE;
  628. }
  629. $this->merchantProperty['available_res'] = $this->isResourcesAvailable( $resources1 );
  630. if ( $this->merchantProperty['available_res'] && !$this->merchantProperty['showError'] )
  631. {
  632. $this->merchantProperty['vRow_merchant_num'] = ceil( ( $resources1[1] + $resources1[2] + $resources1[3] + $resources1[4] ) / $this->merchantProperty['capacity'] );
  633. if ( 0 < $this->merchantProperty['vRow_merchant_num'] && $this->merchantProperty['vRow_merchant_num'] <= $this->merchantProperty['exits_num'] )
  634. {
  635. $this->merchantProperty -= "exits_num";
  636. $this->data += "offer_merchants_count";
  637. $offer = $resources1[1]." ".$resources1[2]." ".$resources1[3]." ".$resources1[4]."|".( $resources2[1]." ".$resources2[2]." ".$resources2[3]." ".$resources2[4] );
  638. $m->addMerchantOffer( $this->player->playerId, $this->data['name'], $this->data['selected_village_id'], $this->data['rel_x'], $this->data['rel_y'], $this->merchantProperty['vRow_merchant_num'], $offer, isset( $_POST['ally'] ), 0 < intval( $_POST['d2'] ) ? intval( $_POST['d2'] ) : 0, $this->gameMetadata['tribes'][$this->data['tribe_id']]['merchants_velocity'] * $this->gameMetadata['game_speed'] );
  639. foreach ( $resources1 as $k => $v )
  640. {
  641. $this->resources[$k] -= "current_value";
  642. }
  643. $this->queueModel->_updateVillage( FALSE, FALSE );
  644. }
  645. else
  646. {
  647. $this->merchantProperty['showError'] = TRUE;
  648. }
  649. }
  650. else
  651. {
  652. $this->merchantProperty['showError'] = TRUE;
  653. }
  654. }
  655. else
  656. {
  657. $this->merchantProperty['showError'] = TRUE;
  658. $this->merchantProperty['showError2'] = TRUE;
  659. }
  660. }
  661. else if ( isset( $_GET['d'] ) && 0 < intval( $_GET['d'] ) )
  662. {
  663. $row = $m->getOffer( intval( $_GET['d'] ), $this->player->playerId, $this->data['selected_village_id'] );
  664. if ( $row != NULL )
  665. {
  666. $this->merchantProperty += "exits_num";
  667. $this->data -= "offer_merchants_count";
  668. $resources2 = explode( "|", $row['offer'] );
  669. $resources1 = explode( "|", $row['offer'] );
  670. list( $resources1, $resources2 ) = $resources1;
  671. $resourcesArray1 = explode( " ", $resources1 );
  672. $res = array( );
  673. $i = 0;
  674. $_c = sizeof( $resourcesArray1 );
  675. while ( $i < $_c )
  676. {
  677. $res[$i + 1] = $resourcesArray1[$i];
  678. ++$i;
  679. }
  680. foreach ( $res as $k => $v )
  681. {
  682. $this->resources[$k] += "current_value";
  683. }
  684. $this->queueModel->_updateVillage( FALSE, FALSE );
  685. $m->removeMerchantOffer( intval( $_GET['d'] ), $this->player->playerId, $this->data['selected_village_id'] );
  686. }
  687. }
  688. $this->merchantProperty['offers'] = $m->getOffers( $this->data['selected_village_id'] );
  689. $m->dispose( );
  690. }
  691. else
  692. {
  693. if ( $this->selectedTabIndex == 3 && $this->isPost( ) && isset( $_POST['m2'] ) && is_array( $_POST['m2'] ) && sizeof( $_POST['m2'] ) == 4 && $this->gameMetadata['plusTable'][6]['cost'] <= $this->data['gold_num'] )
  694. {
  695. $resources = array( "1" => intval( $_POST['m2'][0] ), "2" => intval( $_POST['m2'][1] ), "3" => intval( $_POST['m2'][2] ), "4" => intval( $_POST['m2'][3] ) );
  696. $oldSum = $this->resources[1]['current_value'] + $this->resources[2]['current_value'] + $this->resources[3]['current_value'] + $this->resources[4]['current_value'];
  697. $newSum = $resources[1] + $resources[2] + $resources[3] + $resources[4];
  698. if ( $newSum <= $oldSum )
  699. {
  700. foreach ( $resources as $k => $v )
  701. {
  702. $this->resources[$k]['current_value'] = $v;
  703. }
  704. $this->queueModel->_updateVillage( FALSE, FALSE );
  705. $m = new BuildModel( );
  706. $m->decreaseGoldNum( $this->player->playerId, $this->gameMetadata['plusTable'][6]['cost'] );
  707. $m->dispose( );
  708. }
  709. }
  710. }
  711. }
  712. }
  713. public function handleEmbassy( )
  714. {
  715. if ( 0 < intval( $this->data['alliance_id'] ) )
  716. {
  717. }
  718. else
  719. {
  720. $this->embassyProperty = array( "level" => $this->buildings[$this->buildingIndex]['level'], "invites" => NULL, "error" => 0, "ally1" => "", "ally2" => "" );
  721. $maxPlayers = $this->gameMetadata['items'][18]['levels'][$this->embassyProperty['level'] - 1]['value'];
  722. $this->embassyProperty['ally1'] = $ally1 = trim( $_POST['ally1'] );
  723. $this->embassyProperty['ally2'] = $ally2 = trim( $_POST['ally2'] );
  724. if ( $ally1 == "" || $ally2 == "" )
  725. {
  726. $this->embassyProperty['error'] = $ally1 == "" && $ally2 == "" ? 3 : $ally1 == "" ? 1 : 2;
  727. }
  728. else
  729. {
  730. $m = new BuildModel( );
  731. if ( !$m->allianceExists( $this->embassyProperty['ally1'] ) )
  732. {
  733. $this->data['alliance_name'] = $this->embassyProperty['ally1'];
  734. $this->data['alliance_id'] = $m->createAlliance( $this->player->playerId, $this->embassyProperty['ally1'], $this->embassyProperty['ally2'], $maxPlayers );
  735. $m->dispose( );
  736. }
  737. else
  738. {
  739. $this->embassyProperty['error'] = 4;
  740. $m->dispose( );
  741. }
  742. }
  743. $invites_alliance_ids = trim( $this->data['invites_alliance_ids'] );
  744. $this->embassyProperty['invites'] = array( );
  745. if ( $invites_alliance_ids != "" )
  746. {
  747. $_arr = explode( "\n", $invites_alliance_ids );
  748. foreach ( $_arr as $_s )
  749. {
  750. $allianceName = explode( " ", $_s, 2 );
  751. $allianceId = explode( " ", $_s, 2 );
  752. list ( $allianceId, $allianceName ) = $allianceId;
  753. $this->embassyProperty['invites'][$allianceId] = $allianceName;
  754. }
  755. }
  756. if ( !$this->isPost( ) )
  757. {
  758. if ( isset( $_GET['a'] ) && 0 < intval( $_GET['a'] ) )
  759. {
  760. $allianceId = intval( $_GET['a'] );
  761. if ( isset( $this->embassyProperty['invites'][$allianceId] ) )
  762. {
  763. $m = new BuildModel( );
  764. $acceptResult = $m->acceptAllianceJoining( $this->player->playerId, $allianceId );
  765. if ( $acceptResult == 2 )
  766. {
  767. $this->data['alliance_name'] = $this->embassyProperty['invites'][$allianceId];
  768. $this->data['alliance_id'] = $allianceId;
  769. unset( $Var_4320['invites'][$allianceId] );
  770. $m->removeAllianceInvites( $this->player->playerId, $allianceId );
  771. }
  772. else if ( $acceptResult == 1 )
  773. {
  774. $this->embassyProperty['error'] = 15;
  775. }
  776. $m->dispose( );
  777. }
  778. }
  779. else
  780. {
  781. if ( isset( $_GET['d'] ) && 0 < intval( $_GET['d'] ) )
  782. {
  783. $allianceId = intval( $_GET['d'] );
  784. if ( isset( $this->embassyProperty['invites'][$allianceId] ) )
  785. {
  786. unset( $Var_5112['invites'][$allianceId] );
  787. $m = new BuildModel( );
  788. $m->removeAllianceInvites( $this->player->playerId, $allianceId );
  789. $m->dispose( );
  790. }
  791. }
  792. }
  793. }
  794. }
  795. }
  796. public function handleWarrior( )
  797. {
  798. $itemId = $this->buildings[$this->buildingIndex]['item_id'];
  799. $this->troopsUpgrade = array( );
  800. $_arr = explode( ",", $this->data['troops_training'] );
  801. foreach ( $_arr as $troopStr )
  802. {
  803. $attack_level = explode( " ", $troopStr );
  804. $defense_level = explode( " ", $troopStr );
  805. $researches_done = explode( " ", $troopStr );
  806. $troopId = explode( " ", $troopStr );
  807. list( $troopId, $researches_done, $defense_level, $attack_level ) = $troopId;
  808. if ( $researches_done == 1 && 0 < $this->gameMetadata['troops'][$troopId]['gold_needed'] )
  809. {
  810. $this->troopsUpgrade[$troopId] = $troopId;
  811. }
  812. }
  813. $this->warriorMessage = "";
  814. if ( $this->isPost( ) && isset( $_POST['tf'] ) && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  815. {
  816. $cropConsume = 0;
  817. $totalGoldsNeeded = 0;
  818. foreach ( $_POST['tf'] as $troopId => $num )
  819. {
  820. $num = intval( $num );
  821. if ( $num <= 0 || !isset( $this->troopsUpgrade[$troopId] ) )
  822. {
  823. continue;
  824. }
  825. $totalGoldsNeeded += $this->gameMetadata['troops'][$troopId]['gold_needed'] * $num;
  826. $cropConsume += $this->gameMetadata['troops'][$troopId]['crop_consumption'] * $num;
  827. }
  828. if ( $totalGoldsNeeded <= 0 )
  829. {
  830. }
  831. else
  832. {
  833. $canProcess = $totalGoldsNeeded <= $this->data['gold_num'];
  834. $this->warriorMessage = $canProcess ? 1 : 2;
  835. if ( $canProcess )
  836. {
  837. $troopsString = "";
  838. foreach ( $this->troops as $tid => $num )
  839. {
  840. if ( $tid == 99 )
  841. {
  842. continue;
  843. }
  844. $neededNum = isset( $this->troopsUpgrade[$tid], $_POST['tf'][$tid] ) ? $_POST['tf'][$tid] : 0;
  845. if ( $troopsString != "" )
  846. {
  847. $troopsString .= ",";
  848. }
  849. $troopsString .= $tid." ".$neededNum;
  850. }
  851. $m = new BuildModel( );
  852. $m->decreaseGoldNum( $this->player->playerId, $totalGoldsNeeded );
  853. $m->dispose( );
  854. $this->data -= "gold_num";
  855. $procParams = $troopsString."|0||||||1";
  856. $buildingMetadata = $this->gameMetadata['items'][$this->buildProperties['building']['item_id']];
  857. $bLevel = $this->buildings[$this->buildingIndex]['level'];
  858. $needed_time = $buildingMetadata['levels'][$bLevel - 1]['value'] * 3600;
  859. $newTask = new QueueTask( QS_WAR_REINFORCE, 0, $needed_time );
  860. $newTask->villageId = 0;
  861. $newTask->toPlayerId = $this->player->playerId;
  862. $newTask->toVillageId = $this->data['selected_village_id'];
  863. $newTask->procParams = $procParams;
  864. $newTask->tag = array( "troops" => NULL, "hasHero" => FALSE, "resources" => NULL, "troopsCropConsume" => $cropConsume );
  865. $this->queueModel->addTask( $newTask );
  866. }
  867. }
  868. }
  869. }
  870. public function handleTroopBuilding( )
  871. {
  872. $itemId = $this->buildings[$this->buildingIndex]['item_id'];
  873. $this->troopsUpgradeType = QS_TROOP_TRAINING;
  874. $this->troopsUpgrade = array( );
  875. $_arr = explode( ",", $this->data['troops_training'] );
  876. foreach ( $_arr as $troopStr )
  877. {
  878. $attack_level = explode( " ", $troopStr );
  879. $defense_level = explode( " ", $troopStr );
  880. $researches_done = explode( " ", $troopStr );
  881. $troopId = explode( " ", $troopStr );
  882. list( $troopId, $researches_done, $defense_level, $attack_level ) = $troopId;
  883. if ( $researches_done == 1 && $this->_canTrainInBuilding( $troopId, $itemId ) )
  884. {
  885. $this->troopsUpgrade[$troopId] = $troopId;
  886. }
  887. }
  888. if ( $this->isPost( ) && isset( $_POST['tf'] ) && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  889. {
  890. foreach ( $_POST['tf'] as $troopId => $num )
  891. {
  892. $num = intval( $num );
  893. if ( $num <= 0 || !isset( $this->troopsUpgrade[$troopId] ) || $this->_getMaxTrainNumber( $troopId, $itemId ) < $num )
  894. {
  895. continue;
  896. }
  897. $timeFactor = 1;
  898. if ( $this->gameMetadata['troops'][$troopId]['is_cavalry'] == TRUE )
  899. {
  900. $flvl = $this->_getMaxBuildingLevel( 41 );
  901. if ( 0 < $flvl )
  902. {
  903. $timeFactor -= $this->gameMetadata['items'][41]['levels'][$flvl - 1]['value'] / 100;
  904. }
  905. }
  906. $troopMetadata = $this->gameMetadata['troops'][$troopId];
  907. $calcConsume = intval( $troopMetadata['training_time_consume'] / $this->gameSpeed * ( 10 / ( $this->buildProperties['building']['level'] + 9 ) ) * $timeFactor );
  908. $newTask = new QueueTask( $this->troopsUpgradeType, $this->player->playerId, $calcConsume );
  909. $newTask->threads = $num;
  910. $newTask->villageId = $this->data['selected_village_id'];
  911. $newTask->buildingId = $this->buildProperties['building']['item_id'];
  912. $newTask->procParams = $troopId;
  913. $newTask->tag = array( "1" => $troopMetadata['training_resources'][1] * $this->buildingTribeFactor * $num, "2" => $troopMetadata['training_resources'][2] * $this->buildingTribeFactor * $num, "3" => $troopMetadata['training_resources'][3] * $this->buildingTribeFactor * $num, "4" => $troopMetadata['training_resources'][4] * $this->buildingTribeFactor * $num );
  914. $this->queueModel->addTask( $newTask );
  915. }
  916. }
  917. }
  918. public function handleAcademy( )
  919. {
  920. $this->troopsUpgradeType = QS_TROOP_RESEARCH;
  921. $this->troopsUpgrade = array( "available" => array( ), "soon" => array( ) );
  922. $_arr = explode( ",", $this->data['troops_training'] );
  923. foreach ( $_arr as $troopStr )
  924. {
  925. $attack_level = explode( " ", $troopStr );
  926. $defense_level = explode( " ", $troopStr );
  927. $researches_done = explode( " ", $troopStr );
  928. $troopId = explode( " ", $troopStr );
  929. list( $troopId, $researches_done, $defense_level, $attack_level ) = $troopId;
  930. if ( $researches_done == 0 )
  931. {
  932. $this->troopsUpgrade[$this->_canDoResearches( $troopId ) ? "available" : "soon"][] = $troopId;
  933. }
  934. }
  935. if ( $_GET['k'] == $this->data['update_key'] && !isset( $this->queueModel->tasksInQueue[$this->troopsUpgradeType] ) && $this->_canDoResearches( intval( $_GET['a'] ) ) && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  936. {
  937. $troopId = intval( $_GET['a'] );
  938. $buildingMetadata = $this->gameMetadata['troops'][$troopId];
  939. return;
  940. $calcConsume = intval( $buildingMetadata['research_time_consume'] / $this->gameSpeed );
  941. $newTask = new QueueTask( $this->troopsUpgradeType, $this->player->playerId, $calcConsume );
  942. $newTask->villageId = $this->data['selected_village_id'];
  943. $newTask->procParams = $troopId;
  944. $newTask->tag = $buildingMetadata['research_resources'];
  945. $this->queueModel->addTask( $newTask );
  946. }
  947. }
  948. public function handleTownHall( )
  949. {
  950. $buildingMetadata = $this->gameMetadata['items'][$this->buildProperties['building']['item_id']];
  951. $bLevel = $this->buildings[$this->buildingIndex]['level'];
  952. if ( $_GET['k'] == $this->data['update_key'] && !isset( $this->queueModel->tasksInQueue[QS_TOWNHALL_CELEBRATION] ) && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  953. {
  954. if ( intval( $_GET

Large files files are truncated, but you can click here to view the full file