Weapon
extends AbstractWeapon
in package
uses
RaceID
Defines a concrete realization of a weapon type for ships/planets.
Table of Contents
Constants
- BONUS_ACCURACY : int = 4
- BONUS_DAMAGE : int = 15
- HIGHEST_POWER_LEVEL : int = 5
- PLANET_DAMAGE_MOD : float = 0.2
- Reduce the damage done to planets by this factor
Properties
- $bonusAccuracy : bool
- $bonusDamage : bool
- $damageRollover : bool
- $raceID : int
- $weaponType : WeaponType
- $weaponTypeID : int
Methods
- canShootTarget() : bool
- getArmourDamage() : int
- Return the weapon armour damage.
- getBaseAccuracy() : int
- Return the weapon base accuracy.
- getBuyerRestriction() : BuyerRestriction
- getBuyHREF() : string
- getCost() : int
- Weapon cost is increased by 100% for each enhancement present
- getDamage() : WeaponDamage
- getModifiedAccuracyAgainstTarget() : float
- getModifiedDamageAgainstTarget() : WeaponDamage
- getModifiedPlanetAccuracy() : float
- getModifiedPlayerAccuracy() : float
- getModifiedPortAccuracy() : float
- getName() : string
- Return weapon name suitable for HTML display.
- getPlanetAccuracy() : float
- getPlayerLevelAccuracyMod() : float
- getPowerLevel() : int
- getRaceID() : int
- getRaceName() : string
- getSellHREF() : string
- getShieldDamage() : int
- Return the weapon shield damage.
- getWeapon() : self
- getWeaponTypeID() : int
- hasBonusAccuracy() : bool
- hasBonusDamage() : bool
- isDamageRollover() : bool
- isUniqueType() : bool
- Ships are only allowed to equip one of each type of Unique weapon
- setBonusAccuracy() : void
- setBonusDamage() : void
- shoot() : MissedWeaponResult|HitWeaponResult<string|int, TTarget>
- __construct() : mixed
- checkHit() : bool
- Given $weaponAccuracy as a percent, decide if the weapon hits.
- getWeightedRandom() : WeightedRandom
- hitTarget() : HitWeaponResult<string|int, TTarget>
- Applies this weapon's modified damage and resolves a killing shot, if any.
- getNumberOfEnhancements() : int
- hasEnhancements() : bool
Constants
BONUS_ACCURACY
protected
int
BONUS_ACCURACY
= 4
BONUS_DAMAGE
protected
int
BONUS_DAMAGE
= 15
HIGHEST_POWER_LEVEL
protected
int
HIGHEST_POWER_LEVEL
= 5
PLANET_DAMAGE_MOD
Reduce the damage done to planets by this factor
protected
float
PLANET_DAMAGE_MOD
= 0.2
Properties
$bonusAccuracy
protected
bool
$bonusAccuracy
= false
$bonusDamage
protected
bool
$bonusDamage
= false
$damageRollover
protected
bool
$damageRollover
= false
Attributes
- #[Override]
$raceID
protected
int
$raceID
$weaponType read-only
protected
WeaponType
$weaponType
$weaponTypeID read-only
protected
int
$weaponTypeID
Methods
canShootTarget()
public
canShootTarget(CombatantInterface $target) : bool
Parameters
- $target : CombatantInterface
Return values
boolgetArmourDamage()
Return the weapon armour damage.
public
getArmourDamage() : int
Return values
intgetBaseAccuracy()
Return the weapon base accuracy.
public
getBaseAccuracy() : int
Return values
intgetBuyerRestriction()
public
getBuyerRestriction() : BuyerRestriction
Return values
BuyerRestrictiongetBuyHREF()
public
getBuyHREF(Location $location) : string
Parameters
- $location : Location
Return values
stringgetCost()
Weapon cost is increased by 100% for each enhancement present
public
getCost() : int
Return values
intgetDamage()
public
getDamage() : WeaponDamage
Return values
WeaponDamagegetModifiedAccuracyAgainstTarget()
public
getModifiedAccuracyAgainstTarget(CombatantInterface $shooter, CombatantInterface $target) : float
Parameters
- $shooter : CombatantInterface
- $target : CombatantInterface
Return values
floatgetModifiedDamageAgainstTarget()
public
getModifiedDamageAgainstTarget(CombatantInterface $shooter, CombatantInterface $target) : WeaponDamage
Parameters
- $shooter : CombatantInterface
- $target : CombatantInterface
Return values
WeaponDamagegetModifiedPlanetAccuracy()
public
getModifiedPlanetAccuracy(Planet $planet, Ship $target) : float
Parameters
Return values
floatgetModifiedPlayerAccuracy()
public
getModifiedPlayerAccuracy(Ship $shooter, CombatantInterface $target) : float
Parameters
- $shooter : Ship
- $target : CombatantInterface
Return values
floatgetModifiedPortAccuracy()
public
getModifiedPortAccuracy(Port $port, Ship $target) : float
Parameters
Return values
floatgetName()
Return weapon name suitable for HTML display.
public
getName() : string
The name is displayed in green with pluses if enhancements are present.
Return values
stringgetPlanetAccuracy()
public
getPlanetAccuracy(Planet $planet) : float
Parameters
- $planet : Planet
Return values
floatgetPlayerLevelAccuracyMod()
public
static getPlayerLevelAccuracyMod(Ship $ship) : float
Parameters
- $ship : Ship
Return values
floatgetPowerLevel()
public
getPowerLevel() : int
Return values
intgetRaceID()
public
getRaceID() : int
Return values
intgetRaceName()
public
getRaceName() : string
Return values
stringgetSellHREF()
public
getSellHREF(Location $location, int $orderID) : string
Parameters
- $location : Location
- $orderID : int
Return values
stringgetShieldDamage()
Return the weapon shield damage.
public
getShieldDamage() : int
Return values
intgetWeapon()
public
static getWeapon(int $weaponTypeID[, DatabaseRecord|null $dbRecord = null ]) : self
Parameters
- $weaponTypeID : int
- $dbRecord : DatabaseRecord|null = null
Return values
selfgetWeaponTypeID()
public
getWeaponTypeID() : int
Return values
inthasBonusAccuracy()
public
hasBonusAccuracy() : bool
Return values
boolhasBonusDamage()
public
hasBonusDamage() : bool
Return values
boolisDamageRollover()
public
isDamageRollover() : bool
Return values
boolisUniqueType()
Ships are only allowed to equip one of each type of Unique weapon
public
isUniqueType() : bool
Return values
boolsetBonusAccuracy()
public
setBonusAccuracy(bool $bonusAccuracy) : void
Parameters
- $bonusAccuracy : bool
setBonusDamage()
public
setBonusDamage(bool $bonusDamage) : void
Parameters
- $bonusDamage : bool
shoot()
public
shoot(WeaponShotAtCombatant<string|int, TTarget> $shot) : MissedWeaponResult|HitWeaponResult<string|int, TTarget>
Parameters
- $shot : WeaponShotAtCombatant<string|int, TTarget>
Tags
Return values
MissedWeaponResult|HitWeaponResult<string|int, TTarget>__construct()
protected
__construct(int $weaponTypeID[, DatabaseRecord|null $dbRecord = null ]) : mixed
Parameters
- $weaponTypeID : int
- $dbRecord : DatabaseRecord|null = null
checkHit()
Given $weaponAccuracy as a percent, decide if the weapon hits.
protected
checkHit(CombatantInterface $shooter, CombatantInterface $target, float $weaponAccuracy) : bool
Parameters
- $shooter : CombatantInterface
- $target : CombatantInterface
- $weaponAccuracy : float
Return values
boolgetWeightedRandom()
protected
getWeightedRandom(CombatantInterface $shooter, CombatantInterface $target) : WeightedRandom
Parameters
- $shooter : CombatantInterface
- $target : CombatantInterface
Return values
WeightedRandomhitTarget()
Applies this weapon's modified damage and resolves a killing shot, if any.
protected
hitTarget(WeaponShotAtCombatant<string|int, TTarget> $shot) : HitWeaponResult<string|int, TTarget>
Parameters
- $shot : WeaponShotAtCombatant<string|int, TTarget>
Tags
Return values
HitWeaponResult<string|int, TTarget>getNumberOfEnhancements()
private
getNumberOfEnhancements() : int
Return values
inthasEnhancements()
private
hasEnhancements() : bool