예제 #1
0
 /**
  * Creates a new Assault Object.
  *
  * @param integer $location    Assault location
  * @param integer $owner    Owner of the attacked planet
  * @param Bengine_Game_Model_Event $event
  *
  * @return Bengine_Game_Assault
  */
 public function __construct($location = null, $owner = null, Bengine_Game_Model_Event $event = null)
 {
     $this->attackers = new Map();
     $this->defenders = new Map();
     $this->location = $location;
     $this->owner = $owner;
     $time = TIME;
     $eventId = null;
     if (null !== $event) {
         $this->event = $event;
         $eventId = $event->get("eventid");
         $time = $event->get("time");
     }
     // Create a new assault in the database.
     Core::getQuery()->insert("assault", array("planetid" => $this->location, "event_id" => $eventId, "time" => $time, "real_time" => TIME));
     $this->assaultid = Core::getDB()->lastInsertId();
     // If the location is a planet, we have to update the ressource production.
     if ($this->location !== null) {
         $planet = new Bengine_Game_Planet($this->location, $this->owner, false);
         $planet->getProduction()->addProd();
         $this->loadDefenders();
     }
     return $this;
 }
예제 #2
0
 /**
  * Add production to destination planet.
  *
  * @param Bengine_Game_Model_Event $event
  * @return Bengine_Game_Planet
  */
 protected function _production(Bengine_Game_Model_Event $event)
 {
     $planet = new Bengine_Game_Planet($event->get("destination"), $event->get("destination_user_id"), false);
     $planet->getProduction()->addProd();
     return $planet;
 }