예제 #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
파일: Unit.php 프로젝트: uhtoff/WotR
 /**
  * Set combatant
  *
  * @param \Meldon\WotRBundle\Entity\Combatant $combatant
  * @return Unit
  */
 public function setCombatant(\Meldon\WotRBundle\Entity\Combatant $combatant = null)
 {
     $this->combatant = $combatant;
     $combatant->addUnit($this);
     return $this;
 }