Esempio n. 1
0
 public function handleHerosMansion()
 {
     $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && intval($_GET['t']) == 1 ? intval($_GET['t']) : 0;
     if ($this->selectedTabIndex == 0) {
         $this->hasHero = 0 < intval($this->data['hero_troop_id']);
         $this->troopsUpgradeType = QS_TROOP_TRAINING_HERO;
         if (!$this->hasHero) {
             $this->_getOnlyMyTroops(TRUE);
             if ($_GET['k'] == $this->data['update_key'] && !isset($this->queueModel->tasksInQueue[$this->troopsUpgradeType]) && isset($this->troops[intval($_GET['a'])]) && 0 < $this->troops[intval($_GET['a'])] && !$this->isGameTransientStopped() && !$this->isGameOver()) {
                 $troopId = intval($_GET['a']);
                 $troopMetadata = $this->gameMetadata['troops'][$troopId];
                 $nResources = array("1" => $troopMetadata['training_resources'][1] * 2, "2" => $troopMetadata['training_resources'][2] * 2, "3" => $troopMetadata['training_resources'][3] * 2, "4" => $troopMetadata['training_resources'][4] * 2);
                 if (!$this->isResourcesAvailable($nResources)) {
                 } else {
                     $calcConsume = intval($troopMetadata['training_time_consume'] / $this->gameSpeed * (10 / ($this->buildProperties['building']['level'] + 9))) * 12;
                     $newTask = new QueueTask($this->troopsUpgradeType, $this->player->playerId, $calcConsume);
                     $newTask->procParams = $troopId . " " . $this->data['selected_village_id'];
                     $newTask->tag = $nResources;
                     $this->queueModel->addTask($newTask);
                 }
             }
         } else {
             if ($this->isPost() && isset($_POST['hname']) && trim($_POST['hname']) != "") {
                 $this->data['hero_name'] = trim($_POST['hname']);
                 $m = new BuildModel();
                 $m->changeHeroName($this->player->playerId, $this->data['hero_name']);
                 $m->dispose();
             }
         }
     } else {
         if ($this->selectedTabIndex == 1) {
             $this->villageOases = array();
             $m = new BuildModel();
             $result = $m->getVillageOases(trim($this->data['village_oases_id']));
             while ($result != NULL && $result->next()) {
                 $this->villageOases[$result->row['id']] = array("id" => $result->row['id'], "rel_x" => $result->row['rel_x'], "rel_y" => $result->row['rel_y'], "image_num" => $result->row['image_num'], "allegiance_percent" => $result->row['allegiance_percent']);
             }
             $m->dispose();
             if (!$this->isGameTransientStopped() && !$this->isGameOver()) {
                 $oasisId = intval($_GET['a']);
                 $newTask = new QueueTask(QS_LEAVEOASIS, $this->player->playerId, floor(21600 / $this->gameSpeed));
                 $newTask->villageId = $this->data['selected_village_id'];
                 $newTask->buildingId = $oasisId;
                 $newTask->procParams = $this->villageOases[$oasisId]['rel_x'] . " " . $this->villageOases[$oasisId]['rel_y'];
                 $this->queueModel->addTask($newTask);
             } else {
                 if (isset($_GET['qid']) && 0 < intval($_GET['qid'])) {
                     $this->queueModel->cancelTask($this->player->playerId, intval($_GET['qid']));
                 }
             }
         }
     }
 }
Esempio n. 2
0
<?php

include "BuildModel.php";
$class = new BuildModel();
unset($argv[0]);
if (count($argv) == 0) {
    PrintHelp();
} else {
    $class->class_name = $argv[1];
    foreach ($argv as $arg) {
        if (preg_match("/([-v])\\w/", $arg, $r)) {
        }
        echo $arg;
        echo "\n";
    }
    $class->SaveFile();
}
function PrintHelp()
{
    echo "This is unhelpfull help";
}
Esempio n. 3
0
 public function _canBuildNewVillage()
 {
     $GameMetadata = $GLOBALS['GameMetadata'];
     $neededCpValue = $totalCpRate = $totalCpValue = 0;
     $m = new BuildModel();
     $result = $m->getVillagesCp($this->data['villages_id']);
     while ($result->next()) {
         list($cpValue, $cpRate) = explode(" ", $result->row['cp']);
         $cpValue += $result->row['elapsedTimeInSeconds'] * ($cpRate / 86400);
         $totalCpRate += $cpRate;
         $totalCpValue += $cpValue;
         $neededCpValue += intval($this->gameMetadata['cp_for_new_village'] / $GameMetadata['game_speed']);
     }
     $totalCpValue = floor($totalCpValue);
     $m->dispose();
     return $neededCpValue <= $totalCpValue;
 }