Exemplo n.º 1
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;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 public function addShipType(ShipType $shipType)
 {
     if (isset($this->array[$shipType->getId()])) {
         $this->array[$shipType->getId()]->increment($shipType->getCount());
     } else {
         $shipType = $shipType->cloneMe();
         //avoid collateral effects
         if ($this->id != -1) {
             $shipType->setWeaponsTech($this->weapons_tech);
             $shipType->setShieldsTech($this->shields_tech);
             $shipType->setArmourTech($this->armour_tech);
         }
         $this->array[$shipType->getId()] = $shipType;
     }
     $this->count += $shipType->getCount();
 }
Exemplo n.º 5
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();
 }
Exemplo n.º 6
0
 public function getShotsFiredByAttackerToAll(ShipType $shipType_A, $real = false)
 {
     $num = new Number($this->getAttackerTotalShots() * $shipType_A->getCount());
     $denum = new Number($this->attackerShipType->getTotalCount());
     return Math::divide($num, $denum, $real);
 }
Exemplo n.º 7
0
 public function getRfTo(ShipType $other)
 {
     return isset($this->rf[$other->getId()]) ? $this->rf[$other->getId()] : 0;
 }