コード例 #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
ファイル: 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);
 }
コード例 #3
0
ファイル: Race.php プロジェクト: Toxicat/dolumar
 public function getId()
 {
     $races = Dolumar_Races_Race::getRaces();
     $o = 1;
     foreach ($races as $k => $v) {
         if ($v == $this->getName()) {
             $o = $k;
         }
     }
     return $o;
 }
コード例 #4
0
ファイル: Building.php プロジェクト: Toxicat/dolumar
 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);
     }
 }
コード例 #5
0
ファイル: Report.php プロジェクト: Toxicat/dolumar
 private function getUnitStats()
 {
     $html = "";
     foreach (Dolumar_Races_Race::getRaceObjects() as $race) {
         $html .= '<div style="width: 450px; float: left; margin: 0px 0px 0px 0px;">';
         $html .= '<h2>' . $race->getDisplayName() . '</h2>';
         $units = Dolumar_Units_Unit::getAllUnits($race);
         $page = new Neuron_Core_Template();
         $page->set('showConsumption', true);
         $page->set('showCost', true);
         $page->set('showSpeed', true);
         Dolumar_Units_Unit::printStatNames($page);
         foreach ($units as $v) {
             $data = array('name' => $v->getName(), 'stats' => $v->getStats(), 'available' => $v->getAvailableAmount(), 'total' => $v->getTotalAmount(), 'consumption' => Dolumar_Tools::resourceToText($v->getConsumption()), 'cost' => Dolumar_Tools::resourceToText($v->getTrainingCost()), 'type' => $v->getAttackType_text(), 'image' => $v->getImageUrl());
             $page->addListValue('units', $data);
         }
         $html .= $page->parse('structure/unitstats.phpt');
         $html .= '</div>';
     }
     return $html;
 }
コード例 #6
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...');
     }
 }
コード例 #7
0
ファイル: MyAccount.php プロジェクト: Toxicat/dolumar
 protected function getPlayerInitialization($registrationTracker = false)
 {
     // Check if we can actually register
     $server = Neuron_GameServer::getServer();
     if (!$server->canRegister()) {
         return '<p>This server has gone into "endgame" mode. You can not register here anymore. But stay tuned, a new game will start soon.</p>';
     }
     $data = $this->getInputData();
     $me = Neuron_GameServer::getPlayer();
     if (isset($data['race'])) {
         // Check for clans
         $clan = isset($data['clan']) ? intval($data['clan']) : 0;
         $location = isset($data['location']) ? $data['location'] : null;
         $objClan = false;
         if ($clan > 0) {
             $objClan = new Dolumar_Players_Clan($clan);
             if ($objClan->isFound()) {
                 // Check for password
                 if ($objClan->isPasswordProtected()) {
                     // Break out of the function if the password is not correct.
                     if (!isset($data['password']) || !$objClan->checkPassword($data['password'])) {
                         return $this->requestClanPassword($data['race'], $objClan);
                     }
                 }
                 $members = $objClan->getMembers();
                 if (count($members) > 0) {
                     $member = $members[rand(0, count($members) - 1)];
                     // Fetch towncenter
                     $village = $member->getMainVillage();
                     if ($village) {
                         // Overwrite location with the location of this towncenter.
                         $location = $village->buildings->getTownCenterLocation();
                     } else {
                         $location = array(0, 0);
                     }
                 } else {
                     $location = array(0, 0);
                 }
             }
         }
         if ($me->initializeAccount($data['race'], $location, $objClan)) {
             // Scroll to the right location
             $me = Neuron_GameServer::getPlayer();
             $home = $me->getHomeLocation();
             $this->mapJump($home[0], $home[1]);
             // Reload area
             $this->reloadLocation($home[0], $home[1]);
             reloadEverything();
             return $this->getContent(false);
         } else {
             //return $this->getPlayerInitialization ();
         }
     }
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('account');
     $text->setSection('selectRace');
     $data = $this->getInputData();
     // Show form
     $page = new Neuron_Core_Template();
     $error = Neuron_GameServer::getPlayer()->getError();
     if (!empty($error)) {
         $page->set('error', $text->get($error, 'errors', 'account', $error));
     }
     // Loop trough races
     foreach (Dolumar_Races_Race::getRaces() as $k => $v) {
         $race = Dolumar_Races_Race::getFromId($k);
         if ($race->canPlayerSelect(Neuron_GameServer::getPlayer())) {
             $page->addListValue('races', array($text->get($v, 'races', 'races', $v), $text->get($v, 'desc', 'races', 'null'), $k));
         }
     }
     $page->sortList('races');
     // Some text values
     $page->set('submit', $text->get('submit'));
     $page->set('select', $text->get('select'));
     $page->set('location', $text->get('location'));
     if ($registrationTracker === true) {
         $tracker = Neuron_GameServer::getPlayer()->getTrackerUrl('registration');
         $page->set('tracker_url', htmlentities($tracker));
     }
     // Locations
     $page->addListValue('directions', array($text->get('r', 'directions', 'main'), 'r'));
     $page->addListValue('directions', array($text->get('n', 'directions', 'main'), 'n'));
     $page->addListValue('directions', array($text->get('ne', 'directions', 'main'), 'ne'));
     $page->addListValue('directions', array($text->get('e', 'directions', 'main'), 'e'));
     $page->addListValue('directions', array($text->get('es', 'directions', 'main'), 'es'));
     $page->addListValue('directions', array($text->get('s', 'directions', 'main'), 's'));
     $page->addListValue('directions', array($text->get('sw', 'directions', 'main'), 'sw'));
     $page->addListValue('directions', array($text->get('w', 'directions', 'main'), 'w'));
     $page->addListValue('directions', array($text->get('wn', 'directions', 'main'), 'wn'));
     // Fetch a list of all clans
     $db = Neuron_Core_Database::__getInstance();
     $clans = $db->select('clans', array('*'));
     // Add a list of all clans ;-)
     foreach ($clans as $v) {
         $clan = new Dolumar_Players_Clan($v['c_id'], $v);
         $page->addListValue('clans', array('id' => $clan->getId(), 'name' => Neuron_Core_Tools::output_varchar($clan->getName()), 'isLocked' => $clan->isPasswordProtected(), 'isFull' => $clan->isFull()));
     }
     return $page->parse('account/selectRace.phpt');
 }
コード例 #8
0
<?php

$player = new Dolumar_Players_Player(1);
echo print_r($player->calculateNewStartLocation(array(0, 0), Dolumar_Races_Race::getRace('DarkElves')));
コード例 #9
0
ファイル: Report.php プロジェクト: Toxicat/dolumar
 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;
 }
コード例 #10
0
         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
コード例 #11
0
ファイル: Simulator.php プロジェクト: Toxicat/dolumar
 public function simulate()
 {
     $input = $this->getInputData();
     //return '<pre>' . print_r ($input, true) . '</pre>';
     $slots = array();
     // Collect thze slots
     foreach (array('att', 'def') as $side) {
         $units = array();
         $hasnext = true;
         $counter = 1;
         while ($hasnext) {
             $dummy = new Dolumar_Players_DummyVillage();
             $unit = isset($input['slot_' . $side . '_unit_' . $counter]) ? $input['slot_' . $side . '_unit_' . $counter] : false;
             $slot = isset($input['slot_' . $side . '_slot_' . $counter]) ? $input['slot_' . $side . '_slot_' . $counter] : false;
             $amount = isset($input['slot_' . $side . '_amount_' . $counter]) ? $input['slot_' . $side . '_amount_' . $counter] : false;
             if ($unit === false || $slot === false || $amount === false) {
                 $hasnext = false;
                 break;
             }
             if (!isset($slots[$counter])) {
                 $slots[$counter] = Dolumar_Battle_Slot_Grass::getFromId($slot, $counter, $dummy);
             }
             $unitdata = explode('_', $unit);
             if (count($unitdata) == 2) {
                 $race = Dolumar_Races_Race::getFromId($unitdata[0]);
                 //echo $race->getName () . "\n";
                 $unitobj = Dolumar_Units_Unit::getUnitFromId($unitdata[1], $race, $dummy);
                 //echo $unitobj->getName () . "\n";
                 $unitobj->addAmount($amount, $amount, $amount);
                 $unitobj->setBattleSlot($slots[$counter]);
                 $units[$counter] = $unitobj;
             }
             $counter++;
         }
         ${$side} = $units;
     }
     //return print_r ($att, true) . ' ' . print_r ($def, true);
     $logger = new Dolumar_Battle_Logger();
     // __construct ($objAttVil, $objDefVil, $objAttUnits, $objDefUnits, $slots, $specialUnits, $objLogger)
     $fight = new Dolumar_Battle_Fight($dummy, $dummy, $att, $def, $slots, array(), $logger);
     $result = $fight->getResult();
     $out = '<p>Fight result: ' . ceil($result * 100) . '%</p>';
     $report = Dolumar_Battle_SimulatorReport::getFromLogger($logger);
     $out .= $this->showReport($report);
     // Set the request data
     $this->updateRequestData(array('report' => $report->serialize()));
     // We puts the report in thze session
     //$_SESSION['tmp_report'] = $report;
     // NEVER DO THAT AGAIN!
     return $out;
 }
コード例 #12
0
<?php

//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;
コード例 #13
0
ファイル: Player.php プロジェクト: Toxicat/dolumar
 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;
     }
 }
コード例 #14
0
ファイル: Technology.php プロジェクト: Toxicat/dolumar
 public static function getFromId($id, $inRace = null)
 {
     $id = explode('.', $id);
     if (count($id) > 1) {
         $race = Dolumar_Races_Race::getFromId(intval($id[1]));
     } else {
         $race = $inRace;
     }
     $id = intval($id[0]);
     $db = Neuron_Core_Database::__getInstance();
     $l = $db->select('technology', array('techName'), "techId = {$id}");
     if (count($l) == 1) {
         return self::getTechnology($l[0]['techName'], $race);
     } else {
         return false;
     }
 }
コード例 #15
0
ファイル: Village.php プロジェクト: Toxicat/dolumar
 public function getRace()
 {
     $this->loadData();
     return Dolumar_Races_Race::getRace($this->data['race']);
 }
コード例 #16
0
ファイル: Equipment.php プロジェクト: Toxicat/dolumar
 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;
 }
コード例 #17
0
ファイル: Techtree.php プロジェクト: Toxicat/dolumar
 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?";
     }
 }
コード例 #18
0
         $output['content']['premium'] = array();
         $output['content']['premium']['online'] = Neuron_GameServer::getServer()->countPremiumPlayers();
         $output['content']['premium']['lastFive'] = Neuron_GameServer::getServer()->countPremiumPlayers(60 * 5);
         $output['content']['premium']['lastHour'] = Neuron_GameServer::getServer()->countPremiumPlayers(60 * 60);
         $output['content']['premium']['lastDay'] = Neuron_GameServer::getServer()->countPremiumPlayers(60 * 60 * 24);
         $output['content']['premium']['lastWeek'] = Neuron_GameServer::getServer()->countPremiumPlayers(60 * 60 * 24 * 7);
         $output['content']['premium']['lastMonth'] = Neuron_GameServer::getServer()->countPremiumPlayers(60 * 60 * 24 * 31);
         $output['content']['premium']['total'] = Neuron_GameServer::getServer()->countPremiumPlayers();
     }
     //$output['content']['players']['sponsors'] = Neuron_GameServer::getServer()->countSponsors ();
     // Villages
     $output['content']['villages'] = array();
     $output['content']['villages']['total'] = Neuron_GameServer::getServer()->countVillages();
     $output['content']['villages']['active'] = Neuron_GameServer::getServer()->countVillages(false);
     $output['content']['villages']['races'] = array();
     foreach (Dolumar_Races_Race::getRaces() as $k => $v) {
         $output['content']['villages']['races'][$v] = Neuron_GameServer::getServer()->countVillagesFromRace($k);
     }
     // Invitations
     //$output['content']['invitations'] = Neuron_GameServer::getServer()->countInvitations ();
     // Auth types
     //$output['content']['auths'] = Neuron_GameServer::getServer()->countAuthTypes ();
     break;
 case 'clearcache':
     $output['content'] = Neuron_GameServer::getServer()->clearCache(isset($_GET['clearMapCache']) && $_GET['clearMapCache'] == 'yes');
     break;
 case 'ranking':
     // Ranking is handling its own output.
     include 'ranking.php';
     exit;
     break;
コード例 #19
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;
 }