function load() { parent::load(); $m = new ActivateModel(); if (isset($_GET['id'])) { $this->playerStatus = $m->doActivation($_GET['id']) ? 1 : 2; } else { if (isset($_GET['uid'])) { $this->uid = intval($_GET['uid']); $row = $m->getPlayerData($this->uid); if ($row == NULL) { $this->uid = 0 - 1; } else { $this->uname = $row['name']; if ($this->isPost()) { if (isset($_POST['pw']) && md5($_POST['pw']) == $row['pwd']) { $mj = new QueueJobModel(); $mj->deletePlayer($this->uid); $this->playerStatus = 3; } } } } } $m->dispose(); }
function load() { // run the queue job if (!$this->isCallback()) { $qj = new QueueJobModel(); $qj->processQueue(); } // change the selected village if (isset($_GET['vid']) && $this->globalModel->hasVillage($this->player->playerId, intval($_GET['vid']))) { $this->globalModel->setSelectedVillage($this->player->playerId, intval($_GET['vid'])); } // fetch the player/village data $this->data = $this->globalModel->getVillageData($this->player->playerId); if ($this->data == NULL) { $this->player->logout(); $this->redirect('index.php'); return; } $this->player->gameStatus = $this->data['gameStatus']; if ($this->isCallback()) { return; } // check for global message if ($this->checkForGlobalMessage && !$this->player->isSpy && $this->data['new_gnews'] == 1) { $this->redirect('shownew.php'); return; } // check for new village creation flag if ($this->checkForNewVillage && !$this->player->isSpy && intval($this->data['create_nvil']) == 1) { $this->redirect('shownvill.php'); return; } $bannerModel = new AdvertisingModel(); $this->banner = $bannerModel->GetBanner(2); // fetch the items in the queue $this->queueModel->fetchQueue($this->player->playerId); // fill the player custom links if (trim($this->data['custom_links']) != '') { $lnk_arr = explode("\n\n", $this->data['custom_links']); foreach ($lnk_arr as $lnk_str) { list($linkName, $linkHref, $linkSelfTarget) = explode("\n", $lnk_str); $this->playerLinks[] = array('linkName' => $linkName, 'linkHref' => $linkHref, 'linkSelfTarget' => $linkSelfTarget != '*'); } } // fill the player villages array $v_arr = explode("\n", $this->data['villages_data']); foreach ($v_arr as $v_str) { list($vid, $x, $y, $vname) = explode(' ', $v_str, 4); $this->playerVillages[$vid] = array($x, $y, $vname); } // fill the resources $wrapString = ''; $elapsedTimeInSeconds = $this->data['elapsedTimeInSeconds']; $r_arr = explode(',', $this->data['resources']); foreach ($r_arr as $r_str) { $r2 = explode(' ', $r_str); $prate = floor($r2[4] * (1 + $r2[5] / 100)) - ($r2[0] == 4 ? $this->data['crop_consumption'] : 0); $current_value = floor($r2[1] + $elapsedTimeInSeconds * ($prate / 3600)); if ($current_value > $r2[2]) { $current_value = $r2[2]; } $this->resources[$r2[0]] = array('current_value' => $current_value, 'store_max_limit' => $r2[2], 'store_init_limit' => $r2[3], 'prod_rate' => $r2[4], 'prod_rate_percentage' => $r2[5], 'calc_prod_rate' => $prate); $wrapString .= $this->resources[$r2[0]]['current_value'] . $this->resources[$r2[0]]['store_max_limit']; } $this->wrap = strlen($wrapString) > 40; // calc the cp list($this->cpValue, $this->cpRate) = explode(' ', $this->data['cp']); $this->cpValue += $elapsedTimeInSeconds * ($this->cpRate / 86400); }
public function makeVillageAsCapital($playerId, $villageId) { $mq = new QueueJobModel(); $capitalRow = $this->provider->fetchRow("SELECT v.id, v.buildings FROM p_villages v WHERE v.player_id=%s AND v.is_capital=1", array($playerId)); $buildingArr = explode(",", $capitalRow['buildings']); $c = 0; foreach ($buildingArr as $buildingItem) { ++$c; $update_state = explode(" ", $buildingItem[2]); $level = explode(" ", $buildingItem[1]); $item_id = explode(" ", $buildingItem[0]); list($item_id, $level, $update_state) = $item_id; if ($item_id == 0) { continue; } $max_lvl_in_non_capital = $GLOBALS['GameMetadata']['items'][$item_id]['max_lvl_in_non_capital']; if ($max_lvl_in_non_capital == NULL || $level + $update_state <= $max_lvl_in_non_capital) { continue; } $dropLevels = $level + $update_state - $max_lvl_in_non_capital; while (0 < $dropLevels--) { $mq->upgradeBuilding($capitalRow['id'], $c, $item_id, TRUE); } } $this->provider->executeQuery("UPDATE p_villages v SET v.is_capital=0 WHERE v.player_id=%s", array($playerId)); $this->provider->executeQuery("UPDATE p_villages v SET v.is_capital=1 WHERE v.id=%s AND v.player_id=%s", array($villageId, $playerId)); }
public function load() { parent::load(); $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && 0 <= intval($_GET['t']) && intval($_GET['t']) <= 11 ? intval($_GET['t']) : 0; $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN; $this->_tb = isset($_GET['tb']) ? intval($_GET['tb']) : 0; $m = new StatisticsModel(); $this->tatarRaised = $m->tatarRaised(); if ($this->selectedTabIndex == 11 && !$this->tatarRaised) { $this->selectedTabIndex = 0; } $this->selectedRank = 0; if ($this->selectedTabIndex == 0) { if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) { if (trim($_POST['name']) != "") { $this->selectedRank = intval($m->getPlayerRankByName(trim($_POST['name']), $this->_tb)); } else { if (0 < intval($_POST['rank'])) { $this->selectedRank = intval($_POST['rank']); } } } else { if (!isset($_GET['p'])) { $this->selectedRank = 0 < $this->_tb && $this->data['tribe_id'] != $this->_tb ? 1 : intval($m->getPlayerRankById($this->player->playerId, $this->_tb)); } } if ($this->isAdmin && !$this->isPost()) { if (isset($_GET['_cs']) && 0 < intval($_GET['_cs'])) { $m->togglePlayerStatus(intval($_GET['_cs'])); $this->adminActionMessage = statistics_p_playerstatusch; } else { if (isset($_GET['_dp']) && 0 < intval($_GET['_dp'])) { if ($m->getPlayerType(intval($_GET['_dp'])) == PLAYERTYPE_NORMAL) { $qm = new QueueJobModel(); $qm->deletePlayer(intval($_GET['_dp'])); $this->adminActionMessage = statistics_p_playerdeleted; } } else { if (isset($_GET['_gd']) && 0 < intval($_GET['_gd']) && isset($_GET['_g']) && 0 <= intval($_GET['_g'])) { $m->setPlayerGold(intval($_GET['_gd']), intval($_GET['_g'])); $this->adminActionMessage = statistics_p_goldwaschanged; } } } } } else { if ($this->selectedTabIndex == 1) { if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) { if (trim($_POST['name']) != "") { $this->selectedRank = intval($m->getAllianceRankByName(trim($_POST['name']))); } else { if (0 < intval($_POST['rank'])) { $this->selectedRank = intval($_POST['rank']); } } } else { if (!isset($_GET['p'])) { $this->selectedRank = intval($m->getAllianceRankById(intval($this->data['alliance_id']))); } } } else { if ($this->selectedTabIndex == 2) { if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) { if (trim($_POST['name']) != "") { $this->selectedRank = intval($m->getVillageRankByName(trim($_POST['name']))); } else { if (0 < intval($_POST['rank'])) { $this->selectedRank = intval($_POST['rank']); } } } else { if (!isset($_GET['p'])) { $this->selectedRank = intval($m->getVillageRankById($this->data['selected_village_id'])); } } } else { if ($this->selectedTabIndex == 3) { if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) { if (trim($_POST['name']) != "") { $this->selectedRank = intval($m->getHeroRankByName(trim($_POST['name']))); } else { if (0 < intval($_POST['rank'])) { $this->selectedRank = intval($_POST['rank']); } } } else { if (!isset($_GET['p'])) { $this->selectedRank = intval($m->getHeroRankById($this->player->playerId)); } } } else { if ($this->selectedTabIndex == 6 || $this->selectedTabIndex == 7) { if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) { if (trim($_POST['name']) != "") { $this->selectedRank = intval($m->getPlayersPointsByName(trim($_POST['name']), $this->selectedTabIndex == 6)); } else { if (0 < intval($_POST['rank'])) { $this->selectedRank = intval($_POST['rank']); } } } else { if (!isset($_GET['p'])) { $this->selectedRank = intval($m->getPlayersPointsById($this->player->playerId, $this->selectedTabIndex == 6)); } } } else { if ($this->selectedTabIndex == 9 || $this->selectedTabIndex == 10) { if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) { if (trim($_POST['name']) != "") { $this->selectedRank = intval($m->getAlliancePointsRankByName(trim($_POST['name']), $this->selectedTabIndex == 9)); } else { if (0 < intval($_POST['rank'])) { $this->selectedRank = intval($_POST['rank']); } } } else { if (!isset($_GET['p'])) { $this->selectedRank = intval($m->getAlliancePointsRankById(intval($this->data['alliance_id']), $this->selectedTabIndex == 9)); } } } } } } } } if ($this->selectedTabIndex == 0) { $rowsCount = $m->getPlayerListCount($this->_tb); $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1; $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0; if ($this->pageCount <= $this->pageIndex) { $this->pageIndex = $this->pageCount - 1; $this->selectedRank = 0 - 1; } $this->dataList = $m->getPlayerList($this->pageIndex, $this->pageSize, $this->_tb); } else { if ($this->selectedTabIndex == 1) { $rowsCount = $m->getAllianceListCount(); $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1; $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0; if ($this->pageCount <= $this->pageIndex) { $this->pageIndex = $this->pageCount - 1; $this->selectedRank = 0 - 1; } $this->dataList = $m->getAlliancesList($this->pageIndex, $this->pageSize); } else { if ($this->selectedTabIndex == 2) { $rowsCount = $m->getVillageListCount(); $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1; $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0; if ($this->pageCount <= $this->pageIndex) { $this->pageIndex = $this->pageCount - 1; $this->selectedRank = 0 - 1; } $this->dataList = $m->getVillagesList($this->pageIndex, $this->pageSize); } else { if ($this->selectedTabIndex == 3) { $rowsCount = $m->getHeroListCount(); $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1; $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0; if ($this->pageCount <= $this->pageIndex) { $this->pageIndex = $this->pageCount - 1; $this->selectedRank = 0 - 1; } $this->dataList = $m->getHerosList($this->pageIndex, $this->pageSize); } else { if ($this->selectedTabIndex == 4) { $this->generalData = $m->getGeneralSummary(); } else { if ($this->selectedTabIndex == 6 || $this->selectedTabIndex == 7) { $rowsCount = $m->getPlayersPointsListCount(); $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1; $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0; if ($this->pageCount <= $this->pageIndex) { $this->pageIndex = $this->pageCount - 1; $this->selectedRank = 0 - 1; } $this->dataList = $m->getPlayersPointsList($this->pageIndex, $this->pageSize, $this->selectedTabIndex == 6); } else { if ($this->selectedTabIndex == 9 || $this->selectedTabIndex == 10) { $rowsCount = $m->getAlliancePointsListCount(); $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1; $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0; if ($this->pageCount <= $this->pageIndex) { $this->pageIndex = $this->pageCount - 1; $this->selectedRank = 0 - 1; } $this->dataList = $m->getAlliancePointsList($this->pageIndex, $this->pageSize, $this->selectedTabIndex == 9); } else { if ($this->selectedTabIndex == 5 || $this->selectedTabIndex == 8) { if ($this->selectedTabIndex == 5) { } $this->top10Result = array("URL" => $this->selectedTabIndex == 5 ? "profile.php?uid=" : "alliance.php?id=", "TARGETNAME" => $this->selectedTabIndex == 5 ? $this->data['name'] : $this->data['alliance_name'], "TARGETID" => $this->selectedTabIndex == 5 ? $this->player->playerId : intval($this->data['alliance_id']), "TARGEPOINT_ATTACK" => $this->selectedTabIndex == 5 ? $this->data['week_attack_points'] : $m->getAlliancePoint(intval($this->data['alliance_id']), "week_attack_points"), "TARGEPOINT_DEFENSE" => $this->selectedTabIndex == 5 ? $this->data['week_defense_points'] : $m->getAlliancePoint(intval($this->data['alliance_id']), "week_defense_points"), "TARGEPOINT_DEV" => $this->selectedTabIndex == 5 ? $this->data['week_dev_points'] : $m->getAlliancePoint(intval($this->data['alliance_id']), "week_dev_points"), "TARGEPOINT_THIEF" => $this->selectedTabIndex == 5 ? $this->data['week_thief_points'] : $m->getAlliancePoint(intval($this->data['alliance_id']), "week_thief_points"), "ATTACK" => $m->getTop10($this->selectedTabIndex == 5, "week_attack_points"), "DEFENSE" => $m->getTop10($this->selectedTabIndex == 5, "week_defense_points"), "DEV" => $m->getTop10($this->selectedTabIndex == 5, "week_dev_points"), "THIEF" => $m->getTop10($this->selectedTabIndex == 5, "week_thief_points")); } else { if ($this->selectedTabIndex == 11) { $this->dataList = $m->getTatarVillagesList(); } } } } } } } } } $m->dispose(); }
function captureVillage($toVillageRow, $fromVillageRow, $kingCropConumption) { global $GameMetadata, $SetupMetadata; $this->provider->executeQuery('DELETE FROM p_queue WHERE player_id=%s AND village_id=%s AND proc_type IN (%s)', array(intval($toVillageRow['player_id']), intval($toVillageRow['id']), QS_BUILD_CREATEUPGRADE . ',' . QS_BUILD_DROP . ',' . QS_TROOP_RESEARCH . ',' . QS_TROOP_UPGRADE_ATTACK . ',' . QS_TROOP_UPGRADE_DEFENSE . ',' . QS_TROOP_TRAINING . ',' . QS_TROOP_TRAINING_HERO . ',' . QS_WAR_ATTACK . ',' . QS_WAR_ATTACK_PLUNDER . ',' . QS_WAR_ATTACK_SPY . ',' . QS_CREATEVILLAGE)); $troops_training = ''; $troops_num = ''; foreach ($GameMetadata['troops'] as $k => $v) { if ($v['for_tribe_id'] == -1 || $v['for_tribe_id'] == $fromVillageRow['tribe_id']) { if ($troops_training != '') { $troops_training .= ','; } $researching_done = $v['research_time_consume'] == 0 ? 1 : 0; $troops_training .= $k . ' ' . $researching_done . ' 0 0'; if ($troops_num != '') { $troops_num .= ','; } $troops_num .= $k . ' 0'; } } $troops_num = '-1:' . $troops_num; $buildings = ''; $reCheckBuilding = $this->provider->fetchScalar('SELECT v.buildings FROM p_villages v WHERE v.id=%s', array(intval($toVillageRow['id']))); $bStr = trim($reCheckBuilding); if ($bStr != '') { $bStrArr = explode(',', $bStr); $mq = new QueueJobModel(); $ccb = 0; foreach ($bStrArr as $b2Str) { ++$ccb; if ($buildings != '') { $buildings .= ','; } list($item_id, $level, $update_state) = explode(' ', $b2Str); if (!isset($GameMetadata['items'][$item_id]['for_tribe_id'][$fromVillageRow['tribe_id']])) { while (0 < $level--) { $mq->upgradeBuilding($toVillageRow['id'], $ccb, $item_id, TRUE); } $item_id = $level = $update_state = 0; } $buildings .= $item_id . ' ' . $level . ' ' . $update_state; } } $this->provider->executeQuery('UPDATE p_villages v SET v.parent_id=%s, v.tribe_id=%s, v.player_id=%s, v.alliance_id=%s, v.player_name=\'%s\', v.alliance_name=\'%s\', v.is_capital=0, v.buildings=\'%s\', v.troops_training=\'%s\', v.troops_num=\'%s\', v.child_villages_id=NULL, v.allegiance_percent=100, v.troops_out_num=NULL, v.troops_out_intrap_num=NULL, v.creation_date=NOW(), v.last_update_date=NOW() WHERE v.id=%s', array(intval($fromVillageRow['id']), intval($fromVillageRow['tribe_id']), intval($fromVillageRow['player_id']), intval($fromVillageRow['alliance_id']) > 0 ? intval($fromVillageRow['alliance_id']) : 'NULL', $fromVillageRow['player_name'], $fromVillageRow['alliance_name'], $buildings, $troops_training, $troops_num, intval($toVillageRow['id']))); $this->provider->executeQuery('UPDATE p_villages v SET v.tribe_id=%s, v.player_id=%s, v.alliance_id=%s, v.player_name=\'%s\', v.alliance_name=\'%s\', v.troops_num=NULL, v.troops_out_num=NULL, v.troops_out_intrap_num=NULL WHERE v.parent_id=%s AND v.is_oasis=1', array(intval($fromVillageRow['tribe_id']), intval($fromVillageRow['player_id']), intval($fromVillageRow['alliance_id']) > 0 ? intval($fromVillageRow['alliance_id']) : 'NULL', $fromVillageRow['player_name'], $fromVillageRow['alliance_name'], intval($toVillageRow['id']))); $child_villages_id = trim($fromVillageRow['child_villages_id']); if ($child_villages_id != '') { $child_villages_id .= ','; } $child_villages_id .= $toVillageRow['id']; $this->provider->executeQuery('UPDATE p_villages v SET v.crop_consumption=v.crop_consumption-%s, v.child_villages_id=\'%s\' WHERE v.id=%s', array($kingCropConumption, $child_villages_id, intval($fromVillageRow['id']))); $prow = $this->provider->fetchRow('SELECT p.villages_id, p.villages_data FROM p_players p WHERE p.id=%s', array(intval($fromVillageRow['player_id']))); $villages_id = trim($prow['villages_id']); if ($villages_id != '') { $villages_id .= ','; } $villages_id .= $toVillageRow['id']; $villages_data = trim($prow['villages_data']); if ($villages_data != '') { $villages_data .= "\n"; } $villages_data .= $toVillageRow['id'] . ' ' . $toVillageRow['rel_x'] . ' ' . $toVillageRow['rel_y'] . ' ' . $toVillageRow['village_name']; $toCheckPeople = $this->provider->fetchScalar('SELECT v.people_count FROM p_villages v WHERE v.id=%s', array(intval($toVillageRow['id']))); $this->provider->executeQuery('UPDATE p_players p SET p.total_people_count=p.total_people_count+%s, p.villages_count=p.villages_count+1, p.selected_village_id=%s, p.villages_id=\'%s\', p.villages_data=\'%s\' WHERE p.id=%s', array(intval($toCheckPeople), intval($toVillageRow['id']), $villages_id, $villages_data, intval($fromVillageRow['player_id']))); }
public function captureVillage($toVillageRow, $fromVillageRow, $kingCropConumption) { $GameMetadata = $GLOBALS['GameMetadata']; $SetupMetadata = $GLOBALS['SetupMetadata']; $this->provider->executeQuery("DELETE FROM p_queue WHERE player_id=%s AND village_id=%s AND proc_type IN (%s)", array(intval($toVillageRow['player_id']), intval($toVillageRow['id']), QS_BUILD_CREATEUPGRADE . "," . QS_BUILD_DROP . "," . QS_TROOP_RESEARCH . "," . QS_TROOP_UPGRADE_ATTACK . "," . QS_TROOP_UPGRADE_DEFENSE . "," . QS_TROOP_TRAINING . "," . QS_TROOP_TRAINING_HERO . "," . QS_WAR_REINFORCE . "," . QS_WAR_ATTACK . "," . QS_WAR_ATTACK_PLUNDER . "," . QS_WAR_ATTACK_SPY . "," . QS_CREATEVILLAGE)); $troops_training = ""; $troops_num = ""; foreach ($GameMetadata['troops'] as $k => $v) { if ($v['for_tribe_id'] == 0 - 1 || $v['for_tribe_id'] == $fromVillageRow['tribe_id']) { if ($troops_training != "") { $troops_training .= ","; } $researching_done = $v['research_time_consume'] == 0 ? 1 : 0; $troops_training .= $k . " " . $researching_done . " 0 0"; if ($troops_num != "") { $troops_num .= ","; } $troops_num .= $k . " 0"; } } $troops_num = "-1:" . $troops_num; $buildings = ""; $bStr = trim($toVillageRow['buildings']); if ($bStr != "") { $bStrArr = explode(",", $bStr); $mq = new QueueJobModel(); $ccb = 0; foreach ($bStrArr as $b2Str) { ++$ccb; if ($buildings != "") { $buildings .= ","; } $update_state = explode(" ", $b2Str); $level = explode(" ", $b2Str); $item_id = explode(" ", $b2Str); list($item_id, $level, $update_state) = $item_id; if (!isset($GameMetadata['items'][$item_id]['for_tribe_id'][$fromVillageRow['tribe_id']])) { while (0 < $level--) { $mq->upgradeBuilding($toVillageRow['id'], $ccb, $item_id, TRUE); } $item_id = $level = $update_state = 0; } $buildings .= $item_id . " " . $level . " " . $update_state; } } $this->provider->executeQuery("UPDATE p_villages v\r\n\t\t\tSET\r\n\t\t\t\tv.parent_id=%s,\r\n\t\t\t\tv.tribe_id=%s,\r\n\t\t\t\tv.player_id=%s,\r\n\t\t\t\tv.alliance_id=%s,\r\n\t\t\t\tv.player_name='%s',\r\n\t\t\t\tv.alliance_name='%s',\r\n\t\t\t\tv.is_capital=0,\r\n\t\t\t\tv.buildings='%s',\r\n\t\t\t\tv.troops_training='%s',\r\n\t\t\t\tv.troops_num='%s',\r\n\t\t\t\tv.child_villages_id=NULL,\r\n\t\t\t\tv.allegiance_percent=100,\r\n\t\t\t\tv.troops_out_num=NULL,\r\n\t\t\t\tv.troops_out_intrap_num=NULL,\r\n\t\t\t\tv.creation_date=NOW(),\r\n\t\t\t\tv.last_update_date=NOW()\r\n\t\t\tWHERE v.id=%s", array(intval($fromVillageRow['id']), intval($fromVillageRow['tribe_id']), intval($fromVillageRow['player_id']), 0 < intval($fromVillageRow['alliance_id']) ? intval($fromVillageRow['alliance_id']) : "NULL", $fromVillageRow['player_name'], $fromVillageRow['alliance_name'], $buildings, $troops_training, $troops_num, intval($toVillageRow['id']))); $this->provider->executeQuery("UPDATE p_villages v\r\n\t\t\tSET\r\n\t\t\t\tv.tribe_id=%s,\r\n\t\t\t\tv.player_id=%s,\r\n\t\t\t\tv.alliance_id=%s,\r\n\t\t\t\tv.player_name='%s',\r\n\t\t\t\tv.alliance_name='%s',\r\n\t\t\t\tv.troops_num=NULL,\r\n\t\t\t\tv.troops_out_num=NULL,\r\n\t\t\t\tv.troops_out_intrap_num=NULL\r\n\t\t\tWHERE v.parent_id=%s AND v.is_oasis=1", array(intval($fromVillageRow['tribe_id']), intval($fromVillageRow['player_id']), 0 < intval($fromVillageRow['alliance_id']) ? intval($fromVillageRow['alliance_id']) : "NULL", $fromVillageRow['player_name'], $fromVillageRow['alliance_name'], intval($toVillageRow['id']))); $child_villages_id = trim($fromVillageRow['child_villages_id']); if ($child_villages_id != "") { $child_villages_id .= ","; } $child_villages_id .= $toVillageRow['id']; $this->provider->executeQuery("UPDATE p_villages v\r\n\t\t\tSET\r\n\t\t\t\tv.crop_consumption=v.crop_consumption-%s,\r\n\t\t\t\tv.child_villages_id='%s'\r\n\t\t\tWHERE v.id=%s", array($kingCropConumption, $child_villages_id, intval($fromVillageRow['id']))); $prow = $this->provider->fetchRow("SELECT p.villages_id, p.villages_data FROM p_players p WHERE p.id=%s", array(intval($fromVillageRow['player_id']))); $villages_id = trim($prow['villages_id']); if ($villages_id != "") { $villages_id .= ","; } $villages_id .= $toVillageRow['id']; $villages_data = trim($prow['villages_data']); if ($villages_data != "") { $villages_data .= "\n"; } $villages_data .= $toVillageRow['id'] . " " . $toVillageRow['rel_x'] . " " . $toVillageRow['rel_y'] . " " . $toVillageRow['village_name']; $this->provider->executeQuery("UPDATE p_players p\r\n\t\t\tSET\r\n\t\t\t\tp.total_people_count=p.total_people_count+%s,\r\n\t\t\t\tp.villages_count=p.villages_count+1,\r\n\t\t\t\tp.selected_village_id=%s,\r\n\t\t\t\tp.villages_id='%s',\r\n\t\t\t\tp.villages_data='%s'\r\n\t\t\tWHERE\r\n\t\t\t\tp.id=%s", array(intval($toVillageRow['people_count']), intval($toVillageRow['id']), $villages_id, $villages_data, intval($fromVillageRow['player_id']))); }