Ship
extends AbstractShip
in package
Adds a database layer to an AbstractShip instance.
Loads and saves ship properties from/to the database.
Table of Contents
Constants
- SQL = 'account_id = :account_id AND game_id = :game_id'
- EXP_PER_DAMAGE_FORCE = 0.075
- EXP_PER_DAMAGE_PLANET = 1.0
- EXP_PER_DAMAGE_PLAYER = 0.375
- EXP_PER_DAMAGE_PORT = 0.15
- STARTER_SHIPS = [RACE_NEUTRAL => SHIP_TYPE_GALACTIC_SEMI, RACE_ALSKANT => SHIP_TYPE_SMALL_TIMER, RACE_CREONTI => SHIP_TYPE_MEDIUM_CARGO_HULK, RACE_HUMAN => SHIP_TYPE_LIGHT_FREIGHTER, RACE_IKTHORNE => SHIP_TYPE_TINY_DELIGHT, RACE_SALVENE => SHIP_TYPE_HATCHLINGS_DUE, RACE_THEVIAN => SHIP_TYPE_SWIFT_VENTURE, RACE_WQHUMAN => SHIP_TYPE_SLIP_FREIGHTER, RACE_NIJARIN => SHIP_TYPE_REDEEMER]
Properties
- $SQLID : array{account_id: int, game_id: int}
- $CACHE_SHIPS : array<int, array<int, self>>
- $cargo : array<int, int>
- $gameID : int
- $hardware : array<int, int>
- $hasChangedCargo : bool
- $hasChangedCloak : bool
- $hasChangedHardware : array<int, bool>
- $hasChangedIllusion : bool
- $hasChangedWeapons : bool
- $illusionShip : ShipIllusion|false
- $isCloaked : bool
- $player : AbstractPlayer
- $shipType : ShipType
- $weapons : array<int, Weapon>
Methods
- addWeapon() : Weapon|false
- canAttack() : bool
- checkForExcess() : void
- checkForExcessCargo() : void
- checkForExcessHardware() : void
- checkForExcessWeapons() : void
- checkPowerAvailable() : bool
- given power level of new weapon, return whether there is enough power available to install it on this ship
- clearCache() : void
- decloak() : void
- decreaseArmour() : void
- decreaseCargo() : void
- decreaseCDs() : void
- decreaseMines() : void
- decreaseSDs() : void
- decreaseShields() : void
- disableIllusion() : void
- enableCloak() : void
- getAccountID() : int
- getArmour() : int
- getArmourHigh() : int
- getArmourLow() : int
- getAttackRating() : int
- getAttackRatingWithMaxCDs() : int
- getCargo() : mixed
- getCargoHolds() : int
- getCDs() : int
- getCDsHigh() : int
- getCDsLow() : int
- getClass() : ShipClass
- getCost() : int
- getCostToUNO() : int
- getCostToUpgrade() : int
- getCostToUpgradeAndUNO() : int
- getDefenseRating() : int
- getDisplayAttackRating() : int
- getDisplayDefenseRating() : int
- getDisplayName() : string
- getEmptyHolds() : int
- getGame() : Game
- getGameID() : int
- getHardpoints() : int
- getHardware() : mixed
- getIllusion() : ShipIllusion|false
- getMaxArmour() : int
- getMaxCargoHolds() : int
- getMaxCDs() : int
- getMaxDefenseRating() : int
- getMaxMines() : int
- getMaxSDs() : int
- getMaxShields() : int
- getMines() : int
- getMR() : int
- Returns the maneuverability rating for this ship.
- getName() : string
- getNumWeapons() : int
- getOpenWeaponSlots() : int
- getPlayer() : AbstractPlayer
- getPod() : void
- getPowerUsed() : int
- getRealSpeed() : float
- Returns the ship speed modified by the game speed.
- getRefundValue() : int
- Trade-in value of the ship
- getRemainingPower() : int
- getSDs() : int
- getShieldHigh() : int
- getShieldLow() : int
- getShields() : int
- getShip() : self
- getTotalArmourDamage() : int
- getTotalShieldDamage() : int
- getType() : ShipType
- getTypeID() : int
- getUsedHolds() : int
- getWeapons() : array<int, Weapon>
- giveStarterShip() : void
- hasActiveIllusion() : bool
- hasArmour() : bool
- hasCargo() : bool
- hasCDs() : bool
- hasCloak() : bool
- hasDCS() : bool
- hasIllegalGoods() : bool
- hasIllusion() : bool
- hasJump() : bool
- hasMaxArmour() : bool
- hasMaxCargoHolds() : bool
- hasMaxCDs() : bool
- hasMaxHardware() : bool
- hasMaxMines() : bool
- hasMaxSDs() : bool
- hasMaxShields() : bool
- hasMines() : bool
- hasOpenWeaponSlots() : bool
- hasScanner() : bool
- hasSDs() : bool
- hasShields() : bool
- hasWeapons() : bool
- increaseArmour() : void
- increaseCargo() : void
- increaseCDs() : void
- increaseHardware() : void
- increaseMines() : void
- increaseSDs() : void
- increaseShields() : void
- isCloaked() : bool
- isDead() : bool
- isFederal() : bool
- isUnderground() : bool
- loadCloak() : void
- loadIllusion() : void
- moveWeaponDown() : void
- moveWeaponUp() : void
- removeAllCargo() : void
- removeAllHardware() : void
- removeAllWeapons() : void
- removeLastWeapon() : void
- removeWeapon() : void
- saveShips() : void
- setArmour() : void
- setCargo() : void
- setCargoHolds() : void
- setCDs() : void
- setHardware() : void
- setHardwareToMax() : void
- Set all hardware to its maximum value for this ship.
- setIllusion() : void
- setMines() : void
- setSDs() : void
- setShields() : void
- setTypeID() : void
- Switch to a new ship, updating player turns accordingly.
- setWeaponLocations() : void
- shootForces() : ForceAttackerCombatResult
- shootPlanet() : PlanetAttackerCombatResult
- shootPlayers() : TraderCombatResult
- shootPort() : PortAttackerCombatResult
- takeDamage() : TakenDamageData
- takeDamageFromMines() : TakenDamageData
- update() : void
- updateCargo() : void
- updateCloak() : void
- updateHardware() : void
- updateIllusion() : void
- __construct() : mixed
- getCostToUNOAgainstShip() : int
- loadCargo() : void
- loadHardware() : void
- loadWeapons() : void
- Initialize the weapons onboard this ship.
- regenerateShipType() : void
- takeDamageToArmour() : int
- takeDamageToCDs() : int
- takeDamageToShields() : int
- updateWeapons() : void
Constants
SQL
public
mixed
SQL
= 'account_id = :account_id AND game_id = :game_id'
EXP_PER_DAMAGE_FORCE
protected
mixed
EXP_PER_DAMAGE_FORCE
= 0.075
EXP_PER_DAMAGE_PLANET
protected
mixed
EXP_PER_DAMAGE_PLANET
= 1.0
EXP_PER_DAMAGE_PLAYER
protected
mixed
EXP_PER_DAMAGE_PLAYER
= 0.375
EXP_PER_DAMAGE_PORT
protected
mixed
EXP_PER_DAMAGE_PORT
= 0.15
STARTER_SHIPS
protected
mixed
STARTER_SHIPS
= [RACE_NEUTRAL => SHIP_TYPE_GALACTIC_SEMI, RACE_ALSKANT => SHIP_TYPE_SMALL_TIMER, RACE_CREONTI => SHIP_TYPE_MEDIUM_CARGO_HULK, RACE_HUMAN => SHIP_TYPE_LIGHT_FREIGHTER, RACE_IKTHORNE => SHIP_TYPE_TINY_DELIGHT, RACE_SALVENE => SHIP_TYPE_HATCHLINGS_DUE, RACE_THEVIAN => SHIP_TYPE_SWIFT_VENTURE, RACE_WQHUMAN => SHIP_TYPE_SLIP_FREIGHTER, RACE_NIJARIN => SHIP_TYPE_REDEEMER]
Properties
$SQLID read-only
public
array{account_id: int, game_id: int}
$SQLID
$CACHE_SHIPS
protected
static array<int, array<int, self>>
$CACHE_SHIPS
= []
$cargo
protected
array<int, int>
$cargo
= []
$gameID
protected
int
$gameID
$hardware
protected
array<int, int>
$hardware
= []
$hasChangedCargo
protected
bool
$hasChangedCargo
= false
$hasChangedCloak
protected
bool
$hasChangedCloak
= false
$hasChangedHardware
protected
array<int, bool>
$hasChangedHardware
= []
$hasChangedIllusion
protected
bool
$hasChangedIllusion
= false
$hasChangedWeapons
protected
bool
$hasChangedWeapons
= false
$illusionShip
protected
ShipIllusion|false
$illusionShip
= false
$isCloaked
protected
bool
$isCloaked
= false
$player
protected
AbstractPlayer
$player
$shipType
protected
ShipType
$shipType
$weapons
protected
array<int, Weapon>
$weapons
= []
Methods
addWeapon()
public
addWeapon(Weapon $weapon) : Weapon|false
Parameters
- $weapon : Weapon
Return values
Weapon|falsecanAttack()
public
canAttack() : bool
Return values
boolcheckForExcess()
public
checkForExcess() : void
checkForExcessCargo()
public
checkForExcessCargo() : void
checkForExcessHardware()
public
checkForExcessHardware() : void
checkForExcessWeapons()
public
checkForExcessWeapons() : void
checkPowerAvailable()
given power level of new weapon, return whether there is enough power available to install it on this ship
public
checkPowerAvailable(int $powerLevel) : bool
Parameters
- $powerLevel : int
Return values
boolclearCache()
public
static clearCache() : void
decloak()
public
decloak() : void
decreaseArmour()
public
decreaseArmour(int $amount) : void
Parameters
- $amount : int
decreaseCargo()
public
decreaseCargo(int $goodID, int $amount) : void
Parameters
- $goodID : int
- $amount : int
decreaseCDs()
public
decreaseCDs(int $amount) : void
Parameters
- $amount : int
decreaseMines()
public
decreaseMines(int $amount) : void
Parameters
- $amount : int
decreaseSDs()
public
decreaseSDs(int $amount) : void
Parameters
- $amount : int
decreaseShields()
public
decreaseShields(int $amount) : void
Parameters
- $amount : int
disableIllusion()
public
disableIllusion() : void
enableCloak()
public
enableCloak() : void
getAccountID()
public
getAccountID() : int
Return values
intgetArmour()
public
getArmour() : int
Return values
intgetArmourHigh()
public
getArmourHigh() : int
Return values
intgetArmourLow()
public
getArmourLow() : int
Return values
intgetAttackRating()
public
getAttackRating() : int
Return values
intgetAttackRatingWithMaxCDs()
public
getAttackRatingWithMaxCDs() : int
Return values
intgetCargo()
public
getCargo([int|null $goodID = null ]) : mixed
Parameters
- $goodID : int|null = null
getCargoHolds()
public
getCargoHolds() : int
Return values
intgetCDs()
public
getCDs() : int
Return values
intgetCDsHigh()
public
getCDsHigh() : int
Return values
intgetCDsLow()
public
getCDsLow() : int
Return values
intgetClass()
public
getClass() : ShipClass
Return values
ShipClassgetCost()
public
getCost() : int
Return values
intgetCostToUNO()
public
getCostToUNO() : int
Return values
intgetCostToUpgrade()
public
getCostToUpgrade(int $otherShipTypeID) : int
Parameters
- $otherShipTypeID : int
Return values
intgetCostToUpgradeAndUNO()
public
getCostToUpgradeAndUNO(int $otherShipTypeID) : int
Parameters
- $otherShipTypeID : int
Return values
intgetDefenseRating()
public
getDefenseRating() : int
Return values
intgetDisplayAttackRating()
public
getDisplayAttackRating() : int
Return values
intgetDisplayDefenseRating()
public
getDisplayDefenseRating() : int
Return values
intgetDisplayName()
public
getDisplayName() : string
Return values
stringgetEmptyHolds()
public
getEmptyHolds() : int
Return values
intgetGame()
public
getGame() : Game
Return values
GamegetGameID()
public
getGameID() : int
Return values
intgetHardpoints()
public
getHardpoints() : int
Return values
intgetHardware()
public
getHardware([int|null $hardwareTypeID = null ]) : mixed
Parameters
- $hardwareTypeID : int|null = null
getIllusion()
public
getIllusion() : ShipIllusion|false
Return values
ShipIllusion|falsegetMaxArmour()
public
getMaxArmour() : int
Return values
intgetMaxCargoHolds()
public
getMaxCargoHolds() : int
Return values
intgetMaxCDs()
public
getMaxCDs() : int
Return values
intgetMaxDefenseRating()
public
getMaxDefenseRating() : int
Return values
intgetMaxMines()
public
getMaxMines() : int
Return values
intgetMaxSDs()
public
getMaxSDs() : int
Return values
intgetMaxShields()
public
getMaxShields() : int
Return values
intgetMines()
public
getMines() : int
Return values
intgetMR()
Returns the maneuverability rating for this ship.
public
getMR() : int
Return values
intgetName()
public
getName() : string
Return values
stringgetNumWeapons()
public
getNumWeapons() : int
Return values
intgetOpenWeaponSlots()
public
getOpenWeaponSlots() : int
Return values
intgetPlayer()
public
getPlayer() : AbstractPlayer
Return values
AbstractPlayergetPod()
public
getPod([bool $isNewbie = false ]) : void
Parameters
- $isNewbie : bool = false
getPowerUsed()
public
getPowerUsed() : int
Return values
intgetRealSpeed()
Returns the ship speed modified by the game speed.
public
getRealSpeed() : float
Return values
floatgetRefundValue()
Trade-in value of the ship
public
getRefundValue() : int
Return values
intgetRemainingPower()
public
getRemainingPower() : int
Return values
intgetSDs()
public
getSDs() : int
Return values
intgetShieldHigh()
public
getShieldHigh() : int
Return values
intgetShieldLow()
public
getShieldLow() : int
Return values
intgetShields()
public
getShields() : int
Return values
intgetShip()
public
static getShip(AbstractPlayer $player[, bool $forceUpdate = false ]) : self
Parameters
- $player : AbstractPlayer
- $forceUpdate : bool = false
Return values
selfgetTotalArmourDamage()
public
getTotalArmourDamage() : int
Return values
intgetTotalShieldDamage()
public
getTotalShieldDamage() : int
Return values
intgetType()
public
getType() : ShipType
Return values
ShipTypegetTypeID()
public
getTypeID() : int
Return values
intgetUsedHolds()
public
getUsedHolds() : int
Return values
intgetWeapons()
public
getWeapons() : array<int, Weapon>
Return values
array<int, Weapon>giveStarterShip()
public
giveStarterShip() : void
hasActiveIllusion()
public
hasActiveIllusion() : bool
Tags
Return values
boolhasArmour()
public
hasArmour() : bool
Return values
boolhasCargo()
public
hasCargo([int|null $goodID = null ]) : bool
Parameters
- $goodID : int|null = null
Return values
boolhasCDs()
public
hasCDs() : bool
Return values
boolhasCloak()
public
hasCloak() : bool
Return values
boolhasDCS()
public
hasDCS() : bool
Return values
boolhasIllegalGoods()
public
hasIllegalGoods() : bool
Return values
boolhasIllusion()
public
hasIllusion() : bool
Return values
boolhasJump()
public
hasJump() : bool
Return values
boolhasMaxArmour()
public
hasMaxArmour() : bool
Return values
boolhasMaxCargoHolds()
public
hasMaxCargoHolds() : bool
Return values
boolhasMaxCDs()
public
hasMaxCDs() : bool
Return values
boolhasMaxHardware()
public
hasMaxHardware(int $hardwareTypeID) : bool
Parameters
- $hardwareTypeID : int
Return values
boolhasMaxMines()
public
hasMaxMines() : bool
Return values
boolhasMaxSDs()
public
hasMaxSDs() : bool
Return values
boolhasMaxShields()
public
hasMaxShields() : bool
Return values
boolhasMines()
public
hasMines() : bool
Return values
boolhasOpenWeaponSlots()
public
hasOpenWeaponSlots() : bool
Return values
boolhasScanner()
public
hasScanner() : bool
Return values
boolhasSDs()
public
hasSDs() : bool
Return values
boolhasShields()
public
hasShields() : bool
Return values
boolhasWeapons()
public
hasWeapons() : bool
Return values
boolincreaseArmour()
public
increaseArmour(int $amount) : void
Parameters
- $amount : int
increaseCargo()
public
increaseCargo(int $goodID, int $amount) : void
Parameters
- $goodID : int
- $amount : int
increaseCDs()
public
increaseCDs(int $amount) : void
Parameters
- $amount : int
increaseHardware()
public
increaseHardware(int $hardwareTypeID, int $amount) : void
Parameters
- $hardwareTypeID : int
- $amount : int
increaseMines()
public
increaseMines(int $amount) : void
Parameters
- $amount : int
increaseSDs()
public
increaseSDs(int $amount) : void
Parameters
- $amount : int
increaseShields()
public
increaseShields(int $amount) : void
Parameters
- $amount : int
isCloaked()
public
isCloaked() : bool
Return values
boolisDead()
public
isDead() : bool
Return values
boolisFederal()
public
isFederal() : bool
Return values
boolisUnderground()
public
isUnderground() : bool
Return values
boolloadCloak()
public
loadCloak() : void
loadIllusion()
public
loadIllusion() : void
moveWeaponDown()
public
moveWeaponDown(int $orderID) : void
Parameters
- $orderID : int
moveWeaponUp()
public
moveWeaponUp(int $orderID) : void
Parameters
- $orderID : int
removeAllCargo()
public
removeAllCargo() : void
removeAllHardware()
public
removeAllHardware() : void
removeAllWeapons()
public
removeAllWeapons() : void
removeLastWeapon()
public
removeLastWeapon() : void
removeWeapon()
public
removeWeapon(int $orderID) : void
Parameters
- $orderID : int
saveShips()
public
static saveShips() : void
setArmour()
public
setArmour(int $amount) : void
Parameters
- $amount : int
setCargo()
public
setCargo(int $goodID, int $amount) : void
Parameters
- $goodID : int
- $amount : int
setCargoHolds()
public
setCargoHolds(int $amount) : void
Parameters
- $amount : int
setCDs()
public
setCDs(int $amount) : void
Parameters
- $amount : int
setHardware()
public
setHardware(int $hardwareTypeID, int $amount) : void
Parameters
- $hardwareTypeID : int
- $amount : int
setHardwareToMax()
Set all hardware to its maximum value for this ship.
public
setHardwareToMax() : void
setIllusion()
public
setIllusion(int $shipTypeID, int $attack, int $defense) : void
Parameters
- $shipTypeID : int
- $attack : int
- $defense : int
setMines()
public
setMines(int $amount) : void
Parameters
- $amount : int
setSDs()
public
setSDs(int $amount) : void
Parameters
- $amount : int
setShields()
public
setShields(int $amount) : void
Parameters
- $amount : int
setTypeID()
Switch to a new ship, updating player turns accordingly.
public
setTypeID(int $shipTypeID) : void
Parameters
- $shipTypeID : int
setWeaponLocations()
public
setWeaponLocations(array<int, int> $orderArray) : void
Parameters
- $orderArray : array<int, int>
shootForces()
public
shootForces(Force $forces) : ForceAttackerCombatResult
Parameters
- $forces : Force
Return values
ForceAttackerCombatResultshootPlanet()
public
shootPlanet(Planet $planet) : PlanetAttackerCombatResult
Parameters
- $planet : Planet
Return values
PlanetAttackerCombatResultshootPlayers()
public
shootPlayers(array<string|int, AbstractPlayer> $targetPlayers) : TraderCombatResult
Parameters
- $targetPlayers : array<string|int, AbstractPlayer>
Return values
TraderCombatResultshootPort()
public
shootPort(Port $port) : PortAttackerCombatResult
Parameters
- $port : Port
Return values
PortAttackerCombatResulttakeDamage()
public
takeDamage(WeaponDamageData $damage) : TakenDamageData
Parameters
- $damage : WeaponDamageData
Return values
TakenDamageDatatakeDamageFromMines()
public
takeDamageFromMines(WeaponDamageData $damage) : TakenDamageData
Parameters
- $damage : WeaponDamageData
Return values
TakenDamageDataupdate()
public
update() : void
updateCargo()
public
updateCargo() : void
updateCloak()
public
updateCloak() : void
updateHardware()
public
updateHardware() : void
updateIllusion()
public
updateIllusion() : void
__construct()
protected
__construct(AbstractPlayer $player) : mixed
Parameters
- $player : AbstractPlayer
getCostToUNOAgainstShip()
protected
getCostToUNOAgainstShip(int $otherShipTypeID) : int
Parameters
- $otherShipTypeID : int
Return values
intloadCargo()
protected
loadCargo() : void
loadHardware()
protected
loadHardware() : void
loadWeapons()
Initialize the weapons onboard this ship.
protected
loadWeapons() : void
regenerateShipType()
protected
regenerateShipType() : void
takeDamageToArmour()
protected
takeDamageToArmour(int $damage) : int
Parameters
- $damage : int
Return values
inttakeDamageToCDs()
protected
takeDamageToCDs(int $damage) : int
Parameters
- $damage : int
Return values
inttakeDamageToShields()
protected
takeDamageToShields(int $damage) : int
Parameters
- $damage : int
Return values
intupdateWeapons()
private
updateWeapons() : void