public function reduceElite(Unit $e) { $units = $this->getUnits(); $possRegs = $units->filter(function ($u) use($e) { return $u->getNation() == $e->getNation() && is_null($u->getLocation()) && $u->isRegular(); }); $deadRegs = $possRegs->filter(function ($u) { return $u->getCasualty(); }); if (!$deadRegs->isEmpty()) { $nR = $deadRegs->first(); } else { $nR = $possRegs->first(); } $nR->setLocation($e->getLocation())->setCombatant($e->getCombatant())->setCasualty(false); return $nR; }
/** * @param bool $casualty */ public function becomeCasualty($casualty = true) { if ($this->getFellowship()) { $this->leaveFellowship(); } parent::becomeCasualty($casualty); $this->setCasualty(true); }