Exemplo n.º 1
0
Arquivo: Game.php Projeto: 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()));
 }
Exemplo n.º 2
0
Arquivo: Unit.php Projeto: 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;
 }