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(); }
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(); }
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); }