Beispiel #1
0
 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;
 }