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; }
public static function getTechnology($technology, $objRace = null) { $oCost = array('wood' => 1000); $duration = 60 * 5; $stats = Neuron_Core_Stats::__getInstance(); $cost = $stats->getSection($technology, 'technology'); // Only fetch the 6 resources $o = array(); $ini = array('gold', 'grain', 'wood', 'stone', 'iron', 'gems'); foreach ($ini as $v) { if (isset($cost[$v])) { $o[$v] = $cost[$v]; } } if (count($o) != 0) { $oCost = $o; } // Check for duration if (isset($cost['duration'])) { $duration = $cost['duration']; } // Fetch requirements $requirements = array(); $requirements['level'] = isset($cost['level']) ? intval($cost['level']) : 0; // Check for other requirements $requirements['technologies'] = array(); if (isset($cost['requires'])) { $reqs = explode(',', $cost['requires']); foreach ($reqs as $v) { $requirements['technologies'][] = trim($v); } } $requirements['races'] = array(); if (isset($cost['race'])) { $reqs = explode(',', $cost['race']); foreach ($reqs as $v) { $requirements['races'][] = Dolumar_Races_Race::getRace(trim($v)); } } // Check for class type if (isset($cost['type'])) { $classname = 'Dolumar_Technology_' . $cost['type']; if (class_exists($classname)) { $obj = new $classname($technology, $oCost, $duration, $requirements); $obj->setStats($cost); return $obj; } } // Not elseif, if not returned yet, there is something wrong. if ($objRace && class_exists($objRace->getName() . '_Dolumar_Technology_' . $technology)) { $classname = $objRace->getName() . '_Dolumar_Technology_' . $technology; return new $classname($technology, $oCost, $duration, $requirements); } elseif (class_exists('Dolumar_Technology_' . $technology)) { $classname = 'Dolumar_Technology_' . $technology; return new $classname($technology, $oCost, $duration, $requirements); } else { return new self($technology, $oCost, $duration, $requirements); } }
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...'); } }
if ($parseNew) { unlink($file); } else { echo file_get_contents($file); } } else { unlink($file); } } if ($parseNew) { // Load buildings from SQL $points = array(array($_GET['x'] * $imageSize + $imageSize / 2, $_GET['y'] * $imageSize + $imageSize / 2)); $buildingSQL = Dolumar_Map_Map::getBuildingsFromLocations($points, $imageSize); $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']); $b->setData($buildingV['bid'], $buildingV); $buildings[floor($buildingV['xas'])][floor($buildingV['yas'])][] = $b; } // Add buildings $startX = $_GET['x'] * $imageSize; $endX = $startX + $imageSize; $startY = $_GET['y'] * $imageSize; $endY = $startY + $imageSize; $im = imagecreate($imageSize, $imageSize); $i = 0; for ($x = $startX; $x <= $endX; $x++) { $j = 0; for ($y = $startY; $y <= $endY; $y++) { // Check for building
private function getEquipableRaces() { if (isset($this->requirement['race'])) { $races = explode(',', $this->requirement['race']); $out = array(); foreach ($races as $v) { $out[] = Dolumar_Races_Race::getRace($v); } return $out; } return false; }
<?php $player = new Dolumar_Players_Player(1); echo print_r($player->calculateNewStartLocation(array(0, 0), Dolumar_Races_Race::getRace('DarkElves')));
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; }
public function initializeAccount($race, $direction, $clan = false) { if (true) { $db = Neuron_Core_Database::__getInstance(); $text = Neuron_Core_Text::__getInstance(); if ($this->isFound() && !$this->isPlaying()) { $this->loadData(); if (empty($this->data['nickname'])) { $this->error = 'nickname_not_set'; return false; } else { $race = Dolumar_Races_Race::getRace($race); if (!$race->canPlayerSelect($this)) { $this->error = 'race_not_found'; return false; } // If a clan is specified, make sure it's not out of range if ($clan) { // Check if the clan is found if ($clan->isFull()) { $this->error = 'clan_is_full'; return false; } $map = $this->calculateNewStartLocation($direction, $race, MAXCLANDISTANCE); } else { $map = $this->calculateNewStartLocation($direction, $race); } // Map can actually fail, if no location is found. if (!$map) { $this->error = 'no_location_found'; return false; } $building = Dolumar_Buildings_Building::getBuilding(1, $race); $building = $building->build(null, $map[0], $map[1], $this, $race); $village = $building->getVillage(); // Update field $db->update('n_players', array('startX' => $map[0], 'startY' => $map[1], 'isPlaying' => 1), "plid = {$this->getId()}"); $this->data['startX'] = $map[0]; $this->data['startY'] = $map[1]; $this->data['isPlaying'] = 1; // Blah $this->village_insert_id = $village->getId(); // Now join the clan if ($clan) { $clan->doJoinClan($this); } $this->reloadData(); $this->reloadVillages(); $village->buildings->reloadBuildings(); // Invoke the command $this->events->invoke('register'); return true; } } else { $this->error = 'already_initialized'; return false; } } else { $this->error = 'game_not_open'; return false; } }
public function getRace() { $this->loadData(); return Dolumar_Races_Race::getRace($this->data['race']); }
private function parseSpecialUnit($data) { $unit = Dolumar_SpecialUnits_SpecialUnits::getFromId($data[0]); $unit->setLevel($data[1]); $unit->setCustomName($data[2]); $unit->setAlive($data[3]); if (isset($data[4])) { $unit->setRace(Dolumar_Races_Race::getRace($data[4])); } return $unit; }