示例#1
0
 /** Cette fonction transfert les unités en attaque au stock et efface le combat
  * elle retourne la nouvelle armée pour l'affichage en ajax
  * @return array new updated Army_owned list
  */
 public function reset_army()
 {
     $army_mobile = new Army($this->attacker_id, $this->id);
     $army_owned = new Army($this->attacker_id);
     if (count($army_mobile->troops) > 0 && $army_mobile->total_units > 0) {
         foreach ($army_mobile->troops as $unit_id => $troop) {
             if ($troop->quantity > 0) {
                 $army_owned->add_troop($unit_id, $troop->quantity);
             }
             $troop = new Troop($troop->id);
             $troop->delete();
         }
     }
     $this->delete();
     return $army_owned->get_troops();
 }