public function executeWarResult($taskRow) { $taskRow['village_id'] = intval($taskRow['village_id']); $fromVillageRow = $this->_getVillageInfo($taskRow['village_id']); $toVillageRow = $this->_getVillageInfo($taskRow['to_village_id']); $paramsArray = explode("|", $taskRow['proc_params']); $troopsArrStr = explode(",", $paramsArray[0]); $troopsArray = array("troops" => array(), "onlyHero" => FALSE, "heroTroopId" => 0, "hasHero" => FALSE, "hasKing" => FALSE, "hasWallDest" => FALSE, "cropConsumption" => 0); $_onlyHero = TRUE; foreach ($troopsArrStr as $_t) { $tnum = explode(" ", $_t); $tid = explode(" ", $_t); list($tid, $tnum) = $tid; if ($tnum == 0 - 1) { $troopsArray['hasHero'] = TRUE; $troopsArray['heroTroopId'] = $tid; $tnum = 1; } else { $troopsArray['troops'][$tid] = $tnum; if (0 < $tnum) { $_onlyHero = FALSE; } else { continue; } if ($tid == 9 || $tid == 19 || $tid == 29 || $tid == 108 || $tid == 59) { $troopsArray['hasKing'] = TRUE; } if ($tid == 7 || $tid == 17 || $tid == 27 || $tid == 106 || $tid == 57) { $troopsArray['hasWallDest'] = TRUE; } } $tnum += $troopsArray['cropConsumption']; //fix still needed } if ($_onlyHero && $troopsArray['hasHero']) { $troopsArray['onlyHero'] = TRUE; } $procInfo = array("troopsArray" => $troopsArray, "hasHero" => $paramsArray[1] == 1, "spyAction" => $paramsArray[2], "catapultTarget" => $paramsArray[3], "harvestResources" => $paramsArray[4], "spyInfo" => $paramsArray[5], "catapultResult" => $paramsArray[6], "troopBack" => $paramsArray[7] == 1); if ($taskRow['proc_type'] == QS_CREATEVILLAGE && ($toVillageRow['is_oasis'] || 0 < intval($toVillageRow['player_id']))) { $taskRow['proc_type'] = QS_WAR_ATTACK_PLUNDER; } switch ($taskRow['proc_type']) { case QS_WAR_REINFORCE: require_once MODEL_PATH . DIRECTORY_SEPARATOR . "battles" . DIRECTORY_SEPARATOR . "reinforcement.php"; $reinforceModel = new ReInforcementBattleModel(); return $reinforceModel->handleReInforcement($taskRow, $toVillageRow, $fromVillageRow, $procInfo, $paramsArray[0]); case QS_WAR_ATTACK: break; case QS_WAR_ATTACK_PLUNDER: } require_once MODEL_PATH . DIRECTORY_SEPARATOR . "battles" . DIRECTORY_SEPARATOR . "war.php"; $warModel = new WarBattleModel(); return $warModel->handleWarAttack($taskRow, $toVillageRow, $fromVillageRow, $procInfo); switch ($taskRow['proc_type']) { case QS_WAR_ATTACK_SPY: require_once MODEL_PATH . DIRECTORY_SEPARATOR . "battles" . DIRECTORY_SEPARATOR . "spy.php"; $spyModel = new SpyBattleModel(); return $spyModel->handleWarSpy($taskRow, $toVillageRow, $fromVillageRow, $procInfo); case QS_CREATEVILLAGE: require_once MODEL_PATH . DIRECTORY_SEPARATOR . "battles" . DIRECTORY_SEPARATOR . "createnewvillage.php"; $newVillageModel = new NewVillageBattleModel(); return $newVillageModel->handleCreateNewVillage($taskRow, $toVillageRow, $fromVillageRow, $troopsArray['cropConsumption']); } return FALSE; }
function executeWarResult($taskRow) { global $GameMetadata; $taskRow['village_id'] = intval($taskRow['village_id']); $fromVillageRow = $this->_getVillageInfo($taskRow['village_id']); $toVillageRow = $this->_getVillageInfo($taskRow['to_village_id']); $paramsArray = explode('|', $taskRow['proc_params']); $troopsArrStr = explode(',', $paramsArray[0]); $troopsArray = array('troops' => array(), 'onlyHero' => FALSE, 'heroTroopId' => 0, 'hasHero' => FALSE, 'hasKing' => FALSE, 'hasWallDest' => FALSE, 'cropConsumption' => 0); $_onlyHero = TRUE; foreach ($troopsArrStr as $_t) { list($tid, $tnum) = explode(' ', $_t); if ($tnum == -1) { $troopsArray['hasHero'] = TRUE; $troopsArray['heroTroopId'] = $tid; $tnum = 1; } else { $troopsArray['troops'][$tid] = $tnum; if ($tnum > 0) { $_onlyHero = FALSE; } else { continue; } if ($tid == 9 || $tid == 19 || $tid == 29) { $troopsArray['hasKing'] = TRUE; } if ($tid == 7 || $tid == 17 || $tid == 27) { $troopsArray['hasWallDest'] = TRUE; } } $troopsArray['cropConsumption'] += $GameMetadata['troops'][$tid]['crop_consumption'] * $tnum; } if ($_onlyHero && $troopsArray['hasHero']) { $troopsArray['onlyHero'] = TRUE; } $procInfo = array('troopsArray' => $troopsArray, 'hasHero' => $paramsArray[1] == 1, 'spyAction' => $paramsArray[2], 'catapultTarget' => $paramsArray[3], 'harvestResources' => $paramsArray[4], 'spyInfo' => $paramsArray[5], 'catapultResult' => $paramsArray[6], 'troopBack' => $paramsArray[7] == 1); if ($taskRow['proc_type'] == QS_CREATEVILLAGE) { if ($toVillageRow['is_oasis'] || intval($toVillageRow['player_id']) > 0) { $taskRow['proc_type'] = QS_WAR_ATTACK_PLUNDER; } } switch ($taskRow['proc_type']) { case QS_WAR_REINFORCE: require_once MODEL_PATH . DIRECTORY_SEPARATOR . 'battles' . DIRECTORY_SEPARATOR . 'reinforcement.php'; $reinforceModel = new ReInforcementBattleModel(); return $reinforceModel->handleReInforcement($taskRow, $toVillageRow, $fromVillageRow, $procInfo, $paramsArray[0]); case QS_WAR_ATTACK: case QS_WAR_ATTACK_PLUNDER: require_once MODEL_PATH . DIRECTORY_SEPARATOR . 'battles' . DIRECTORY_SEPARATOR . 'war.php'; $warModel = new WarBattleModel(); return $warModel->handleWarAttack($taskRow, $toVillageRow, $fromVillageRow, $procInfo); case QS_WAR_ATTACK_SPY: require_once MODEL_PATH . DIRECTORY_SEPARATOR . 'battles' . DIRECTORY_SEPARATOR . 'spy.php'; $spyModel = new SpyBattleModel(); return $spyModel->handleWarSpy($taskRow, $toVillageRow, $fromVillageRow, $procInfo); case QS_CREATEVILLAGE: require_once MODEL_PATH . DIRECTORY_SEPARATOR . 'battles' . DIRECTORY_SEPARATOR . 'createnewvillage.php'; $newVillageModel = new NewVillageBattleModel(); return $newVillageModel->handleCreateNewVillage($taskRow, $toVillageRow, $fromVillageRow, $troopsArray['cropConsumption']); } return TRUE; }