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 function getMyContent($input, $original = false) { if ($original) { return parent::getMyContent($input); } else { return $this->getGeneralContent(); } }
public function getName() { $data = $this->getLogArray(); //print_r ($data); $id = $data['building']; $race = Dolumar_Races_Race::getFromId($data['race']); list($locationX, $locationY) = array($data['x'], $data['y']); $level = $data['level']; $building = Dolumar_Buildings_Building::getBuilding($id, $race, $locationX, $locationY); if ($building) { $text = Neuron_Core_Text::getInstance(); return $building->getName() . ' ' . $text->get('lvl', 'building', 'building') . ' ' . $level; } else { return 'Building not found: ' . print_r($data); } }
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...'); } }
public function isFinished(Neuron_GameServer_Player $player) { $village = $player->getMainVillage(); // Check if we already have a farm return $village->buildings->hasBuilding(Dolumar_Buildings_Building::getBuilding(20, $village->getRace()), true); }
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 getBuildingsToDestroy($amount) { $db = Neuron_Core_Database::__getInstance(); if ($this->getOwner()->isPlaying()) { $tc = $this->buildings->getTownCenter(); $loc = $tc->getLocation(); // Load my buildings $buildings = $db->select('map_buildings', array('*', "SQRT(POW(xas-'{$loc[0]}',2)+POW(yas-'{$loc[1]}',2)) AS afstand"), "village = '" . $this->getId() . "' AND buildingType > '1' AND destroyDate = '0'", 'afstand DESC', ceil($amount)); $o = array(); $i = 0; foreach ($buildings as $v) { $o[$i] = Dolumar_Buildings_Building::getBuilding($v['buildingType'], $this->getRace(), $v['xas'], $v['yas']); $o[$i]->setData($v['bid'], $v); $o[$i]->setVillage($this); $i++; } return $o; } else { return array(); } }
public function resourceToText($res, $showRunes = true, $dot = true, $village) { return Dolumar_Buildings_Building::resourceToText($res, $showRunes, $dot, $village); }
private function processBuildInput() { $data = $this->getInputData(); // Get building $building = Dolumar_Buildings_Building::getBuilding($data['building'], $this->village->getRace()); if (isset($data['rune'])) { $building->setChosenRune($this->village, $data['rune']); } $x = floor($data['x'] * 2) / 2; $y = floor($data['y'] * 2) / 2; /* Check if the game allows building this building now */ if (!$building->canBuildBuilding($this->village)) { $this->updateContent($this->getContent('techlevel')); } elseif (!$building->checkBuildingLevels($this->village)) { $this->updateContent($this->getContent('buildinglevel', array('building' => $building->getName(false), 'buildings' => $building->getName(true), 'level' => $this->village->buildings->getBuildingAmount($building) + 1))); } elseif ($this->village->readyToBuild()) { $this->buildBuilding($building, $x, $y); } else { $this->updateContent($this->getContent('stillConstructing')); } }
$show_units = Neuron_Core_Tools::getInput('_GET', 'units', 'int', 0) == 1; $gv = new Image_GraphViz(true, array('label' => $race->getName(), 'labelloc' => 't')); // All buildings $gv->addCluster("BUILDINGS", "Buildings"); if ($show_technology) { $gv->addCluster("TECHNOLOGY", "Technology"); } //$gv->addCluster ("EQUIPMENT", "Equipment"); if ($show_equipment) { $gv->addCluster("weapon", "Weapons", array('rotate' => '90')); $gv->addCluster("armour", "Armour", array()); } if ($show_units) { $gv->addCluster("UNITS", "Units"); } $buildings = Dolumar_Buildings_Building::getBuildingObjects($race); foreach ($buildings as $building) { $building->setVillage(new Dolumar_Players_DummyVillage($race)); //$building->setRace ($race); // Add building $gv->addNode(BUILDING_PREFIX . $building->getName(), $default_node_settings, "BUILDINGS"); // Add building requirements foreach ($building->getRequiredBuildings() as $req) { $label = $req['amount'] . '+'; $gv->addEdge(array(BUILDING_PREFIX . $req['building']->getName() => BUILDING_PREFIX . $building->getName()), array_merge($arrow_atts, array('label' => $label))); } // Technologies if ($show_technology) { foreach ($building->getTechnologies() as $tech) { $label = 'Level ' . $tech->getMinLevel(); $gv->addNode(TECHNOLOGY_PREFIX . $tech->getName(), $tech_atts, "TECHNOLOGY");
public function useCredit($amount, $data) { $action = isset($data['action']) ? $data['action'] : null; $logs = Dolumar_Players_Logs::getInstance(); switch ($action) { case 'buyrunes': $runes = array_keys($this->getMainVillage()->resources->getInitialRunes()); $out = array(); foreach ($runes as $v) { if (isset($data[$v])) { $out[$v] = intval($data[$v]); } } $village = isset($data['village']) ? $data['village'] : null; $village = $this->getMyVillage($village); if ($village) { $village->resources->giveRunes($out); $logs->addPremiumRunesBoughtLog($village, $out); } break; case 'movevillage': $village = isset($data['village']) ? $data['village'] : null; $village = $this->getMyVillage($village); list($ox, $oy) = $village->buildings->getTownCenterLocation(); $x = isset($data['x']) ? $data['x'] : null; $y = isset($data['y']) ? $data['y'] : null; if ($village && isset($x) && isset($y)) { $village->movevillage->moveVillage($x, $y); $logs->addPremiumMoveVillage($village, $x, $y, $ox, $oy); } break; case 'movebuilding': $building = isset($data['building']) ? $data['building'] : null; $village = isset($data['village']) ? $data['village'] : null; $village = $this->getMyVillage($village); $x = isset($data['x']) ? intval($data['x']) : null; $y = isset($data['y']) ? intval($data['y']) : null; if ($village && isset($x) && isset($y) && isset($building)) { $building = $village->buildings->getBuilding($building); if ($building && $building->checkBuildLocation($village, $x, $y)) { list($ox, $oy) = $building->getLocation(); $building->setLocation($x, $y); $logs->addPremiumMoveBuilding($building, $x, $y, $ox, $oy); } } break; case 'bonusbuilding': $village = isset($data['village']) ? $data['village'] : null; $village = $this->getMyVillage($village); $x = isset($data['x']) ? intval($data['x']) : null; $y = isset($data['y']) ? intval($data['y']) : null; $building = isset($data['building']) ? intval($data['building']) : null; $building = Dolumar_Buildings_Building::getBuilding($building, $village->getRace()); $extra = isset($data['tile']) ? intval($data['tile']) : null; $chk = $building->checkBuildLocation($village, $x, $y); if ($chk[0]) { $building = $building->build($village, $x, $y, $extra); $logs->addPremiumBonusBuilding($building, $x, $y); } break; case 'speedup': $type = isset($data['type']) ? $data['type'] : null; $duration = isset($data['duration']) ? $data['duration'] : null; switch ($type) { case 'building': $id = isset($data['building']) ? $data['building'] : null; $building = Dolumar_Buildings_Building::getFromId($id); $building->speedupBuild($duration); // Reload the status bar $player = $building->getVillageForced()->getOwner(); $player->updates->setFlag('refresh-statusbar'); break; case 'training': $id = isset($data['order']) ? $data['order'] : null; $village = isset($data['village']) ? $data['village'] : null; $village = Dolumar_Players_Village::getFromId($village); $village->units->speedupBuild($id, $data['duration']); $player = $village->getOwner(); $player->updates->setFlag('refresh-statusbar'); break; case 'scouting': $id = isset($data['scoutid']) ? $data['scoutid'] : null; $village = isset($data['village']) ? $data['village'] : null; $village = Dolumar_Players_Village::getFromId($village); $village->speedupScouting($id, $data['duration']); $player = $village->getOwner(); $player->updates->setFlag('refresh-statusbar'); break; } break; case 'buyresources': $village = isset($data['village']) ? $data['village'] : null; $resource = isset($data['resource']) ? $data['resource'] : null; $village = $this->getMyVillage($village); if ($village) { if ($resource === 'all') { $village->resources->fillAll(); } else { $village->resources->fill($resource); } } break; default: $this->extendPremiumAccount(60 * 60 * 24 * 15); break; } }
public function processInput() { $data = $this->getInputData(); if (isset($data['action'])) { switch ($data['action']) { case 'overview': $this->updateContent(); return; break; } } $building = Dolumar_Buildings_Building::getBuilding(100, $this->village->getRace()); $x = floor($data['x']); $y = floor($data['y']); $extra = intval($data['extraData']); $building->setBonusBuildingId($extra); $chk = $building->checkBuildLocation($this->village, $x, $y); if ($chk[0]) { $x = $chk[1][0]; $y = $chk[1][1]; /* $this->village->premium->buildBonusBuilding ($building, $x, $y, $extra); $this->reloadLocation ($x, $y); */ //$this->updateContent ('<p>Your bonus building has been built.</p>'); $data = array('action' => 'bonusbuilding', 'building' => 100, 'tile' => $extra, 'village' => $this->village->getId(), 'x' => $x, 'y' => $y); $player = Neuron_GameServer::getPlayer(); $url = $player->getCreditUseUrl(self::CREDIT_COST, $data, $building->getName()); //$url = '<a href="'.$url.'" target="_BLANK" onclick="windowAction(this,{\'action\':\'overview\'}); return !Game.gui.openWindow(this, 450, 190);">here</a>'; //$this->updateContent ('<p>Click '.$url.' to buy a building.</p>'); $page = new Neuron_Core_Template(); $page->set('x', $x); $page->set('y', $y); $page->set('url', $url); $page->set('building', $building->getDisplayName()); $this->updateContent($page->parse('dolumar/bonusbuilding/confirm.phpt')); } else { $this->updateContent($this->getContent('invalidlocation')); } }
private function executeTrainQueue($data) { $unit = Dolumar_Units_Unit::getUnitFromId($data['unit'], $this->village->getRace(), $this->village); $amount = $data['amount']; $building = $data['building']; $building = Dolumar_Buildings_Building::getFromId($building); $building->setVillage($this->village); if ($building && $unit) { if ($building->doTrainUnits($unit, $amount)) { echo "Training " . $unit->getName() . "\n"; return true; } else { echo "No training units: " . $building->getTrainError() . "\n"; return false; } } else { return true; } }
public function equals(Dolumar_Buildings_Building $building) { return $this->getId() == $building->getId(); }
private function getBuildingLog($row) { $o = array(); $buildings = Dolumar_Buildings_Building::getAllBuildings(); // Building if (isset($buildings[$row['l_subId']])) { $o['building'] = $buildings[$row['l_subId']]; } else { $o['building'] = 'undefined'; } return $o; }
private function getSpeedUpBuilding($data) { $text = Neuron_Core_Text::getInstance(); $inputData = $this->getInputData(); $id = isset($data['building']) ? $data['building'] : null; $building = Dolumar_Buildings_Building::getFromId($id); if (!$building) { return '<p>Invalid input: building not found: ' . $id . '</p>'; } $price = PREMIUM_SPEEDUP_BUILDINGS_PRICE; $unit = PREMIUM_SPEEDUP_BUILDINGS_UNIT; if (isset($inputData['duration'])) { $selected = abs(intval($inputData['duration'])); $desc = Neuron_Core_Tools::putIntoText($text->get('confdesc_building', 'speedup', 'statusbar'), array('building' => $building->getName(), 'amount' => Neuron_Core_Tools::getDurationText($selected * $unit))); return $this->getConfirm($price, $unit, $selected, $desc); } $time = $building->getTimeLeft(); return $this->getSpeedUpHTML('building', $time, $price, $unit); }
public function doDestructBuilding($evenTowncenter = false, $date = NOW, $log = true) { if ($evenTowncenter) { parent::doDestructBuilding($evenTowncenter); } }
/** * 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; }
public function build($village, $x, $y, $tile = true) { $building = parent::build($village, $x, $y, false); $db = Neuron_DB_Database::getInstance(); $tile = intval($tile); $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tbonus_buildings\n\t\t\tSET\n\t\t\t\tb_id = {$building->getId()},\n\t\t\t\tb_player_tile = {$tile}\n\t\t"); return $building; }
public function getAllBuildingAmounts($includeConstructing = true) { $this->loadBuildings(); $buildingnames = Dolumar_Buildings_Building::getAllBuildings(); $out = array(); foreach ($this->buildingCount as $k => $v) { $key = isset($buildingnames[$k]) ? $buildingnames[$k] : 'unknown'; $out[$key] = $v; } return $out; }
public function getOutput() { //echo get_include_path (); require_once 'Image/GraphViz.php'; $race = Dolumar_Races_Race::getFromId(Neuron_Core_Tools::getInput('_GET', 'race', 'int', 1)); $default_settings = array('fontsize' => 8); $default_node_settings = $default_settings; $default_node_settings['shape'] = 'box'; $tech_atts = $default_node_settings; $tech_atts['bgcolor'] = 'ff0000'; $tech_atts['color'] = 'blue'; $equip_atts = $default_node_settings; $equip_atts['bgcolor'] = 'ff0000'; $equip_atts['color'] = 'red'; $equip_atts['rankdir'] = 'tb'; $equip_atts['constraint'] = false; $unit_atts = $default_node_settings; $unit_atts['bgcolor'] = 'ff0000'; $unit_atts['color'] = 'green'; $arrow_atts = $default_settings; $arrow_atts['arrowType'] = 'normal'; $arrow_atts['fontsize'] = '6'; $grayarrow_atts = $arrow_atts; $grayarrow_atts['color'] = 'gray'; define('UNIT_PREFIX', '[U] '); define('TECHNOLOGY_PREFIX', '[T] '); define('BUILDING_PREFIX', '[B] '); define('EQUIPMENT_PREFIX', '[E] '); $show_equipment = Neuron_Core_Tools::getInput('_GET', 'equipment', 'int', 0) == 1; $show_technology = Neuron_Core_Tools::getInput('_GET', 'technology', 'int', 0) == 1; $show_units = Neuron_Core_Tools::getInput('_GET', 'units', 'int', 0) == 1; $gv = new Image_GraphViz(true, array('label' => $race->getName(), 'labelloc' => 't')); // All buildings $gv->addCluster("BUILDINGS", "Buildings"); if ($show_technology) { $gv->addCluster("TECHNOLOGY", "Technology"); } //$gv->addCluster ("EQUIPMENT", "Equipment"); if ($show_equipment) { $gv->addCluster("weapon", "Weapons", array('rotate' => '90')); $gv->addCluster("armour", "Armour", array()); } if ($show_units) { $gv->addCluster("UNITS", "Units"); } $buildings = Dolumar_Buildings_Building::getBuildingObjects($race); foreach ($buildings as $building) { $building->setVillage(new Dolumar_Players_DummyVillage($race)); //$building->setRace ($race); // Add building $gv->addNode(BUILDING_PREFIX . $building->getName(), $default_node_settings, "BUILDINGS"); // Add building requirements foreach ($building->getRequiredBuildings() as $req) { $label = $req['amount'] . '+'; $gv->addEdge(array(BUILDING_PREFIX . $req['building']->getName() => BUILDING_PREFIX . $building->getName()), array_merge($arrow_atts, array('label' => $label))); } // Technologies if ($show_technology) { foreach ($building->getTechnologies() as $tech) { $label = 'Level ' . $tech->getMinLevel(); $gv->addNode(TECHNOLOGY_PREFIX . $tech->getName(), $tech_atts, "TECHNOLOGY"); $gv->addEdge(array(BUILDING_PREFIX . $building->getName() => TECHNOLOGY_PREFIX . $tech->getName()), array_merge($arrow_atts, array('label' => $label))); // requirements for the technologies? foreach ($tech->getRequiredTechnologies() as $req) { $label = null; $gv->addEdge(array(TECHNOLOGY_PREFIX . $req->getName() => TECHNOLOGY_PREFIX . $tech->getName()), array_merge($arrow_atts, array('label' => $label))); } } } // Equipment if ($building instanceof Dolumar_Buildings_Crafting && $show_equipment) { foreach ($building->getEquipment() as $equip) { //$gv->addNode (EQUIPMENT_PREFIX . $equip->getName (), $equip_atts, "EQUIPMENT"); $gv->addNode(EQUIPMENT_PREFIX . $equip->getName(), $equip_atts, $equip->getItemType()); // Arrow to this building $label = $equip->getRequiredLevel() > 0 ? 'Level ' . $equip->getRequiredLevel() : null; //$gv->addEdge (array (BUILDING_PREFIX . $building->getName () => EQUIPMENT_PREFIX . $equip->getName ()), array_merge ($arrow_atts, array ('label' => $label))); $gv->addEdge(array(BUILDING_PREFIX . $building->getName() => EQUIPMENT_PREFIX . $equip->getName()), array_merge($grayarrow_atts, array('label' => $label, 'ltail' => 'EQUIPMENT'))); // Required technologies? foreach ($equip->getRequiredTechnologies() as $tech) { $label = null; $gv->addEdge(array(TECHNOLOGY_PREFIX . $tech->getName() => EQUIPMENT_PREFIX . $equip->getName()), array_merge($grayarrow_atts, array('label' => $label))); } } } // Units if ($building instanceof Dolumar_Buildings_Training && $show_units) { foreach ($building->getUnits() as $unit) { // Units! $gv->addNode(UNIT_PREFIX . $unit->getName(), $unit_atts, "UNITS"); // Arrow to this building $label = null; $gv->addEdge(array(BUILDING_PREFIX . $building->getName() => UNIT_PREFIX . $unit->getName()), array_merge($grayarrow_atts, array('label' => $label))); // Required technologies? foreach ($unit->getRequiredTechnologies() as $tech) { $label = null; $gv->addEdge(array(TECHNOLOGY_PREFIX . $tech->getName() => UNIT_PREFIX . $unit->getName()), array_merge($grayarrow_atts, array('label' => $label))); } } } } // All equipment /* $gv->addCluster ("EQUIPMENT", "Equipment"); $eqs = Dolumar_Players_Equipment::getAllEquipment(); foreach ($eqs as $building) { $gv->addNode ($building->getName (), $equip_atts, "EQUIPMENT"); // Required technologies? foreach ($building->getRequiredTechnologies () as $tech) { $label = null; $gv->addEdge (array ($tech->getName () => $building->getName ()), array_merge ($arrow_atts, array ('label' => $label))); } } */ // All units $output = Neuron_Core_Tools::getInput('_GET', 'engine', 'varchar'); switch ($output) { case "dot": case "neato": break; default: $output = "dot"; break; } if (!$gv->image("png", $output)) { echo "Error... Is Graphviz installed?"; } }
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 if (isset($buildings[$x]) && isset($buildings[$x][$y])) {
private function loadBuildingCounters($vils) { $db = Neuron_Core_Database::__getInstance(); $text = Neuron_Core_Text::__getInstance(); $b = $db->select('map_buildings', array('*'), "\n\t\t\t\t(map_buildings.readyDate > '" . time() . "'\n\t\t\t\tOR map_buildings.lastUpgradeDate > '" . time() . "')\n\t\t\t\tAND destroyDate = '0'\n\t\t\t\t{$vils}\n\t\t\t"); foreach ($b as $v) { $village = Dolumar_Players_Village::getVillage($v['village']); $race = $village->getRace(); // Building stuff $building = Dolumar_Buildings_Building::getBuilding($v['buildingType'], $race); $building->setData($v['bid'], $v); $speedUp = null; if ($this->canSpeedUp('building')) { $speedUp = array('type' => 'building', 'building' => $building->getId()); } if ($v['readyDate'] > time()) { $t = Neuron_Core_Tools::putIntoText($text->get('construct'), array($building->getName())); $this->addCounter($v['readyDate'], $village, $t, 'construct', false, $speedUp); } else { $t = Neuron_Core_Tools::putIntoText($text->get('upgrade'), array($building->getName())); $this->addCounter($v['lastUpgradeDate'], $village, $t, 'upgrade', false, $speedUp); } } }