Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 1.1.4.0
- * @ Author : DeZender
- * @ Release on : 30.03.2012
- * @ Official site : http://DeZender.Net
- *
- */
- require( '.' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'boot.php' );
- require_once( MODEL_PATH . 'build.php' );
- class GPage extends VillagePage {
- var $productionPane = TRUE;
- var $buildingView = '';
- var $buildingIndex = -1;
- var $buildProperties = NULL;
- var $newBuilds = NULL;
- var $troopsUpgrade = null;
- var $troopsUpgradeType = null;
- var $buildingTribeFactor = null;
- var $troops = array( );
- var $selectedTabIndex = 0;
- var $villageOases = null;
- var $childVillages = null;
- var $hasHero = FALSE;
- var $totalCpRate = null;
- var $totalCpValue = null;
- var $neededCpValue = null;
- var $childVillagesCount = null;
- var $showBuildingForm = null;
- var $embassyProperty = null;
- var $merchantProperty = null;
- var $rallyPointProperty = null;
- var $crannyProperty = array( 'buildingCount' => 0, 'totalSize' => 0 );
- var $warriorMessage = '';
- var $dataList = null;
- var $pageSize = 40;
- var $pageCount = null;
- var $pageIndex = null;
- function GPage() {
- parent::villagepage( );
- $this->viewFile = 'build.phtml';
- $this->contentCssClass = 'build';
- }
- function onLoadBuildings($building) {
- $GameMetadata = $GLOBALS['GameMetadata'];
- if (( ( ( $this->buildingIndex == 0 - 1 && isset( $_GET['bid'] ) ) && is_numeric( $_GET['bid'] ) ) && $_GET['bid'] == $building['item_id'] )) {
- $this->buildingIndex = $building['index'];
- }
- if (( $building['item_id'] == 23 && 0 < $building['level'] )) {
- ++$this->crannyProperty['buildingCount'];
- $this->crannyProperty += 'totalSize' = $GameMetadata['items'][$building['item_id']]['levels'][$building['level'] - 1]['value'] * $GameMetadata['items'][$building['item_id']]['for_tribe_id'][$this->tribeId];
- }
- }
- function load() {
- parent::load( );
- if (( ( ( $this->buildingIndex == 0 - 1 && isset( $_GET['id'] ) ) && is_numeric( $_GET['id'] ) ) && isset( $this->buildings[$_GET['id']] ) )) {
- $this->buildingIndex = intval( $_GET['id'] );
- }
- $this->buildProperties = $this->getBuildingProperties( $this->buildingIndex );
- if ($this->buildProperties == NULL) {
- $this->redirect( 'village1.php' );
- return null;
- }
- if ($this->buildProperties['emptyPlace']) {
- $this->villagesLinkPostfix .= '&id=' . $this->buildingIndex;
- $this->newBuilds = array( 'available' => array( ), 'soon' => array( ) );
- foreach ($this->gameMetadata['items'] as $item_id => $build) {
- if (( $item_id <= 4 || !isset( $build['for_tribe_id'][$this->tribeId] ) )) {
- continue;
- }
- $canBuild = $this->canCreateNewBuild( $item_id );
- if ($canBuild != 0 - 1) {
- if ($canBuild) {
- if (!isset( $this->newBuilds['available'][$build['levels'][0]['time_consume']] )) {
- $this->newBuilds['available'][$build['levels'][0]['time_consume']] = array( );
- }
- $this->newBuilds['available'][$build['levels'][0]['time_consume']][$item_id] = $build;
- continue;
- }
- $dependencyCount = 0;
- foreach ($build['pre_requests'] as $reqId => $reqValue) {
- if ($reqValue != NULL) {
- $build['pre_requests_dependencyCount'][$reqId] = $reqValue - $this->_getMaxBuildingLevel( $reqId );
- $dependencyCount += $build['pre_requests_dependencyCount'][$reqId];
- continue;
- }
- }
- if (!isset( $this->newBuilds['soon'][$dependencyCount] )) {
- $this->newBuilds['soon'][$dependencyCount] = array( );
- }
- $this->newBuilds['soon'][$dependencyCount][$item_id] = $build;
- continue;
- }
- }
- ksort( $this->newBuilds['available'], SORT_NUMERIC );
- ksort( $this->newBuilds['soon'], SORT_NUMERIC );
- return null;
- }
- $bitemId = $this->buildProperties['building']['item_id'];
- $this->villagesLinkPostfix .= '&id=' . $this->buildingIndex;
- if (4 < $bitemId) {
- $this->villagesLinkPostfix .= '&bid=' . $bitemId;
- }
- $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);
- if ($this->buildings[$this->buildingIndex]['level'] == 0) {
- return null;
- }
- switch ($bitemId) {
- case 12: {
- }
- case 13: {
- $this->productionPane = FALSE;
- $this->buildingView = 'Blacksmith_Armoury';
- $this->handleBlacksmithArmoury( );
- break;
- }
- case 15: {
- if (10 <= $this->buildings[$this->buildingIndex]['level']) {
- $this->buildingView = 'MainBuilding';
- $this->handleMainBuilding( );
- }
- break;
- }
- case 16: {
- $this->productionPane = FALSE;
- $this->buildingView = 'RallyPoint';
- $this->handleRallyPoint( );
- break;
- }
- case 17: {
- $this->productionPane = FALSE;
- $this->buildingView = 'Marketplace';
- $this->handleMarketplace( );
- break;
- }
- case 18: {
- $this->productionPane = FALSE;
- $this->buildingView = 'Embassy';
- $this->handleEmbassy( );
- break;
- }
- case 19: {
- }
- case 20: {
- }
- case 21: {
- }
- case 29: {
- }
- case 30: {
- }
- case 36: {
- $this->_getOnlyMyTroops( );
- $this->productionPane = $bitemId == 36;
- $this->buildingView = 'TroopBuilding';
- $this->handleTroopBuilding( );
- break;
- }
- case 22: {
- $this->productionPane = FALSE;
- $this->buildingView = 'Academy';
- $this->handleAcademy( );
- break;
- }
- case 23: {
- $this->productionPane = TRUE;
- $this->buildingView = 'Cranny';
- break;
- }
- case 24: {
- $this->productionPane = FALSE;
- $this->buildingView = 'TownHall';
- $this->handleTownHall( );
- break;
- }
- case 25: {
- }
- case 26: {
- $this->productionPane = FALSE;
- $this->buildingView = 'Residence_Palace';
- $this->handleResidencePalace( );
- break;
- }
- case 37: {
- $this->productionPane = FALSE;
- $this->buildingView = 'HerosMansion';
- $this->handleHerosMansion( );
- break;
- }
- case 40: {
- $this->productionPane = FALSE;
- break;
- }
- case 42: {
- $this->_getOnlyMyTroops( );
- $this->productionPane = TRUE;
- $this->buildingView = 'Warrior';
- $this->handleWarrior( );
- }
- }
- }
- function handleBlacksmithArmoury() {
- $this->troopsUpgradeType = ($this->buildings[$this->buildingIndex]['item_id'] == 12 ? QS_TROOP_UPGRADE_ATTACK : QS_TROOP_UPGRADE_DEFENSE);
- $this->troopsUpgrade = array( );
- $_arr = explode( ',', $this->data['troops_training'] );
- $_c = 0;
- foreach ($_arr as $troopStr) {
- ++$_c;
- list( $troopId, $researches_done, $defense_level, $attack_level ) = explode( ' ', $troopStr );
- $tlevel = ($this->troopsUpgradeType == QS_TROOP_UPGRADE_ATTACK ? $attack_level : $defense_level);
- if (( ( ( $troopId != 99 && $_c <= 8 ) && $tlevel < 20 ) && $researches_done == 1 )) {
- $this->troopsUpgrade[$troopId] = $tlevel;
- continue;
- }
- }
- if (( ( ( ( ( ( isset( $_GET['a'] ) && isset( $_GET['k'] ) ) && $_GET['k'] == $this->data['update_key'] ) && !isset( $this->queueModel->tasksInQueue[$this->troopsUpgradeType] ) ) && isset( $this->troopsUpgrade[intval( $_GET['a'] )] ) ) && !$this->isGameTransientStopped( ) ) && !$this->isGameOver( ) )) {
- $troopId = intval( $_GET['a'] );
- $level = $this->troopsUpgrade[$troopId];
- $buildingMetadata = $this->gameMetadata['items'][$this->buildProperties['building']['item_id']]['troop_upgrades'][$troopId][$level];
- if (!$this->isResourcesAvailable( $buildingMetadata['resources'] )) {
- return null;
- }
- $calcConsume = intval( $buildingMetadata['time_consume'] / $this->gameSpeed * ( 10 / ( $this->buildProperties['building']['level'] + 9 ) ) );
- $newTask = new QueueTask( $this->troopsUpgradeType, $this->player->playerId, $calcConsume );
- $newTask->villageId = $this->data['selected_village_id'];
- $newTask->procParams = $troopId . ' ' . ( $level + 1 );
- $newTask->tag = $buildingMetadata['resources'];
- $this->queueModel->addTask( $newTask );
- }
- }
- function handleMainBuilding() {
- 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( ) )) {
- $item_id = $this->buildings[$_POST['drbid']]['item_id'];
- $calcConsume = intval( $this->gameMetadata['items'][$item_id]['levels'][$this->buildings[$_POST['drbid']]['level'] - 1]['time_consume'] / $this->gameSpeed * ( $this->data['time_consume_percent'] / 400 ) );
- $newTask = new QueueTask( QS_BUILD_DROP, $this->player->playerId, $calcConsume );
- $newTask->villageId = $this->data['selected_village_id'];
- $newTask->buildingId = $item_id;
- $newTask->procParams = $this->buildings[$_POST['drbid']]['index'];
- $this->queueModel->addTask( $newTask );
- return null;
- }
- 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( ) )) {
- $this->queueModel->cancelTask( $this->player->playerId, intval( $_GET['qid'] ) );
- }
- }
- function handleRallyPoint() {
- if (isset( $_GET['d'] )) {
- $this->queueModel->cancelTask( $this->player->playerId, intval( $_GET['d'] ) );
- }
- $this->rallyPointProperty = array( 'troops_in_village' => array( 'troopsTable' => $this->_getTroopsList( 'troops_num' ), 'troopsIntrapTable' => $this->_getTroopsList( 'troops_intrap_num' ) ), 'troops_out_village' => array( 'troopsTable' => $this->_getTroopsList( 'troops_out_num' ), 'troopsIntrapTable' => $this->_getTroopsList( 'troops_out_intrap_num' ) ), 'troops_in_oases' => array( ), 'war_to_village' => $this->queueModel->tasksInQueue['war_troops']['to_village'], 'war_from_village' => $this->queueModel->tasksInQueue['war_troops']['from_village'], 'war_to_oasis' => $this->queueModel->tasksInQueue['war_troops']['to_oasis'] );
- $village_oases_id = trim( $this->data['village_oases_id'] );
- if ($village_oases_id != '') {
- $m = new BuildModel( );
- $result = $m->getOasesDataById( $village_oases_id );
- while ($result->next( )) {
- $this->rallyPointProperty['troops_in_oases'][$result->row['id']] = array( 'oasisRow' => $result->row, 'troopsTable' => $this->_getOasisTroopsList( $result->row['troops_num'] ), 'war_to' => (isset( $this->rallyPointProperty['war_to_oasis'][$result->row['id']] ) ? $this->rallyPointProperty['war_to_oasis'][$result->row['id']] : NULL) );
- }
- $m->dispose( );
- }
- }
- function _canCancelWarTask($taskType, $taskId) {
- if (!QueueTask::iscancelabletask( $taskType )) {
- return FALSE;
- }
- $timeout = QueueTask::getmaxcanceltimeout( $taskType );
- if (0 - 1 < $timeout) {
- $_task = NULL;
- foreach ($this->queueModel->tasksInQueue[$taskType] as $t) {
- if ($t['id'] == $taskId) {
- $_task = $t;
- break;
- }
- }
- if ($_task == NULL) {
- return FALSE;
- }
- $elapsedTime = $t['elapsedTime'];
- if ($timeout < $elapsedTime) {
- return FALSE;
- }
- }
- return TRUE;
- }
- function _getOasisTroopsList(&$troops_num) {
- $GameMetadata = $GLOBALS['GameMetadata'];
- $m = new BuildModel( );
- $returnTroops = array( );
- if (trim( $troops_num ) != '') {
- $t_arr = explode( '|', $troops_num );
- foreach ($t_arr as $t_str) {
- $t2_arr = explode( ':', $t_str );
- $vid = $t2_arr[0];
- $villageData = $m->getVillageData2ById( $vid );
- $returnTroops[$vid] = array( 'villageData' => $villageData, 'cropConsumption' => 0, 'hasHero' => FALSE, 'troops' => array( ) );
- $t2_arr = explode( ',', $t2_arr[1] );
- foreach ($t2_arr as $t2_str) {
- list( $tid, $tnum ) = explode( ' ', $t2_str );
- if ($tid == 99) {
- continue;
- }
- if ($tnum == 0 - 1) {
- $tnum = 1;
- $returnTroops[$vid]['hasHero'] = TRUE;
- } else {
- $returnTroops[$vid]['troops'][$tid] = $tnum;
- }
- $returnTroops[$vid] += 'cropConsumption' = $GameMetadata['troops'][$tid]['crop_consumption'] * $tnum;
- }
- }
- }
- $m->dispose( );
- return $returnTroops;
- }
- function _getTroopsList(&$key) {
- $GameMetadata = $GLOBALS['GameMetadata'];
- $m = new BuildModel( );
- $returnTroops = array( );
- if (trim( $this->data[$key] ) != '') {
- $t_arr = explode( '|', $this->data[$key] );
- foreach ($t_arr as $t_str) {
- $t2_arr = explode( ':', $t_str );
- $vid = intval( $t2_arr[0] );
- $villageData = NULL;
- if ($vid == 0 - 1) {
- $vid = $this->data['selected_village_id'];
- $villageData = array( 'id' => $vid, 'village_name' => $this->data['village_name'], 'player_id' => $this->player->playerId, 'player_name' => buildings_p_thisvillage );
- } else {
- $villageData = $m->getVillageData2ById( $vid );
- }
- $returnTroops[$vid] = array( 'villageData' => $villageData, 'cropConsumption' => 0, 'hasHero' => FALSE, 'troops' => array( ) );
- if ($vid == $this->data['selected_village_id']) {
- $returnTroops[$vid]['hasHero'] = intval( $this->data['hero_in_village_id'] ) == intval( $this->data['selected_village_id'] );
- if ($returnTroops[$vid]['hasHero']) {
- $returnTroops[$vid] += 'cropConsumption' = $GameMetadata['troops'][$this->data['hero_troop_id']]['crop_consumption'];
- }
- }
- $t2_arr = explode( ',', $t2_arr[1] );
- foreach ($t2_arr as $t2_str) {
- list( $tid, $tnum ) = explode( ' ', $t2_str );
- if ($tid == 99) {
- continue;
- }
- if ($tnum == 0 - 1) {
- $tnum = 1;
- $returnTroops[$vid]['hasHero'] = TRUE;
- } else {
- $returnTroops[$vid]['troops'][$tid] = $tnum;
- }
- $returnTroops[$vid] += 'cropConsumption' = $GameMetadata['troops'][$tid]['crop_consumption'] * $tnum;
- }
- }
- }
- $m->dispose( );
- return $returnTroops;
- }
- function handleMarketplace() {
- $this->selectedTabIndex = (( ( ( isset( $_GET['t'] ) && is_numeric( $_GET['t'] ) ) && 1 <= intval( $_GET['t'] ) ) && intval( $_GET['t'] ) <= 3 ) ? intval( $_GET['t'] ) : 0);
- $itemId = $this->buildings[$this->buildingIndex]['item_id'];
- $itemLevel = $this->buildings[$this->buildingIndex]['level'];
- $tribeMetadata = $this->gameMetadata['tribes'][$this->data['tribe_id']];
- $tradeOfficeLevel = $this->_getMaxBuildingLevel( 28 );
- $capacityFactor = ($tradeOfficeLevel == 0 ? 1 : $this->gameMetadata['items'][28]['levels'][$tradeOfficeLevel - 1]['value'] / 100);
- $capacityFactor *= $this->gameMetadata['game_speed'];
- $total_merchants_num = $this->gameMetadata['items'][$itemId]['levels'][$itemLevel - 1]['value'];
- $exist_num = $total_merchants_num - $this->queueModel->tasksInQueue['out_merchants_num'] - $this->data['offer_merchants_count'];
- if ($exist_num < 0) {
- $exist_num = 0;
- }
- $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 );
- if ($this->selectedTabIndex == 0) {
- $m = new BuildModel( );
- if (( $this->isPost( ) || isset( $_GET['vid2'] ) )) {
- $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) );
- $this->merchantProperty['confirm_snd'] = ($this->isPost( ) ? ( isset( $_POST['act'] ) && $_POST['act'] == 1 ) : isset( $_GET['vid2'] ));
- $map_size = $this->setupMetadata['map_size'];
- $doSend = FALSE;
- if ($this->merchantProperty['confirm_snd']) {
- $vRow = NULL;
- if (( ( ( isset( $_POST['x'] ) && isset( $_POST['y'] ) ) && trim( $_POST['x'] ) != '' ) && trim( $_POST['y'] ) != '' )) {
- $vid = $this->__getVillageId( $map_size, $this->__getCoordInRange( $map_size, intval( $_POST['x'] ) ), $this->__getCoordInRange( $map_size, intval( $_POST['y'] ) ) );
- $vRow = $m->getVillageDataById( $vid );
- } else {
- if (( isset( $_POST['vname'] ) && trim( $_POST['vname'] ) != '' )) {
- $vRow = $m->getVillageDataByName( trim( $_POST['vname'] ) );
- } else {
- if (isset( $_GET['vid2'] )) {
- $vRow = $m->getVillageDataById( intval( $_GET['vid2'] ) );
- if ($vRow != NULL) {
- $_POST['x'] = $vRow['rel_x'];
- $_POST['y'] = $vRow['rel_y'];
- }
- }
- }
- }
- } else {
- $doSend = TRUE;
- $vRow = $m->getVillageDataById( intval( $_POST['vid2'] ) );
- $this->merchantProperty['showError'] = FALSE;
- $_POST['r4'] = '';
- $_POST['r3'] = ;
- $_POST['r2'] = ;
- $_POST['r1'] = ;
- }
- if (( 0 < intval( $vRow['player_id'] ) && $m->getPlayType( intval( $vRow['player_id'] ) ) == PLAYERTYPE_ADMIN )) {
- $this->merchantProperty['showError'] = FALSE;
- $this->merchantProperty['confirm_snd'] = FALSE;
- return null;
- }
- $this->merchantProperty['vRow'] = $vRow;
- $this->merchantProperty['to_vid'] = ($vRow != NULL ? $vRow['id'] : 0);
- $vid = ;
- $rel_x = $vRow['rel_x'];
- $rel_y = $vRow['rel_y'];
- $this->merchantProperty['same_village'] = $vid == $this->data['selected_village_id'];
- $this->merchantProperty['available_res'] = $this->isResourcesAvailable( $resources );
- $this->merchantProperty['vRow_merchant_num'] = ceil( ( $resources[1] + $resources[2] + $resources[3] + $resources[4] ) / $this->merchantProperty['capacity'] );
- $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'] );
- $this->merchantProperty['showError'] = !$this->merchantProperty['confirm_snd'];
- $distance = WebHelper::getdistance( $this->data['rel_x'], $this->data['rel_y'], $rel_x, $rel_y, $this->setupMetadata['map_size'] / 2 );
- $this->merchantProperty['vRow_time'] = intval( $distance / $this->merchantProperty['speed'] * 3600 );
- if (( ( ( !$this->merchantProperty['showError'] && $doSend ) && !$this->isGameTransientStopped( ) ) && !$this->isGameOver( ) )) {
- $this->merchantProperty['confirm_snd'] = FALSE;
- $this->merchantProperty -= 'exits_num' = $this->merchantProperty['vRow_merchant_num'];
- $newTask = new QueueTask( QS_MERCHANT_GO, $this->player->playerId, $this->merchantProperty['vRow_time'] );
- $newTask->villageId = $this->data['selected_village_id'];
- $newTask->toPlayerId = $vRow['player_id'];
- $newTask->toVillageId = $vid;
- $newTask->procParams = $this->merchantProperty['vRow_merchant_num'] . '|' . ( $resources[1] . ' ' . $resources[2] . ' ' . $resources[3] . ' ' . $resources[4] );
- $newTask->tag = $resources;
- $this->queueModel->addTask( $newTask );
- }
- }
- $m->dispose( );
- return null;
- }
- if ($this->selectedTabIndex == 1) {
- $m = new BuildModel( );
- $showOfferList = TRUE;
- if (( isset( $_GET['oid'] ) && 0 < intval( $_GET['oid'] ) )) {
- $oRow = $m->getOffer2( intval( $_GET['oid'] ), $this->data['rel_x'], $this->data['rel_y'], $this->setupMetadata['map_size'] / 2 );
- if ($oRow != NULL) {
- $aid = 0;
- if ($oRow['alliance_only']) {
- if (0 < intval( $this->data['alliance_id'] )) {
- $aid = $m->getPlayerAllianceId( $oRow['player_id'] );
- }
- }
- list( $res1, $res2 ) = explode( '|', $oRow['offer'] );
- $resArr1 = explode( ' ', $res1 );
- $needResources = array( '1' => $resArr1[0], '2' => $resArr1[1], '3' => $resArr1[2], '4' => $resArr1[3] );
- $res1_item_id = 0;
- $res1_value = 0;
- $i = 0;
- $_c = sizeof( $resArr1 );
- while ($i < $_c) {
- if (0 < $resArr1[$i]) {
- $res1_item_id = $i + 1;
- $res1_value = $resArr1[$i];
- break;
- }
- ++$i;
- }
- $resArr1 = explode( ' ', $res2 );
- $giveResources = array( '1' => $resArr1[0], '2' => $resArr1[1], '3' => $resArr1[2], '4' => $resArr1[3] );
- $res2_item_id = 0;
- $res2_value = 0;
- $i = 0;
- $_c = sizeof( $resArr1 );
- while ($i < $_c) {
- if (0 < $resArr1[$i]) {
- $res2_item_id = $i + 1;
- $res2_value = $resArr1[$i];
- break;
- }
- ++$i;
- }
- $distance = $oRow['timeInSeconds'] / 3600 * $oRow['merchants_speed'];
- $acceptResult = $this->_canAcceptOffer( $needResources, $giveResources, $oRow['village_id'], $oRow['alliance_only'], $aid, $oRow['max_time'], $distance );
- if (( ( $acceptResult == 5 && !$this->isGameTransientStopped( ) ) && !$this->isGameOver( ) )) {
- $showOfferList = FALSE;
- $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 );
- $merchantNum = ceil( ( $giveResources[1] + $giveResources[2] + $giveResources[3] + $giveResources[4] ) / $this->merchantProperty['capacity'] );
- $newTask = new QueueTask( QS_MERCHANT_GO, $this->player->playerId, $distance / ( $this->gameMetadata['tribes'][$this->data['tribe_id']]['merchants_velocity'] * $this->gameMetadata['game_speed'] ) * 3600 );
- $newTask->villageId = $this->data['selected_village_id'];
- $newTask->toPlayerId = $oRow['player_id'];
- $newTask->toVillageId = $oRow['village_id'];
- $newTask->procParams = $merchantNum . '|' . ( $giveResources[1] . ' ' . $giveResources[2] . ' ' . $giveResources[3] . ' ' . $giveResources[4] );
- $newTask->tag = $giveResources;
- $this->queueModel->addTask( $newTask );
- $newTask = new QueueTask( QS_MERCHANT_GO, $oRow['player_id'], $oRow['timeInSeconds'] );
- $newTask->villageId = $oRow['village_id'];
- $newTask->toPlayerId = $this->player->playerId;
- $newTask->toVillageId = $this->data['selected_village_id'];
- $newTask->procParams = $oRow['merchants_num'] . '|' . ( $needResources[1] . ' ' . $needResources[2] . ' ' . $needResources[3] . ' ' . $needResources[4] );
- $newTask->tag = array( '1' => 0, '2' => 0, '3' => 0, '4' => 0 );
- $this->queueModel->addTask( $newTask );
- $m->removeMerchantOffer( intval( $_GET['oid'] ), $oRow['player_id'], $oRow['village_id'] );
- }
- }
- }
- $this->merchantProperty['showOfferList'] = $showOfferList;
- if ($showOfferList) {
- $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'] );
- $this->pageCount = (0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1);
- $this->pageIndex = (( ( isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ) && intval( $_GET['p'] ) < $this->pageCount ) ? intval( $_GET['p'] ) : 0);
- $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 );
- }
- $m->dispose( );
- return null;
- }
- .................................
- ......................
- .............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement