コード例 #1
0
ファイル: Clanportal.php プロジェクト: Toxicat/dolumar
 public function canBuildBuilding(Dolumar_Players_Village $village)
 {
     // Only one portal allowed
     if ($village->buildings->hasBuilding($this)) {
         return false;
     }
     if (!defined('ALLOW_CLANPORTALS')) {
         return false;
     }
     if (count($village->getOwner()->getClans()) > 0) {
         return $this->buildRequirementCheck($village);
     }
     return false;
 }
コード例 #2
0
ファイル: Map.php プロジェクト: Toxicat/dolumar
 public function getObjects($squarePoints, $radius)
 {
     $profiler = Neuron_Profiler_Profiler::getInstance();
     // Let's replace this :)
     $out = array();
     $buildingSQL = Dolumar_Map_Map::getBuildingsFromLocations($squarePoints, max($radius, 3));
     $objects = array();
     foreach ($buildingSQL as $buildingV) {
         $profiler->start('Initializing building');
         $profiler->start('Fetching building race object');
         $race = Dolumar_Races_Race::getRace($buildingV['race']);
         $profiler->stop();
         $profiler->start('Fetching building object');
         $b = Dolumar_Buildings_Building::getBuilding($buildingV['buildingType'], $race, $buildingV['xas'], $buildingV['yas']);
         $village = Dolumar_Players_Village::getVillage($buildingV['village']);
         $b->setVillage($village);
         $profiler->stop();
         $profiler->start('Setting data');
         $b->setData($buildingV['bid'], $buildingV);
         if ($buildingV['destroyDate'] > 0 && $buildingV['destroyDate'] < NOW) {
             $b->setDestroyed(true);
         }
         $profiler->stop();
         $profiler->start('Assigning building to array');
         //$buildings[floor ($buildingV['xas'])][floor ($buildingV['yas'])][] = $b;
         $objects[] = new Dolumar_Map_Object($b);
         $profiler->stop();
         $profiler->stop();
     }
     return $objects;
 }
コード例 #3
0
ファイル: Unit.php プロジェクト: Toxicat/dolumar
 public static function getFromId($id)
 {
     $id = explode('|', $id);
     $uid = $id[0];
     $village = Dolumar_Players_Village::getFromId($id[1]);
     $race = Dolumar_Races_Race::getFromId($id[2]);
     return self::getUnitFromId($uid, $race, $village);
 }
コード例 #4
0
ファイル: Visits.php プロジェクト: Toxicat/dolumar
 public function getLastVisits($amount = 10)
 {
     $db = Neuron_DB_Database::getInstance();
     $l = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tvillages_visits\n\t\t\tWHERE\n\t\t\t\tv_id = {$this->objProfile->getId()}\n\t\t\tORDER BY\n\t\t\t\tvi_date DESC\n\t\t\tLIMIT\n\t\t\t\t{$amount}\n\t\t");
     $out = array();
     foreach ($l as $v) {
         $out[] = Dolumar_Players_Village::getVillage($v['vi_v_id']);
     }
     return $out;
 }
コード例 #5
0
ファイル: Villageprofile.php プロジェクト: Toxicat/dolumar
 public function getBody()
 {
     $village = Neuron_Core_Tools::getInput('_GET', 'village', 'int');
     $village = Dolumar_Players_Village::getVillage($village);
     $body = '<h2>' . $village->getName() . '</h2>';
     $location = $village->buildings->getTownCenterLocation();
     //$url = ABSOLUTE_URL . '#' . $location[0] . ',' . $location[1];
     $url = $this->getUrl('Playerprofile', array('plid' => $village->getOwner()->getId()));
     header('Location: ' . $url);
     return $body;
 }
コード例 #6
0
ファイル: Village.php プロジェクト: Toxicat/dolumar
 public static function getVillage($id, $syncBattle = NOW, $cronStuff = false, $noStatic = false)
 {
     $in = self::$instances;
     $id = intval($id);
     if (empty($id) || $id == 0) {
         return new Dolumar_Players_DummyVillage();
     }
     $lock = Neuron_Core_Lock::__getInstance();
     if (!defined('DISABLE_STATIC_FACTORY') && !$noStatic) {
         // Initialize the village
         if (!isset($in[$id]) || !$in[$id]->isInitialized) {
             $in[$id] = new Dolumar_Players_Village($id, $cronStuff);
         }
         $village = $in[$id];
     } else {
         $village = new Dolumar_Players_Village($id, $cronStuff);
     }
     $village->setBattleProcessData($syncBattle);
     return $village;
 }
コード例 #7
0
ファイル: Squad.php プロジェクト: Toxicat/dolumar
 public function getCurrentLocation()
 {
     if (!isset($this->oCurrentVillage)) {
         $this->loadData();
         if ($this->data['s_village'] > 0) {
             $this->setCurrentLocation(Dolumar_Players_Village::getVillage($this->data['s_village']));
         } else {
             $this->setCurrentLocation($this->getVillage());
         }
     }
     return $this->oCurrentVillage;
 }
コード例 #8
0
ファイル: Outpost.php プロジェクト: Toxicat/dolumar
 public function canBuildBuilding(Dolumar_Players_Village $village)
 {
     $tc = $village->buildings->getTownCenter();
     $villages = count($village->getOwner()->getVillages());
     if (!$tc) {
         return false;
     }
     $level = $tc->getLevel();
     $max = 1;
     if ($level >= 10) {
         $max++;
     }
     if ($level >= 15) {
         $max++;
     }
     if ($level >= 18) {
         $max++;
     }
     if ($level >= 20) {
         $max += $level - 19;
     }
     return $villages < $max;
 }
コード例 #9
0
ファイル: Units.php プロジェクト: Toxicat/dolumar
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     $data = $this->getRequestData();
     $this->village = Dolumar_Players_Village::getMyVillage($data['vid']);
     // Window settings
     $this->setSize('425px', '300px');
     $this->setAllowOnlyOnce();
     if ($login->isLogin() && $this->village->isFound()) {
         $this->setTitle($text->get('units', 'menu', 'main') . ' (' . Neuron_Core_Tools::output_varchar($this->village->getName()) . ')');
     } else {
         $this->setTitle($text->get('units', 'menu', 'main'));
     }
 }
コード例 #10
0
ファイル: VillageProfile.php プロジェクト: Toxicat/dolumar
 protected function setPlayer()
 {
     $o = $this->getRequestData();
     if (!isset($o['village']) && isset($o[0])) {
         $o['village'] = $o[0];
     } elseif (!isset($o['village'])) {
         $o['village'] = null;
     }
     $village = Dolumar_Players_Village::getVillage($o['village']);
     if ($village) {
         $this->player = $village->getOwner();
         $this->thisVillage = $village;
     }
     $this->setTitle(Neuron_Core_Tools::output_varchar($this->player->getNickname()));
 }
コード例 #11
0
ファイル: Logbook.php プロジェクト: Toxicat/dolumar
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     // Window settings
     $this->setSize('450px', '250px');
     $this->setTitle($text->get('logbook', 'menu', 'main'));
     $this->setClassname('logbook');
     $this->setAllowOnlyOnce();
     // Check for input
     $input = $this->getRequestData();
     if (isset($input['village'])) {
         $this->objVillage = Dolumar_Players_Village::getMyVillage($input['village']);
     } else {
         $this->objVillage = false;
     }
 }
コード例 #12
0
ファイル: Economy.php プロジェクト: Toxicat/dolumar
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     // Window settings
     $this->setSize('400px', '380px');
     $this->setAllowOnlyOnce();
     $data = $this->getRequestData();
     // Construct village
     if (isset($data['vid']) && $login->isLogin()) {
         $this->village = Dolumar_Players_Village::getVillage($data['vid']);
         $this->setTitle($text->get('economy', 'menu', 'main') . ' (' . Neuron_Core_Tools::output_varchar($this->village->getName()) . ')');
     } else {
         $this->village = false;
         $this->setTitle($text->get('economy', 'menu', 'main'));
     }
 }
コード例 #13
0
ファイル: Magic.php プロジェクト: Toxicat/dolumar
 protected function getCastSpellHTML($building)
 {
     $data = $this->getRequestData();
     $input = $this->getInputData();
     $building = $this->village->buildings->getBuilding($building);
     if (!$building instanceof $this->buildingType) {
         $building = false;
     }
     // Let's go for the various stages
     if ($building && isset($data['spell']) && $building->getUnitCount() > 0) {
         $unit = $building->getSpecialUnit();
         $spell = $building->getSpecialUnit()->getEffect($data['spell']);
         if ($spell && ($spell instanceof Dolumar_Effects_Boost || $spell instanceof Dolumar_Effects_Instant)) {
             // That's alright, let's go for the actual thing
             if (isset($data['target'])) {
                 $objTarget = Dolumar_Players_Village::getVillage($data['target']);
                 if ($objTarget) {
                     if ($objTarget->getOwner()->inVacationMode()) {
                         return $this->getChooseTarget($spell, 'vacationmode');
                     } elseif (isset($input['confirm'])) {
                         return $this->doCastSpell($unit, $spell, $objTarget);
                     } else {
                         return $this->getConfirmCast($unit, $spell, $objTarget);
                     }
                 } else {
                     return $this->getChooseTarget($spell);
                 }
             } elseif (!$spell->requiresTarget()) {
                 // Check for confirmation
                 if (isset($input['confirm'])) {
                     return $this->doCastSpell($unit, $spell, null);
                 } else {
                     return $this->getConfirmCast($unit, $spell, null);
                 }
             } else {
                 return $this->getChooseTarget($spell);
             }
         }
     } elseif ($building && $building->getUnitCount() > 0) {
         return $this->getCastSpell($building->getSpecialUnit());
     } elseif ($building) {
         return $this->getOverview();
     } else {
         return '<p>Invalid input: building not found.</p>';
     }
 }
コード例 #14
0
ファイル: Gamelogs.php プロジェクト: Toxicat/dolumar
 public function getBody()
 {
     $player = Neuron_GameServer::getPlayer();
     if (!$player->isModerator()) {
         return '<p>You don\'t have the rights to access the player logs.</p>';
     }
     $page = new Neuron_Core_Template();
     // Let's find the players
     $input = Neuron_Core_Tools::getInput('_GET', 'players', 'varchar');
     $playerids = explode('|', $input);
     $players = array();
     $villages = array();
     $ids = array();
     $i = 0;
     foreach ($playerids as $v) {
         $player = Neuron_GameServer::getPlayer($v);
         if ($player) {
             $players[] = $player;
             $villages = array_merge($villages, $player->getVillages());
             $ids[$player->getId()] = $i;
             $page->addListValue('players', array('key' => $i, 'id' => $player->getId(), 'name' => $player->getName(), 'url' => $this->getUrl('user', array('id' => $player->getId()))));
             $i++;
         }
     }
     $pageid = max(0, intval(Neuron_Core_Tools::getInput('_GET', 'page', 'int', 1)) - 1);
     $objLogs = Dolumar_Players_Logs::getInstance();
     $logs = $objLogs->getLogs($villages, $pageid * 250, 250, 'DESC');
     foreach ($logs as $v) {
         $player = Dolumar_Players_Village::getFromId($v['village'])->getOwner();
         // Check if this is an important log.
         $bImportant = $this->isImportantLog($players, $v);
         $page->addListValue('logs', array('action' => $objLogs->getLogText($v, false), 'date' => date(DATETIME, $v['timestamp']), 'player' => $player->getName(), 'url' => $this->getUrl('user', array('id' => $player->getId())), 'key' => $ids[$player->getId()], 'important' => $bImportant ? 'important' : null));
     }
     $page->set('page', $pageid + 1);
     if (count($logs) == 250) {
         $page->set('nextpage', $this->getUrl('gamelogs', array('players' => $input, 'page' => $pageid + 2)));
     }
     if ($pageid > 0) {
         $page->set('previouspage', $this->getUrl('gamelogs', array('players' => $input, 'page' => $pageid)));
     }
     return $page->parse('pages/admin/gamelogs.phpt');
 }
コード例 #15
0
ファイル: VillageOverview.php プロジェクト: Toxicat/dolumar
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     // Window settings
     $this->setSize('250px', '350px');
     $data = $this->getRequestData();
     if (!isset($data['vid'])) {
         $data['vid'] = 0;
     }
     $this->village = Dolumar_Players_Village::getMyVillage($data['vid']);
     // Window settings
     if ($login->isLogin() && $this->village->isFound() && $this->village->getOwner()->getId() == $login->getUserId()) {
         $this->setTitle($text->get('overview', 'menu', 'main') . ' (' . Neuron_Core_Tools::output_varchar($this->village->getName()) . ')');
     } else {
         $this->setTitle($text->get('overview', 'menu', 'main'));
     }
     $this->setAllowOnlyOnce();
     $this->setClassName('overview');
 }
コード例 #16
0
ファイル: Multis.php プロジェクト: Toxicat/dolumar
 public function getBody()
 {
     $timeframe = Neuron_Core_Tools::getInput('_GET', 'timeframe', 'int', 60 * 60 * 48);
     $page = new Neuron_Core_Template();
     $page->set('timeframe', $timeframe);
     $objLogs = Dolumar_Players_Logs::getInstance();
     $objLogs->setTimeInterval(NOW - $timeframe, NOW);
     $pageid = Neuron_Core_Tools::getInput('_GET', 'page', 'int', 1);
     $limit = Neuron_Core_Tools::splitInPages($page, $objLogs->getSuspiciousLogsCounter(), $pageid, self::SUSPICIOUS_TRANSACTIONS_PERPAGE, 7, array('timeframe' => $timeframe), 'multis');
     //print_r ($limit);
     //$logs = $objLogs->getSuspiciousLogs ();
     $logs = $objLogs->getSuspiciousLogs($limit['start'], $limit['perpage'], 'DESC');
     foreach ($logs as $v) {
         $player = Dolumar_Players_Village::getFromId($v['village'])->getOwner();
         $page->addListValue('logs', array('action' => $objLogs->getLogText($v, false), 'date' => date(DATETIME, $v['timestamp']), 'player' => $player->getDisplayName()));
     }
     // Output the shizzle
     $html = $page->parse('dolumar/pages/admin/multis/dangeroustransactions.phpt');
     $html .= parent::getBody();
     return $html;
 }
コード例 #17
0
ファイル: OpenPortal.php プロジェクト: Toxicat/dolumar
 public function prepare()
 {
     // Fetch a random target
     $networth = $this->getVillage()->getScore();
     $minscore = floor($networth * 0.75);
     $maxscore = ceil($networth * 1.25);
     $db = Neuron_DB_Database::getInstance();
     $myclanlist = "";
     foreach ($this->getVillage()->getOwner()->getClans() as $v) {
         $myclanlist .= $v->getId() . ",";
     }
     $myclanlist = substr($myclanlist, 0, -1);
     $chk = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tvillages v\n\t\t\tLEFT JOIN\n\t\t\t\tn_players p USING(plid)\n\t\t\tLEFT JOIN\n\t\t\t\tclan_members cm ON cm.plid = p.plid AND cm.c_id IN ({$myclanlist})\n\t\t\tWHERE\n\t\t\t\tv.networth > {$minscore} AND\n\t\t\t\tv.networth < {$maxscore} AND\n\t\t\t\tv.plid != {$this->getVillage()->getOwner()->getId()} AND\n\t\t\t\tv.isActive = 1 AND\n\t\t\t\tp.startVacation IS NULL AND\n\t\t\t\tcm.c_id IS NULL\n\t\t\tORDER BY\n\t\t\t\tRAND()\n\t\t\tLIMIT\n\t\t\t\t1\n\t\t");
     //die ($db->getLastQuery ());
     if (count($chk) > 0) {
         $village = Dolumar_Players_Village::getVillage($chk[0]['vid']);
         $this->setTarget($village);
     } else {
         $this->setCastable(false);
         $this->setError(Dolumar_Effects_Effect::ERROR_NO_TARGET_FOUND);
     }
 }
コード例 #18
0
ファイル: Building.php プロジェクト: Toxicat/dolumar
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $db = Neuron_Core_Database::__getInstance();
     // Window settings
     $this->setSize('315px', '300px');
     $o = $this->getRequestData();
     $l = $db->getDataFromQuery($db->customQuery("\n\t\t\tSELECT\n\t\t\t\tmap_buildings.*, villages.race\n\t\t\tFROM\n\t\t\t\tmap_buildings\n\t\t\tLEFT JOIN\n\t\t\t\tvillages ON map_buildings.village = villages.vid\n\t\t\tWHERE\n\t\t\t\tmap_buildings.bid = '" . $db->makeSafe($o['bid']) . "'\n\t\t\t\tAND (destroyDate = 0 OR destroyDate > " . NOW . ")\n\t\t"));
     if (count($l) == 1) {
         $race = Dolumar_Races_Race::getRace($l[0]['race']);
         $this->building = Dolumar_Buildings_Building::getBuilding($l[0]['buildingType'], $race, $l[0]['xas'], $l[0]['yas']);
         if ($l[0]['village']) {
             $this->building->setVillage(Dolumar_Players_Village::getVillage($l[0]['village']));
         }
         $this->building->setWindow($this);
         $this->building->setData($l[0]['bid'], $l[0]);
         $this->setTitle($this->getTitle());
     } else {
         $this->building = false;
         $this->setTitle('Oh-Ow...');
     }
 }
コード例 #19
0
ファイル: Ranking.php プロジェクト: Toxicat/dolumar
 public function getVillageRanking()
 {
     $text = Neuron_Core_Text::__getInstance();
     $db = Neuron_Core_Database::__getInstance();
     $input = $this->getInputData();
     $page = new Neuron_Core_Template();
     $text->setFile('ranking');
     $text->setSection('ranking');
     $page->set('title', $text->get('villageRating'));
     $page->set('village', $text->get('village'));
     $page->set('value', $text->get('value'));
     $data = $this->getRequestData();
     $perPage = 25;
     $myDefaultPage = 1;
     if (isset($data['village'])) {
         $village = Dolumar_Players_Village::getVillageFromId($data['village']);
         $myVillageId = $data['village'];
         $myRank = $village->getRank();
         $myDefaultPage = floor($myRank[0] / $perPage) + 1;
     } else {
         $myVillageId = 0;
         // Load "main village" from this user
         $myself = Neuron_GameServer::getPlayer();
         if ($myself) {
             $village = $myself->getMainVillage();
             if ($village) {
                 $myVillageId = $village->getId();
                 $myRank = $village->getRank();
                 $myDefaultPage = floor($myRank[0] / $perPage) + 1;
             }
         }
     }
     $currentPage = isset($input['page']) ? $input['page'] : $myDefaultPage;
     $limit = Neuron_Core_Tools::splitInPages($page, Dolumar_Players_Ranking::countRanking(), $currentPage, $perPage, 6);
     $l = Dolumar_Players_Ranking::getRanking($limit['start'], $limit['perpage']);
     // Get my villages
     $myself = Neuron_GameServer::getPlayer();
     if ($myself && $myself->isPremium()) {
         $distances = $myself->getVillages();
     } else {
         $distances = array();
     }
     $i = $limit['start'];
     foreach ($l as $v) {
         $i++;
         // Calcualte the distances
         $w_distances = array();
         foreach ($distances as $k => $vv) {
             $w_distances[$k] = Neuron_Core_Tools::output_distance(Dolumar_Map_Map::getDistanceBetweenVillages($vv, $v), true, true);
         }
         $page->addListValue('ranking', array($i, Neuron_Core_Tools::output_varchar($v->getName()), $v->getId(), $v->getNetworth(), $v->getId() == $myVillageId, $w_distances));
         //$v->__destruct ();
     }
     // Add the footnote
     $t_distances = array();
     foreach ($distances as $k => $v) {
         $t_distances[$k] = Neuron_Core_Tools::output_varchar($v->getName());
     }
     $page->set('distances', $t_distances);
     return $page->parse('ranking/ranking.tpl');
 }
コード例 #20
0
ファイル: DummyVillage.php プロジェクト: Toxicat/dolumar
 public function __construct($race = null)
 {
     parent::__construct(null);
     $this->race = $race;
 }
コード例 #21
0
ファイル: Clan.php プロジェクト: Toxicat/dolumar
 /**
  *	Get all clan portal buildings
  */
 public function getClanportals()
 {
     $db = Neuron_DB_Database::getInstance();
     $villages = array();
     foreach ($this->getMembers() as $player) {
         foreach ($player->getVillages() as $v) {
             $villages[] = $v->getId();
         }
     }
     $list = "(" . implode($villages, ",") . ")";
     $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tmap_buildings\n\t\t\tWHERE\n\t\t\t\tbuildingType = 61 AND\n\t\t\t\tvillage IN {$list} AND\n\t\t\t\t(destroyDate = 0 OR destroyDate > " . NOW . ")\n\t\t");
     $out = array();
     foreach ($data as $v) {
         $village = Dolumar_Players_Village::getFromId($v['village']);
         $building = Dolumar_Buildings_Building::getFromId($v['bid'], $village->getRace(), $v['xas'], $v['yas']);
         $building->setData($v['bid'], $v);
         $building->setVillage($village);
         $out[] = $building;
     }
     return $out;
 }
コード例 #22
0
ファイル: Speedup.php プロジェクト: Toxicat/dolumar
 private function getSpeedUpTraining($data)
 {
     $text = Neuron_Core_Text::getInstance();
     $inputData = $this->getInputData();
     $village = isset($data['village']) ? $data['village'] : null;
     $unit = isset($data['unit']) ? $data['unit'] : null;
     $id = isset($data['order']) ? $data['order'] : null;
     $village = Dolumar_Players_Village::getFromId($village);
     $troop = Dolumar_Units_Unit::getFromId($unit);
     $order = $village->units->getTrainingStatus($id);
     if (!$troop || !$id || !$village || !$order) {
         return '<p>Order not found.</p>';
     }
     $price = PREMIUM_SPEEDUP_TRAINING_PRICE;
     $unit = PREMIUM_SPEEDUP_TRAINING_UNIT;
     if (isset($inputData['duration'])) {
         $selected = abs(intval($inputData['duration']));
         $desc = Neuron_Core_Tools::putIntoText($text->get('confdesc_training', 'speedup', 'statusbar'), array('unit' => $troop->getName(), 'amount' => Neuron_Core_Tools::getDurationText($selected * $unit)));
         return $this->getConfirm($price, $unit, $selected, $desc);
     }
     $time = $order['timeLeft'];
     return $this->getSpeedUpHTML('training', $time, $price, $unit);
 }
コード例 #23
0
ファイル: Logs.php プロジェクト: Toxicat/dolumar
 private function getUnitLog($row)
 {
     $objVillage = Dolumar_Players_Village::getVillage($row['l_vid']);
     $unitname = !empty($row['unitName']) ? $row['unitName'] : $row['l_subId'];
     $objUnit = Dolumar_Units_Unit::getUnitFromName($unitname, $objVillage->getRace(), $objVillage);
     if ($objUnit) {
         $unitname = $objUnit->getName();
     }
     return array('unit' => $unitname, 'amount' => $row['lt_amount']);
 }
コード例 #24
0
ファイル: Battle.php プロジェクト: Toxicat/dolumar
 public function processInput()
 {
     $data = $this->getRequestData();
     $input = $this->getInputData();
     if ($this->village->isFound()) {
         if (isset($input['target'])) {
             $data['target'] = $input['target'];
             $this->updateRequestData(array('vid' => $this->village->getId(), 'target' => intval($input['target'])));
         }
         if (!isset($data['target'])) {
             $this->updateContent();
         } else {
             $target = Dolumar_Players_Village::getVillage($data['target']);
             if ($target->isFound() && $target->getId() != $this->village->getId()) {
                 $this->processChallengeInput($target);
             } elseif ($target->isFound()) {
                 $this->updateContent($this->getChallenge($target->getId(), 'ownVillage'));
             } else {
                 $this->updateContent($this->getChallenge($target->getId(), 'villageNotFound'));
             }
         }
     }
 }
コード例 #25
0
ファイル: Market.php プロジェクト: Toxicat/dolumar
 private function getTradeContent()
 {
     $text = Neuron_Core_Text::__getInstance();
     // Can we do it already?
     if ($this->countMaximumTransfers() <= $this->countOutgoingTransfers()) {
         return $this->getMarketBusy();
     }
     if (isset($this->aInput['target'])) {
         $objVillage = Dolumar_Players_Village::getFromId($this->aInput['target']);
         if ($objVillage) {
             $this->objTarget = $objVillage;
             if ($this->objTarget->equals($this->getVillage())) {
                 $msgs[] = array($text->get('error_ownvillage', 'market', 'buildings'), false);
                 return $this->getChooseTarget($msgs);
             }
             /*
             if (!$this->isValidTarget ($objVillage))
             {
             	return $this->getChooseTarget 
             	(
             		array
             		(
             			array 
             			(
             				Neuron_Core_Tools::putIntoText
             				(
             					$text->get ($this->sError, 'market', 'buildings', $this->sError), 
             					array
             					(
             						'percentage' => self::MAX_PERCENTAGE
             					)
             				),
             				false
             			)
             		)
             	);
             }
             */
             // Check for selected resources
             $resources = $this->getResourcesFromInput();
             $runes = $this->getRunesFromInput();
             $equipment = $this->getEquipmentFromInput();
             $confirmed = isset($this->aInput['confirmed']);
             if ($this->isFilled($resources) || $this->isFilled($runes) || count($equipment) > 0) {
                 if ($confirmed) {
                     return $this->getDonateResources($objVillage, $resources, $runes, $equipment);
                 } else {
                     return $this->getConfirmDonation($objVillage, $resources, $runes, $equipment);
                 }
             } else {
                 return $this->getChooseAmount($objVillage);
             }
         }
     }
     return $this->getChooseTarget();
 }
コード例 #26
0
ファイル: Map.php プロジェクト: Toxicat/dolumar
 public static function getSnapshot($x, $y, $width, $height, $zoom)
 {
     $stats = Neuron_Core_Stats::__getInstance();
     $fZoom = $zoom / 100;
     // Make a bigger image
     $width = $width / $fZoom;
     $height = $height / $fZoom;
     $floatZoom = 1;
     $tileSizeX = 200 * $floatZoom;
     $tileSizeY = $tileSizeX / 2;
     $halfTileX = $tileSizeX / 2;
     $halfTileY = $tileSizeY / 2;
     $offsetX = ceil($tileSizeX / 2);
     $offsetY = ceil($tileSizeY / 2);
     $loadExtra = 1;
     $switchpoint = max(ceil($width / ($tileSizeX * 1)), ceil($height / $tileSizeY));
     $im = imagecreatetruecolor($width, $height);
     list($startX, $startY) = self::getStartposition($x, $y, $width, $height, $tileSizeX, $tileSizeY);
     $locations = array(array($startX + $switchpoint / 2, $startY - $switchpoint / 2));
     // Load buildings from SQL
     $buildingSQL = Dolumar_Map_Map::getBuildingsFromLocations($locations, $switchpoint + 15);
     $buildings = array();
     foreach ($buildingSQL as $buildingV) {
         $race = Dolumar_Races_Race::getRace($buildingV['race']);
         $b = Dolumar_Buildings_Building::getBuilding($buildingV['buildingType'], $race, $buildingV['xas'], $buildingV['yas']);
         $village = Dolumar_Players_Village::getVillage($buildingV['village']);
         $b->setVillage($village);
         $b->setData($buildingV['bid'], $buildingV);
         $buildings[floor($buildingV['xas'])][floor($buildingV['yas'])][] = $b;
     }
     for ($i = 0 - $loadExtra; $i <= $switchpoint * 2; $i++) {
         if ($i > $switchpoint) {
             $offset = ($i - $switchpoint + 1) * 2;
         } else {
             $offset = 0;
         }
         $colStart = 0 - $i + $offset - $loadExtra;
         $colEnd = $i - $offset + $loadExtra + 1;
         //$output['regions'][$sQ]['tiles'][$i] = array ();
         $tx = $startX + $i;
         for ($j = $colStart; $j < $colEnd; $j++) {
             $ty = $startY - $j;
             $px = ($i - $j) * $offsetX;
             $py = ($i + $j) * $offsetY;
             // Check for building
             $hasBuildings = isset($buildings[$tx]) && isset($buildings[$tx][$ty]);
             $location = Dolumar_Map_Location::getLocation($tx, $ty, $hasBuildings);
             $image = $location->getImage();
             $sImagePath = IMAGE_PATH . 'tiles/' . $image['image'] . '.gif';
             //die ($sImagePath);
             self::drawSnapshotImage($im, $sImagePath, $px, $py, $floatZoom);
             //checkBuildings ($buildings, $sQ, $i, $j, $tx, $ty);
             if ($hasBuildings) {
                 foreach ($buildings[$tx][$ty] as $building) {
                     $short = $building->getIsoImage();
                     $url = $building->getImagePath();
                     $offset = $building->getTileOffset();
                     $fakeurl = IMAGE_PATH . 'sprites/' . $short . '.png';
                     //echo "---\n";
                     //echo $url . "\n";
                     //echo $fakeurl . "\n";
                     $oi = $i + $offset[0];
                     $oj = $j + $offset[1];
                     $pox = round(($oi - $oj) * floor($tileSizeX / 2));
                     $poy = round(($oi + $oj) * floor($tileSizeY / 2));
                     self::drawSnapshotImage($im, $url, $pox + $stats->get('offsetx', $short, 'images', 0) * $floatZoom, $poy + $stats->get('offsety', $short, 'images', 0) * $floatZoom, $floatZoom, false);
                 }
             }
         }
     }
     // Resize the image
     $newwidth = $width * $fZoom;
     $newheight = $height * $fZoom;
     $newimg = imagecreatetruecolor($newwidth, $newheight);
     imagecopyresampled($newimg, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
     return $newimg;
 }
コード例 #27
0
 public function getHTML($error = null)
 {
     $page = new Neuron_Core_Template();
     $page->setTextSection('chooseTarget', 'main');
     $page->set('canTargetSelf', $this->bTargetSelf);
     $page->set('vid', $this->objVillage->getId());
     // Return action
     if (isset($this->sReturnAction)) {
         $page->set('returnUrl', $this->sReturnAction);
         $page->set('returnText', $this->sReturnText);
     }
     $sQuery = null;
     if (isset($this->aInput['sVillageName'])) {
         $sQuery = $this->aInput['sVillageName'];
         unset($this->aInput['sVillageName']);
     }
     $page->set('input', $this->aInput);
     $page->set('query', Neuron_Core_Tools::output_varchar($sQuery));
     // Fetch all troops
     if (!empty($sQuery)) {
         $db = Neuron_Core_Database::__getInstance();
         $page->set('hasSearched', true);
         $l = $db->getDataFromQuery($db->customQuery("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tvillages\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tvname LIKE '%" . $db->escape($sQuery) . "%'\n\t\t\t\t\t\tAND isActive = 1\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tFIELD(vname, '" . $db->escape($sQuery) . "', vname),\n\t\t\t\t\t\tvname ASC\n\t\t\t\t\tLIMIT 10\n\t\t\t\t"));
         if (count($l) > 0) {
             foreach ($l as $v) {
                 $village = Dolumar_Players_Village::getVillage($v['vid'], false);
                 $village->setData($v);
                 $tc = $village->buildings->getTownCenter();
                 if ($tc) {
                     $loc = $tc->getLocation();
                     $page->addListValue('results', array('id' => $village->getId(), 'name' => Neuron_Core_Tools::output_varchar($village->getName()), 'location' => $loc[0] . ',' . $loc[1]));
                 }
             }
         }
     } elseif ($this->bShowTargets) {
         $db = Neuron_DB_Database::__getInstance();
         // Popular targets
         /*
         $l = $db->getDataFromQuery
         (
         	$db->customQuery
         	("
         		SELECT
         			l_vid,
         			villages.*
         		FROM
         			game_log
         		LEFT JOIN
         			villages ON game_log.l_vid = villages.vid
         		WHERE
         			(l_action = 'attack' OR l_action = 'defend') 
         			AND l_vid != ".$this->objVillage->getId ()."
         			AND l_subId = ".$this->objVillage->getId ()."
         			AND isActive = 1
         		GROUP BY
         			l_vid
         		ORDER BY
         			l_date ASC
         		LIMIT 10
         	")
         );
         */
         $l = $this->objVillage->visits->getLastVisits();
         if (count($l) > 0) {
             foreach ($l as $village) {
                 // Only add active villages
                 if ($village->isActive()) {
                     $tc = $village->buildings->getTownCenter();
                     if ($tc) {
                         $loc = $tc->getLocation();
                         $page->addListValue('results', array('id' => $village->getId(), 'name' => Neuron_Core_Tools::output_varchar($village->getName()), 'location' => $loc[0] . ',' . $loc[1]));
                     }
                 }
             }
         }
     }
     if (isset($error)) {
         $page->set('external_error', $error);
     }
     return $page->parse('neuron/structure/chooseTarget.phpt');
 }
コード例 #28
0
ファイル: Village.php プロジェクト: Toxicat/dolumar
 protected function getNewObject($id)
 {
     return Dolumar_Players_Village::getVillage($id);
 }
コード例 #29
0
         }
     }
     break;
 case 'phpinfo':
     phpinfo();
     exit;
     break;
 case 'getlogs':
     $id = Neuron_Core_Tools::getInput('_GET', 'id', 'int', isset($sInputs[2]) ? $sInputs[2] : 0);
     $start = Neuron_Core_Tools::getInput('_GET', 'start', 'int', 0);
     $objLogs = Dolumar_Players_Logs::__getInstance();
     $output['content'] = $objLogs->getLogs($id, $start, 1000000);
     break;
 case 'getvillageinfo':
     $id = Neuron_Core_Tools::getInput('_GET', 'id', 'int', 0);
     $village = Dolumar_Players_Village::getVillage($id);
     if ($village && $village->isFound()) {
         $output['content'] = $village->getAPIData();
     }
     break;
 case 'getplayerinfo':
     $id = Neuron_Core_Tools::getInput('_GET', 'id', 'int', 0);
     $player = Neuron_GameServer::getPlayer($id);
     if ($player && $player->isFound()) {
         $output['content'] = $player->getAPIData();
     }
     break;
 case 'getonlineplayers':
     $start = Neuron_Core_Tools::getInput('_GET', 'start', 'int', 0);
     $players = Neuron_GameServer::getServer()->getOnlineUser($start * 250, 250);
     $output['content'] = array();
コード例 #30
0
<?php

$village1 = Neuron_Core_Tools::getInput('_GET', 'village1', 'int');
$village2 = Neuron_Core_Tools::getInput('_GET', 'village2', 'int');
$v1 = Dolumar_Players_Village::getVillage($village1);
$v2 = Dolumar_Players_Village::getVillage($village2);
echo 'Calculating distance between ' . $v1->getName() . ' to ' . $v2->getName() . '<br />';
$l1 = $v1->buildings->getTownCenterLocation();
$l2 = $v2->buildings->getTownCenterLocation();
$distance = Dolumar_Map_Map::getDistanceBetweenVillages($v1, $v2);
$straight = Dolumar_Map_Map::calculateDistance($l1[0], $l1[1], $l2[0], $l2[1]);
$profiler = Neuron_Profiler_Profiler::getInstance();
echo '<h2>Profiler</h2>';
echo '<pre>';
echo $profiler;
echo '</pre>';
echo '<p>Distance: <strong>' . $distance . '</strong><br />';
echo 'Straight line distance: <strong>' . $straight . '</strong></p>';