示例#1
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;
 }
示例#2
0
 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;
 }
示例#3
0
 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;
 }
示例#4
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;
 }
示例#5
0
 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()));
 }
示例#6
0
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     $data = $this->getRequestData();
     $this->village = Dolumar_Players_Village::getVillage($data['vid']);
     // Window settings
     $this->setSize('325px', '275px');
     $this->setAllowOnlyOnce();
     if ($login->isLogin() && $this->village->isFound()) {
         $this->setTitle($text->get('squads', 'menu', 'main') . ' (' . Neuron_Core_Tools::output_varchar($this->village->getName()) . ')');
     } else {
         $this->setTitle($text->get('squads', 'menu', 'main'));
     }
     $this->setClassName('squads');
 }
示例#7
0
 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'));
     }
 }
示例#8
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>';
     }
 }
示例#9
0
 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...');
     }
 }
示例#10
0
 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);
     }
 }
<?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>';
示例#12
0
 protected function getNewObject($id)
 {
     return Dolumar_Players_Village::getVillage($id);
 }
示例#13
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;
 }
示例#14
0
 public static function cleanServer()
 {
     $db = Neuron_Core_Database::__getInstance();
     $log = array();
     // Kill players
     $last = Neuron_Core_Tools::timestampToMysqlDatetime(time() - 60 * 60 * 24 * 45);
     $l = $db->select('n_players', array('plid', 'killCounter'), "lastRefresh < '" . $last . "' AND isPlaying = 1");
     foreach ($l as $v) {
         if ($v['killCounter'] < 5) {
             $db->update('n_players', array('killCounter' => '++'), "plid = '" . $v['plid'] . "'");
         } else {
             // Kill!
             $player = Neuron_GameServer::getPlayer($v['plid']);
             if (!$player->isModerator()) {
                 $player->doResetAccount();
                 /*
                 $log[] = array
                 (
                 	'action' => 'reset',
                 	'subject' => 'account',
                 	'name' => $player->getNickname ()
                 );
                 */
                 $player->__destruct();
             }
         }
     }
     // Kill villages
     $last = Neuron_Core_Tools::timestampToMysqlDatetime(time() - 60 * 60 * 24 * 5);
     //$last = Neuron_Core_Tools::timestampToMysqlDatetime (time ());
     $l = $db->select('villages', array('vid'), "isActive = '0' AND (removalDate < '{$last}' OR removalDate IS NULL)");
     foreach ($l as $v) {
         $village = Dolumar_Players_Village::getVillage($v['vid'], false, true, true);
         $village->destroyVillage();
         $village->__destruct();
     }
     // Remove old login data (2 weeks old)
     $rem = $db->remove('n_login_log', "l_datetime < '" . date('Y-m-d H:i:s', time() - 60 * 60 * 24 * 7 * 2) . "'");
     $log[] = "Removed " . $rem . " login logs.\n";
     // Remove old game log data (2 months old)
     //$db->remove ('game_log', "l_date < '".date ('Y-m-d H:i:s', time () - 60*60*31*2)."'");
     // Remove old battle reports (2 months old)
     $rem = $db->remove('battle_report', "fightDate < '" . (time() - 60 * 60 * 24 * 31 * 2) . "'");
     $log[] = "Removed " . $rem . " battle reports.\n";
     return $log;
 }
示例#15
0
 private function loadCraftingCounters($vilsId)
 {
     $db = Neuron_Core_Database::__getInstance();
     $l = $db->select('villages_items', array('*'), "i_endCraft > '" . time() . "' {$vilsId}");
     $text = Neuron_Core_Text::getInstance();
     $text->setSection('status', 'statusbar');
     foreach ($l as $v) {
         $village = Dolumar_Players_Village::getVillage($v['vid']);
         $equipment = Dolumar_Players_Equipment::getFromId($v['i_itemId']);
         if ($equipment) {
             $txt = Neuron_Core_Tools::putIntoText($text->get('crafting'), array('amount' => $v['i_amount'], 'equipment' => $equipment->getName($v['i_amount'] > 1)));
         } else {
             $txt = '*** equipment not found: ' . $v['i_itemId'] . ' ***';
         }
         $this->addCounter($v['i_endCraft'], $village, $txt, 'items');
     }
 }
示例#16
0
 public function setData($data)
 {
     if (!isset($data['vid'])) {
         throw new Exception('Wrong battle data set: ' . print_r($data, true));
     }
     $this->data = $data;
     $fightdate = min(NOW, $data['fightDate']);
     $a = Dolumar_Players_Village::getVillage($data['vid'], $fightdate, false, true);
     $d = Dolumar_Players_Village::getVillage($data['targetId'], $fightdate, false, true);
     $this->attackingVillage = $a;
     $a->processBattles();
     $this->defendingVillage = $d;
     $d->processBattles();
 }
<?php

$villageid = Neuron_Core_Tools::getInput('_GET', 'village', 'int');
$targetid = Neuron_Core_Tools::getInput('_GET', 'target', 'int');
$village = Dolumar_Players_Village::getVillage($villageid);
$target = Dolumar_Players_Village::getVillage($targetid);
if ($villageid && $targetid && $village && $target) {
    echo '<pre>';
    $percentage = Dolumar_Battle_Battle::getMaxStolenRunesPercentage($target, true);
    echo '100% victory results in ' . $percentage . '% stolen runes.';
    echo '</pre>';
    echo '<pre>';
    $clanlose = Dolumar_Battle_Battle::didClanAttackTargetEarlier($village, $target);
    if ($clanlose) {
        echo "Target clan will lose honour.\n";
    } else {
        echo "Target clan will not lose honour.\n";
    }
    echo '</pre>';
} else {
    echo '<p>Please provide village and target parameter</p>';
}
 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');
 }
<?php

$village = Dolumar_Players_Village::getVillage(Neuron_Core_Tools::getInput('_GET', 'village', 'int'));
$village->processBattles();
示例#20
0
 public function getVillages($syncBattles = true)
 {
     if (!isset($this->villages)) {
         //$db = Neuron_Core_Database::__getInstance ();
         $db = Neuron_DB_Database::getInstance();
         $vs = $db->query("\n\t\t\t\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\tvillages\n\t\t\t\tWHERE\n\t\t\t\t\tplid = {$this->getId()} AND isActive = 1\n\t\t\t");
         $o = array();
         $i = 0;
         foreach ($vs as $v) {
             $o[$i] = Dolumar_Players_Village::getVillage($v['vid'], $syncBattles ? NOW : false);
             $o[$i]->setData($v);
             $i++;
         }
         $this->villages = $o;
     }
     return $this->villages;
 }
示例#21
0
 public function getVillageForced()
 {
     try {
         $village = $this->getVillage();
     } catch (Neuron_Core_Error $e) {
         $village = Dolumar_Players_Village::getVillage($this->data['village']);
     }
     return $village;
 }
示例#22
0
 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'));
             }
         }
     }
 }
示例#23
0
 public function getUnits($objVillage = null)
 {
     $this->loadData();
     // Fetch attackers & defenders
     $log = explode('&', $this->data['fightLog']);
     $units = array();
     $units['attacking'] = explode(';', $log[0]);
     if (isset($log[1])) {
         $units['defending'] = explode(';', $log[1]);
     } else {
         $units['defending'] = array();
     }
     // Loop trough units
     $out = array();
     // Filter for defender (info)
     $disabled = array();
     /*
     
     		if
     		(
     			!(
     				$this->fullReport ||
     				(
     					is_object ($objVillage) && 
     					$objVillage->getId () == $this->getDefender ()->getId ()
     				) ||
     				$this->getVictory () > 0.1
     			)
     		)
     		{
     			$disabled['defending'] = true;
     		}
     */
     foreach ($units as $teamKey => $team) {
         $out[$teamKey] = array();
         $distinct = array();
         if (isset($disabled[$teamKey])) {
             $out[$teamKey] = false;
         } else {
             foreach ($team as $v) {
                 $l = explode(':', $v);
                 if (count($l) >= 4) {
                     $vil = Dolumar_Players_Village::getVillage($l[1]);
                     //$race = $vil->getRace ();
                     $race = Dolumar_Races_Race::getFromId($l[2]);
                     $key = $l[0] . '_' . $race->getName();
                     $log = $key . ": ";
                     if (!isset($distinct[$key])) {
                         $distinct[$key] = count($out[$teamKey]);
                         $unit = Dolumar_Units_Unit::getUnitFromId($l[0], $race, $vil);
                         $out[$teamKey][$distinct[$key]] = array('unit' => $unit, 'amount' => $l[3], 'died' => $l[4]);
                         $log .= "init";
                     } else {
                         $out[$teamKey][$distinct[$key]]['amount'] += $l[3];
                         $out[$teamKey][$distinct[$key]]['died'] += $l[4];
                         $log .= "update";
                     }
                 }
             }
         }
     }
     return $out;
 }
示例#24
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']);
 }
示例#25
0
 public static function searchVillage($sName, $iStart = 0, $iLength = 10)
 {
     $db = Neuron_Core_Database::__getInstance();
     $l = $db->getDataFromQuery($db->customQuery("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tvillages\n\t\t\tWHERE\n\t\t\t\tvname LIKE '" . $db->escape($sName) . "'\n\t\t\tLIMIT\n\t\t\t\t{$iStart}, {$iLength}\n\t\t"));
     $o = array();
     $i = 0;
     foreach ($l as $v) {
         $o[$i] = Dolumar_Players_Village::getVillage($v['vid'], false);
         $o[$i]->setData($v);
     }
     return $o;
 }
示例#26
0
 public function build($village, $x, $y, $owner = null, $race = null)
 {
     $db = Neuron_Core_Database::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     // We'll have to create a village
     if ($village != null) {
         $owner = $village->getOwner();
         $race = $village->getRace();
     }
     if (!empty($owner)) {
         // Add new Village
         // Load start resources
         $data = $this->getCapacity();
         //$name = $owner->getNickname () . $text->get ('village', 'main', 'main');
         $name = Neuron_Core_Tools::putIntoText($text->get('playervillage', 'main', 'main'), array('player' => $owner->getNickname()));
         // Count the existing villages
         $villages = count($owner->getVillages());
         if ($villages >= 1) {
             $name .= ' ' . ($villages + 1);
         }
         // Insert other datas.
         $data['vname'] = $name;
         $data['plid'] = $owner->getId();
         $data['race'] = $race->getId();
         $vid = $db->insert('villages', $data);
         $village = Dolumar_Players_Village::getVillage($vid);
         $building = parent::build($village, $x, $y, false);
         $owner->reloadVillages();
         return $building;
         //return array (true, $vid);
     } else {
         return false;
         return array(false, null);
     }
 }
示例#27
0
 private function commandMoveUnit($building, $unit)
 {
     $input = $this->getInputData();
     $id = isset($input['target']) ? intval($input['target']) : null;
     if ($id > 0 && $id != $unit->getLocation()->getId()) {
         // Calculate distance & duration
         $target = Dolumar_Players_Village::getVillage($id);
         if (!$target) {
             return '<p>Invalid input: target village not found.</p>';
         }
         if (isset($input['confirm'])) {
             $page = new Neuron_Core_Template();
             $page->setTextSection('moveUnit', 'thievery');
             $page->set('input', array('building' => $building->getId()));
             // Move the bloody unit
             $unit->moveUnit($target);
             return $page->parse('thieves/doneMoving.phpt');
         } else {
             $page = new Neuron_Core_Template();
             $page->setTextSection('moveUnit', 'thievery');
             $distance = Dolumar_Map_Map::getDistanceBetweenVillages($unit->getLocation(), $target);
             // Calculate duration
             $duration = $unit->getTravelDuration($distance);
             $page->set('input', array_merge($input, array('confirm' => 'true')));
             $page->set('distance', Neuron_Core_Tools::output_distance($distance));
             $page->set('duration', Neuron_Core_Tools::getDuration($duration));
             return $page->parse('thieves/moveThief.phpt');
         }
     } else {
         $structure = new Neuron_Structure_ChooseTarget($this->getInputData(), $this->village, true, true);
         $structure->setReturnData(array('building' => $building->getId()));
         return $structure->getHTML();
     }
 }
示例#28
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();
示例#29
0
 public static function getRankingFromOpenAuth($authType, $authUIDs = array(), $startPoint = 0, $length = 9)
 {
     $db = Neuron_Core_Database::__getInstance();
     if (!is_array($authUIDs)) {
         return array();
     } else {
         $where = "p.authType = '" . $db->escape($authType) . "' AND (FALSE";
         // Actual where values:
         foreach ($authUIDs as $v) {
             $where .= " OR authUID = '" . $db->escape($v) . "'";
         }
         $where .= ')';
         $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tv.*\n\t\t\t\tFROM\n\t\t\t\t\tn_players p\n\t\t\t\tRIGHT JOIN\n\t\t\t\t\tvillages v ON p.plid = v.plid\n\t\t\t\tWHERE\n\t\t\t\t\t{$where}\n\t\t\t\tORDER BY\n\t\t\t\t\tv.networth DESC, v.vid DESC\n\t\t\t\tLIMIT {$startPoint}, {$length}\n\t\t\t";
         $l = $db->getDataFromQuery($db->customQuery($query));
         $o = array();
         foreach ($l as $v) {
             $village = Dolumar_Players_Village::getVillage($v['vid'], false);
             $village->setData($v);
             $o[] = $village;
         }
         //customMail ('*****@*****.**', 'test', print_r ($o, true));
         return $o;
     }
 }