예제 #1
0
파일: Game.php 프로젝트: uhtoff/WotR
 public function setupBattle($data)
 {
     $battle = new Battle();
     $attacker = new Combatant($this->getCurrentSide());
     $defender = new Combatant($this->getOpponentSide());
     $setData = $this->getCurrentAction()->getData();
     $attLoc = $this->getLocations()->get($setData['source']->getID());
     $attacker->setLocation($attLoc);
     $defLoc = $this->getLocations()->get($setData['destination']->getID());
     $defender->setLocation($defLoc);
     /** @var Unit $u */
     foreach ($data['units'] as $u) {
         $u->setCombatant($attacker);
     }
     foreach ($defLoc->getUnits() as $u) {
         /** @var $u Unit */
         $u->setCombatant($defender);
     }
     $battle->setAttacker($attacker);
     $battle->setDefender($defender);
     $battle->setCombatValues();
     $this->setBattle($battle);
     LogFactory::setText("Battle is joined - {$this->getCurrentSide()->getName()} is attacking the {$this->getOpponentSide()->getName()} at {$battle->getDefender()->getLocation()->getName()}.");
     $this->setCurrentAction(new Action($this->getCurrentAction()->getNextAction()));
 }
예제 #2
0
파일: Game.php 프로젝트: uhtoff/WotR
 /**
  * Set battle
  *
  * @param \Meldon\WotRBundle\Entity\Battle $battle
  * @return Game
  */
 public function setBattle(\Meldon\WotRBundle\Entity\Battle $battle = null)
 {
     $this->battle = $battle;
     $battle->setGame($this);
     return $this;
 }