示例#1
0
 public static function create(Dolumar_Underworld_Models_Mission $mission, Dolumar_Underworld_Models_Army $army)
 {
     $loc = $army->getLocation();
     $x = $loc->x();
     $y = $loc->y();
     $db = Neuron_DB_Database::getInstance();
     $id = $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tunderworld_armies\n\t\t\tSET\n\t\t\t\tua_x = {$x},\n\t\t\t\tua_y = {$y},\n\t\t\t\tua_movepoints = {$army->getMovepoints(false)},\n\t\t\t\tua_lastrefresh = FROM_UNIXTIME({$army->getLastRefresh()}),\n\t\t\t\tua_side = {$army->getSide()->getId()},\n\t\t\t\tum_id = {$mission->getId()}\n\t\t");
     $army->setId($id);
     return $army;
 }
示例#2
0
文件: Army.php 项目: Toxicat/dolumar
 /**
  *	Attack
  */
 public function attack(Dolumar_Players_Player $me, Dolumar_Underworld_Models_Army $army)
 {
     if (!$this->canAttack($me)) {
         $this->error = 'move_not_authorized';
         return false;
     }
     $path = $this->canReach($army->getLocation(), true);
     if (!$this->isEnemy($army)) {
         $this->error = 'not_an_enemy';
         return false;
     } else {
         if (!$path) {
             $this->error = 'cannot_reach_target';
             return false;
         } else {
             if ($this->isFighting()) {
                 $this->error = 'army_not_idle';
                 return false;
             } else {
                 if ($army->isFighting()) {
                     // This should be replaced by queing
                     $this->error = 'target_not_idle';
                     return false;
                 } else {
                     $fight = $this->prcFight($army);
                     $this->getMap()->getMission()->getLogger()->attack($me, $this, $army, $army->getLocation(), $path, $fight);
                     return $fight;
                 }
             }
         }
     }
 }