示例#1
0
 public function inflictDamage($damage, $colpiSparatiVersoQuestoTipoDiNavi)
 {
     if ($colpiSparatiVersoQuestoTipoDiNavi == 0) {
         return;
     }
     if ($colpiSparatiVersoQuestoTipoDiNavi < 0) {
         throw new Exception("negative count!");
     }
     echo 'Defender single hull=' . $this->hull . '<br>';
     echo 'Defender count=' . $this->getCount() . '<br>';
     $this->lastShots += $colpiSparatiVersoQuestoTipoDiNavi;
     echo "currentShield before= {$this->currentShield}<br>";
     echo "currentLife before={$this->currentLife}<br>";
     $ps = new PhysicShot($this, $damage, $colpiSparatiVersoQuestoTipoDiNavi);
     $ps->start();
     $this->currentShield -= $ps->getAssorbedDamage(true);
     $this->currentLife -= $ps->getHullDamage();
     echo "currentShield after= {$this->currentShield}<br>";
     echo "currentLife after={$this->currentLife}<br>";
     $this->lastShipHit += $ps->getHitShips();
     echo "lastShipHit after = {$this->lastShipHit}<br>";
     echo "lastShots after={$this->lastShots}<br>";
     return $ps;
     //for web
 }
示例#2
0
 /**
  * ShipType::inflictDamage()
  * Inflict damage to all ships of this type.
  * @param int $damage
  * @param int $shotsToThisShipType
  * @return void
  */
 public function inflictDamage($damage, $shotsToThisShipType)
 {
     if ($shotsToThisShipType == 0) {
         return;
     }
     if ($shotsToThisShipType < 0) {
         throw new Exception("Negative amount of shotsToThisShipType!");
     }
     log_var('Defender single hull', $this->singleLife);
     log_var('Defender count', $this->getCount());
     log_var('currentShield before', $this->currentShield);
     log_var('currentLife before', $this->currentLife);
     $this->lastShots += $shotsToThisShipType;
     $ps = new PhysicShot($this, $damage, $shotsToThisShipType);
     $ps->start();
     log_var('$ps->getAssorbedDamage()', $ps->getAssorbedDamage());
     $this->currentShield -= $ps->getAssorbedDamage();
     if ($this->currentShield < 0 && $this->currentShield > -EPSILON) {
         log_comment('fixing double number currentshield');
         $this->currentShield = 0;
     }
     $this->currentLife -= $ps->getHullDamage();
     if ($this->currentLife < 0 && $this->currentLife > -EPSILON) {
         log_comment('fixing double number currentlife');
         $this->currentLife = 0;
     }
     log_var('currentShield after', $this->currentShield);
     log_var('currentLife after', $this->currentLife);
     $this->lastShipHit += $ps->getHitShips();
     log_var('lastShipHit after', $this->lastShipHit);
     log_var('lastShots after', $this->lastShots);
     if ($this->currentLife < 0) {
         throw new Exception('Negative currentLife!');
     }
     if ($this->currentShield < 0) {
         throw new Exception('Negative currentShield!');
     }
     if ($this->lastShipHit < 0) {
         throw new Exception('Negative lastShipHit!');
     }
     return $ps;
     //for web
 }