Exemple #1
0
 /**
  *	Method that is called after this building was build
  */
 protected function onBuild()
 {
     // Connect this portal to all other portals
     $portals = $this->getVillage()->getOwner()->getMainClan()->getClanportals();
     foreach ($portals as $v) {
         if (!$v->equals($this)) {
             $portal = new Dolumar_Map_Portal(null);
             $portal->setCasterBuilding($this);
             $portal->setTargetBuilding($v);
             Dolumar_Map_Portal::insert($portal);
         }
     }
 }
Exemple #2
0
 public function getGeneralContent($showAll = false)
 {
     // Fetch thze portal
     $portals = Dolumar_Map_Portal::getFromBuilding($this);
     /*
     if (count ($portals) == 0)
     {
     	return '<p class="false">This portal leads to nowhere...</p>';
     }
     */
     $targets = array();
     foreach ($portals as $v) {
         $village = $v->getOtherSide($this->getVillage());
         $targets[] = $village->getDisplayName();
     }
     $page = new Neuron_Core_Template();
     $destroydate = $this->getDestroyDate();
     if ($destroydate) {
         $page->set('timeleft', Neuron_Core_Tools::getCountdown($this->getDestroyDate()));
     }
     $page->set('targets', $targets);
     return $page->parse('buildings/portal.phpt');
 }
Exemple #3
0
 private static function getDistanceBetweenVillages_pathbased($village1, $village2, $ignoreImpassable = true)
 {
     $tc1 = $village1->buildings->getTownCenter();
     $tc2 = $village2->buildings->getTownCenter();
     $loc1 = $tc1->getLocation();
     $loc2 = $tc2->getLocation();
     // Fetch portals
     $portals = Dolumar_Map_Portal::getFromVillages(array($village1, $village2));
     return Dolumar_Map_Distance::getDistance($loc1, $loc2, $portals, $ignoreImpassable);
 }
Exemple #4
0
 public static function insert(Dolumar_Map_Portal $portal)
 {
     $db = Neuron_DB_Database::getInstance();
     $b1 = $portal->getCasterBuilding();
     $b2 = $portal->getTargetBuilding();
     $v1 = $b1->getVillage();
     $v2 = $b2->getVillage();
     $l1 = $portal->getCasterLocation();
     $l2 = $portal->getTargetLocation();
     $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tmap_portals\n\t\t\tSET\n\t\t\t\tp_caster_v_id = {$v1->getId()},\n\t\t\t\tp_target_v_id = {$v2->getId()},\n\t\t\t\tp_caster_x = {$l1[0]},\n\t\t\t\tp_caster_y = {$l1[1]},\n\t\t\t\tp_target_x = {$l2[0]},\n\t\t\t\tp_target_y = {$l2[1]},\n\t\t\t\tp_caster_b_id = {$b1->getId()},\n\t\t\t\tp_target_b_id = {$b2->getId()},\n\t\t\t\tp_endDate = NULL\n\t\t");
 }