예제 #1
0
 public function add(ShipType $shipType)
 {
     if (isset($this->array[$shipType->getId()])) {
         $this->array[$shipType->getId()]->increment($shipType->getCount());
     } else {
         $this->array[$shipType->getId()] = $shipType->cloneMe();
         //avoid collateral effects
     }
     $this->count += $shipType->getCount();
 }
예제 #2
0
 /**
  * ShipsCleaner::__construct()
  * 
  * @param mixed $shipType
  * @param int $lastShipHit
  * @param int $lastShot
  * @return ShipsCleaner
  */
 public function __construct(ShipType $shipType, $lastShipHit, $lastShots)
 {
     if ($lastShipHit < 0) {
         throw new Exception('Negative $lastShipHit');
     }
     if ($lastShots < 0) {
         throw new Exception('Negative $lastShots');
     }
     $this->fighters = $shipType->cloneMe();
     $this->lastShipHit = $lastShipHit;
     $this->lastShots = $lastShots;
 }
예제 #3
0
 /**
  * PhysicShot::__construct()
  * 
  * @param ShipType $shipType
  * @param int $damage
  * @param int $count
  * @return
  */
 public function __construct(ShipType $shipType, $damage, $count)
 {
     echo "damage={$damage}<br>count={$count}<br>";
     if ($damage < 0) {
         throw new Exception('negative damage');
     }
     if ($count < 0) {
         throw new Exception('negative amount of shots');
     }
     $this->fighters = $shipType->cloneMe();
     $this->damage = $damage;
     $this->count = $count;
 }
예제 #4
0
 /**
  * PhysicShot::__construct()
  * 
  * @param ShipType $shipType
  * @param int $damage
  * @param int $count
  * @return
  */
 public function __construct(ShipType $shipType, $damage, $count)
 {
     log_var('damage', $damage);
     log_var('count', $count);
     if ($damage < 0) {
         throw new Exception('Negative damage');
     }
     if ($count < 0) {
         throw new Exception('Negative amount of shots');
     }
     $this->fighters = $shipType->cloneMe();
     $this->damage = $damage;
     $this->count = $count;
 }
예제 #5
0
 /**
  * Fire::__construct()
  * 
  * @param ShipType $attackerShipType
  * @param Fleet $defenderFleet
  * @param bool $attacking
  * @return
  */
 public function __construct(ShipType $attackerShipType, Fleet $defenderFleet)
 {
     $this->attackerShipType = $attackerShipType->cloneMe();
     $this->defenderFleet = $defenderFleet->cloneMe();
 }