Documentation

Port
in package
Uses RaceID

Table of Contents

Constants

CLAIM_PAYOUT  = 0.5
DAMAGE_NEEDED_FOR_ALIGNMENT_CHANGE  = 300
KILLER_RELATIONS_LOSS  = 45
RAZE_PAYOUT  = 0.75
SQL  = 'sector_id = :sector_id AND game_id = :game_id'
BASE_CDS  = 725
BASE_DEFENCES  = 500
BASE_PAYOUT  = 0.85
BASE_REFRESH_PER_HOUR  = ['1' => 150, '2' => 110, '3' => 70]
CDS_PER_LEVEL  = 100
CDS_PER_TEN_MIL_CREDITS  = 25
CHANCE_TO_DOWNGRADE  = 1
DAMAGE_NEEDED_FOR_DOWNGRADE_CHANCE  = 325
DEFENCES_PER_LEVEL  = 700
DEFENCES_PER_TEN_MIL_CREDITS  = 250
GOODS_TRADED_MONEY_MULTIPLIER  = 50
MAX_FEDS_BONUS  = 4000
REFRESH_PER_GOOD  = 0.9
TIME_FEDS_STAY  = 1800
TIME_TO_CREDIT_RAID  = 10800

Properties

$SQLID  : array{sector_id: int, game_id: int}
$armour  : int
$attackStarted  : int
$CACHE_CACHED_PORTS  : array<int, array<int, array<int, self|false>>>
$CACHE_PORTS  : array<int, array<int, self>>
$cachedTime  : int
$cachedVersion  : bool
$cacheIsValid  : bool
$combatDrones  : int
$credits  : int
$experience  : int
$gameID  : int
$goodAmounts  : array<int, int>
$goodAmountsChanged  : array<int, bool>
$goodDistances  : array<int, int>
$goodTransactions  : array<int, TransactionType>
$goodTransactionsChanged  : array<int, bool>
$hasChanged  : bool
$isNew  : bool
$level  : int
$raceID  : int
$reinforceTime  : int
$sectorID  : int
$shields  : int
$upgrade  : int

Methods

__sleep()  : mixed
__wakeup()  : mixed
addCachePort()  : void
addCachePorts()  : bool
addPortGood()  : void
Add good with given ID to the port, with transaction $type as either "Buy" or "Sell", meaning the player buys or sells.
attackedBy()  : void
buyGoods()  : void
calculateExperiencePercent()  : float
Return the fraction of max exp earned.
canBeDestroyed()  : bool
Can ports be destroyed after a successful port raid?
checkDefenses()  : void
checkForDowngrade()  : int
Returns the number of port level downgrades due to damage taken.
checkForUpgrade()  : int
claimPort()  : int
Claim port for your race after a successful port raid.
clearCache()  : void
createPort()  : self
decreaseArmour()  : void
decreaseCDs()  : void
decreaseCredits()  : void
decreaseGood()  : void
decreaseGoodAmount()  : void
decreaseLevel()  : void
decreaseShields()  : void
decreaseUpgrade()  : void
destroyPort()  : int
Permanently destroy the port after a successful port raid.
exists()  : bool
getAllGoodIDs()  : array<string|int, int>
getArmour()  : int
getAttackersToCredit()  : array<string|int, Player>
getAttackHREF()  : string
getAttackStarted()  : int
getBaseExperience()  : float
getBuyGoodIDs()  : array<string|int, int>
Get IDs of goods that can be bought from the port by the trader
getCachedPort()  : self
getCachedTime()  : int
getCDs()  : int
getCredits()  : int
getCreditsPercent()  : float
getDisplayName()  : string
getExperience()  : int
getGalaxyPorts()  : array<int, self>
getGame()  : Game
getGameID()  : int
getGoodAmount()  : int
getGoodDistance()  : int
getGoodTransaction()  : TransactionType
Returns the transaction type for this good (Buy or Sell).
getGoodTransactions()  : array<int, TransactionType>
getIdealPrice()  : int
getLevel()  : int
getLootGoodHREF()  : string
getMaxLevel()  : int
getMaxLevelByGame()  : int
getNumWeapons()  : int
getOfferPrice()  : int
getPayoutHREF()  : string
getPort()  : self
getRaceID()  : int
getRaceName()  : string
getRaidWarningHREF()  : string
getReinforcePercent()  : float
getReinforceTime()  : int
getSector()  : Sector
getSectorID()  : int
getSellGoodIDs()  : array<string|int, int>
Get IDs of goods that can be sold to the port by the trader
getShields()  : int
getTradeRestriction()  : string|false
getUpgrade()  : int
getUpgradePercent()  : float
getUpgradeRequirement()  : int
getVisibleGoodsBought()  : array<int, TradeGood>
Get goods that can be bought by $player from the port
getVisibleGoodsSold()  : array<int, TradeGood>
Get goods that can be sold by $player to the port
getWeapons()  : array<string|int, Weapon>
hasArmour()  : bool
hasCDs()  : bool
hasGood()  : bool
hasShields()  : bool
idealPrice()  : int
Generic ideal price calculation, given all parameters as input.
increaseCredits()  : void
increaseExperience()  : void
increaseGoodAmount()  : void
increaseLevel()  : void
increaseUpgrade()  : void
isBusted()  : bool
isCachedVersion()  : bool
isCreditedAttacker()  : bool
Identifies if the given $player is a credited attacker of this port.
isUnderAttack()  : bool
killPortByPlayer()  : array{}
lootPort()  : int
Get a fraction of the credits stored in the port for looting after a successful port raid.
razePort()  : int
Get a reduced fraction of the credits stored in the port for razing after a successful port raid.
removePort()  : void
removePortGood()  : void
Remove good with given ID from the port.
savePorts()  : void
sellGoods()  : void
setArmour()  : void
setCDs()  : void
setCredits()  : void
setCreditsToDefault()  : void
setExperience()  : void
setLevel()  : void
setPortGoods()  : bool
Manually set port goods.
setRaceID()  : void
setReinforceTime()  : void
setShields()  : void
setUpgrade()  : void
shootPlayers()  : PortCombatResults
stealGoods()  : void
takeDamage()  : TakenDamageData
update()  : void
updateSectorPlayersCache()  : void
upgradeToLevel()  : void
This function should only be used in universe creation to set ports to a specific level.
__construct()  : mixed
creditCurrentAttackersForKill()  : void
doDowngrade()  : void
doUpgrade()  : void
getGoodClassAtLevel()  : int
Returns the good class associated with the given level.
payout()  : bool
refreshGoods()  : void
Adds extra stock to goods in the tier above a good that was traded
selectAndAddGood()  : TradeGood
selectAndRemoveGood()  : void
setCachedTime()  : void
takeDamageToArmour()  : int
takeDamageToCDs()  : int
takeDamageToShields()  : int
tradeGoods()  : void
getGoods()  : void
getVisibleGoods()  : array<int, TradeGood>
restockGood()  : void
Used for the automatic resupplying of all goods over time
setAttackStarted()  : void
setGoodAmount()  : void
updateAttackStarted()  : void

Constants

CLAIM_PAYOUT

public mixed CLAIM_PAYOUT = 0.5

DAMAGE_NEEDED_FOR_ALIGNMENT_CHANGE

public mixed DAMAGE_NEEDED_FOR_ALIGNMENT_CHANGE = 300

KILLER_RELATIONS_LOSS

public mixed KILLER_RELATIONS_LOSS = 45

RAZE_PAYOUT

public mixed RAZE_PAYOUT = 0.75

SQL

public mixed SQL = 'sector_id = :sector_id AND game_id = :game_id'

BASE_CDS

protected mixed BASE_CDS = 725

BASE_DEFENCES

protected mixed BASE_DEFENCES = 500

BASE_PAYOUT

protected mixed BASE_PAYOUT = 0.85

BASE_REFRESH_PER_HOUR

protected mixed BASE_REFRESH_PER_HOUR = ['1' => 150, '2' => 110, '3' => 70]

CDS_PER_LEVEL

protected mixed CDS_PER_LEVEL = 100

CDS_PER_TEN_MIL_CREDITS

protected mixed CDS_PER_TEN_MIL_CREDITS = 25

CHANCE_TO_DOWNGRADE

protected mixed CHANCE_TO_DOWNGRADE = 1

DAMAGE_NEEDED_FOR_DOWNGRADE_CHANCE

protected mixed DAMAGE_NEEDED_FOR_DOWNGRADE_CHANCE = 325

DEFENCES_PER_LEVEL

protected mixed DEFENCES_PER_LEVEL = 700

DEFENCES_PER_TEN_MIL_CREDITS

protected mixed DEFENCES_PER_TEN_MIL_CREDITS = 250

GOODS_TRADED_MONEY_MULTIPLIER

protected mixed GOODS_TRADED_MONEY_MULTIPLIER = 50

MAX_FEDS_BONUS

protected mixed MAX_FEDS_BONUS = 4000

REFRESH_PER_GOOD

protected mixed REFRESH_PER_GOOD = 0.9

TIME_FEDS_STAY

protected mixed TIME_FEDS_STAY = 1800

TIME_TO_CREDIT_RAID

protected mixed TIME_TO_CREDIT_RAID = 10800

Properties

$SQLID read-only

public array{sector_id: int, game_id: int} $SQLID

$armour

protected int $armour

$attackStarted

protected int $attackStarted

$CACHE_CACHED_PORTS

protected static array<int, array<int, array<int, self|false>>> $CACHE_CACHED_PORTS = []

$CACHE_PORTS

protected static array<int, array<int, self>> $CACHE_PORTS = []

$cachedTime

protected int $cachedTime

$cachedVersion

protected bool $cachedVersion = false

$cacheIsValid

protected bool $cacheIsValid = true

$combatDrones

protected int $combatDrones

$credits

protected int $credits

$experience

protected int $experience

$gameID read-only

protected int $gameID

$goodAmounts

protected array<int, int> $goodAmounts

$goodAmountsChanged

protected array<int, bool> $goodAmountsChanged = []

$goodDistances

protected array<int, int> $goodDistances

$goodTransactionsChanged

protected array<int, bool> $goodTransactionsChanged = []

$hasChanged

protected bool $hasChanged = false

$isNew

protected bool $isNew = false

$level

protected int $level

$reinforceTime

protected int $reinforceTime

$sectorID read-only

protected int $sectorID

$shields

protected int $shields

$upgrade

protected int $upgrade

Methods

__sleep()

public __sleep() : mixed

__wakeup()

public __wakeup() : mixed

addCachePort()

public addCachePort(int $accountID) : void
Parameters
$accountID : int

addCachePorts()

public addCachePorts(array<string|int, int> $accountIDs) : bool
Parameters
$accountIDs : array<string|int, int>
Return values
bool

addPortGood()

Add good with given ID to the port, with transaction $type as either "Buy" or "Sell", meaning the player buys or sells.

public addPortGood(int $goodID, TransactionType $type) : void

If the port already has this transaction, do nothing.

NOTE: make sure to adjust the port level appropriately if calling this function directly.

Parameters
$goodID : int
$type : TransactionType

buyGoods()

public buyGoods(TradeGood $good, int $goodsTraded, int $idealPrice, int $bargainPrice, int $exp) : void
Parameters
$good : TradeGood
$goodsTraded : int
$idealPrice : int
$bargainPrice : int
$exp : int

calculateExperiencePercent()

Return the fraction of max exp earned.

public calculateExperiencePercent(int $idealPrice, int $bargainPrice, TransactionType $transactionType) : float
Parameters
$idealPrice : int
$bargainPrice : int
$transactionType : TransactionType
Return values
float

canBeDestroyed()

Can ports be destroyed after a successful port raid?

public canBeDestroyed() : bool
Return values
bool

checkDefenses()

public checkDefenses() : void

checkForDowngrade()

Returns the number of port level downgrades due to damage taken.

public checkForDowngrade(int $damage) : int
Parameters
$damage : int
Return values
int

checkForUpgrade()

public checkForUpgrade() : int
Return values
int

claimPort()

Claim port for your race after a successful port raid.

public claimPort(AbstractPlayer $killer) : int
Parameters
$killer : AbstractPlayer
Return values
int

clearCache()

public static clearCache() : void

createPort()

public static createPort(int $gameID, int $sectorID) : self
Parameters
$gameID : int
$sectorID : int
Return values
self

decreaseArmour()

public decreaseArmour(int $number) : void
Parameters
$number : int

decreaseCDs()

public decreaseCDs(int $number) : void
Parameters
$number : int

decreaseCredits()

public decreaseCredits(int $credits) : void
Parameters
$credits : int

decreaseGood()

public decreaseGood(TradeGood $good, int $amount, bool $doRefresh) : void
Parameters
$good : TradeGood
$amount : int
$doRefresh : bool

decreaseGoodAmount()

public decreaseGoodAmount(int $goodID, int $amount) : void
Parameters
$goodID : int
$amount : int

decreaseLevel()

public decreaseLevel(int $level) : void
Parameters
$level : int

decreaseShields()

public decreaseShields(int $number) : void
Parameters
$number : int

decreaseUpgrade()

public decreaseUpgrade(int $upgrade) : void
Parameters
$upgrade : int

destroyPort()

Permanently destroy the port after a successful port raid.

public destroyPort(AbstractPlayer $killer) : int
Parameters
$killer : AbstractPlayer
Return values
int

exists()

public exists() : bool
Return values
bool

getAllGoodIDs()

public getAllGoodIDs() : array<string|int, int>
Return values
array<string|int, int>

getArmour()

public getArmour() : int
Return values
int

getAttackersToCredit()

public getAttackersToCredit() : array<string|int, Player>
Return values
array<string|int, Player>

getAttackHREF()

public getAttackHREF() : string
Return values
string

getAttackStarted()

public getAttackStarted() : int
Return values
int

getBaseExperience()

public static getBaseExperience(int $cargo, int $distance) : float
Parameters
$cargo : int
$distance : int
Return values
float

getBuyGoodIDs()

Get IDs of goods that can be bought from the port by the trader

public getBuyGoodIDs() : array<string|int, int>
Return values
array<string|int, int>

getCachedPort()

public static getCachedPort(int $gameID, int $sectorID, int $accountID[, bool $forceUpdate = false ]) : self
Parameters
$gameID : int
$sectorID : int
$accountID : int
$forceUpdate : bool = false
Tags
throws
CachedPortNotFound

If the cached port is not found in the database.

Return values
self

getCachedTime()

public getCachedTime() : int
Return values
int

getCDs()

public getCDs() : int
Return values
int

getCredits()

public getCredits() : int
Return values
int

getCreditsPercent()

public getCreditsPercent() : float
Return values
float

getDisplayName()

public getDisplayName() : string
Return values
string

getExperience()

public getExperience() : int
Return values
int

getGalaxyPorts()

public static getGalaxyPorts(int $gameID, int $galaxyID[, bool $forceUpdate = false ]) : array<int, self>
Parameters
$gameID : int
$galaxyID : int
$forceUpdate : bool = false
Return values
array<int, self>

getGameID()

public getGameID() : int
Return values
int

getGoodAmount()

public getGoodAmount(int $goodID) : int
Parameters
$goodID : int
Return values
int

getGoodDistance()

public getGoodDistance(int $goodID) : int
Parameters
$goodID : int
Return values
int

getGoodTransaction()

Returns the transaction type for this good (Buy or Sell).

public getGoodTransaction(int $goodID) : TransactionType

Note: this is the player's transaction, not the port's.

Parameters
$goodID : int
Return values
TransactionType

getIdealPrice()

public getIdealPrice(int $goodID, TransactionType $transactionType, int $numGoods, int $relations) : int
Parameters
$goodID : int
$transactionType : TransactionType
$numGoods : int
$relations : int
Return values
int

getLevel()

public getLevel() : int
Return values
int

getLootGoodHREF()

public getLootGoodHREF(int $boughtGoodID) : string
Parameters
$boughtGoodID : int
Return values
string

getMaxLevel()

public getMaxLevel() : int
Return values
int

getMaxLevelByGame()

public static getMaxLevelByGame(int $gameID) : int
Parameters
$gameID : int
Return values
int

getNumWeapons()

public getNumWeapons() : int
Return values
int

getOfferPrice()

public getOfferPrice(int $idealPrice, int $relations, TransactionType $transactionType) : int
Parameters
$idealPrice : int
$relations : int
$transactionType : TransactionType
Return values
int

getPort()

public static getPort(int $gameID, int $sectorID[, bool $forceUpdate = false ][, DatabaseRecord $dbRecord = null ]) : self
Parameters
$gameID : int
$sectorID : int
$forceUpdate : bool = false
$dbRecord : DatabaseRecord = null
Return values
self

getRaceID()

public getRaceID() : int
Return values
int

getRaceName()

public getRaceName() : string
Return values
string

getRaidWarningHREF()

public getRaidWarningHREF() : string
Return values
string

getReinforcePercent()

public getReinforcePercent() : float
Return values
float

getReinforceTime()

public getReinforceTime() : int
Return values
int

getSectorID()

public getSectorID() : int
Return values
int

getSellGoodIDs()

Get IDs of goods that can be sold to the port by the trader

public getSellGoodIDs() : array<string|int, int>
Return values
array<string|int, int>

getShields()

public getShields() : int
Return values
int

getUpgrade()

public getUpgrade() : int
Return values
int

getUpgradePercent()

public getUpgradePercent() : float
Return values
float

getUpgradeRequirement()

public getUpgradeRequirement() : int
Return values
int

getWeapons()

public getWeapons() : array<string|int, Weapon>
Return values
array<string|int, Weapon>

hasArmour()

public hasArmour() : bool
Return values
bool

hasCDs()

public hasCDs() : bool
Return values
bool

hasShields()

public hasShields() : bool
Return values
bool

idealPrice()

Generic ideal price calculation, given all parameters as input.

public static idealPrice(int $goodID, TransactionType $transactionType, int $numGoods, int $relations, int $supply, int $dist) : int
Parameters
$goodID : int
$transactionType : TransactionType
$numGoods : int
$relations : int
$supply : int
$dist : int
Return values
int

increaseCredits()

public increaseCredits(int $credits) : void
Parameters
$credits : int

increaseExperience()

public increaseExperience(int $experience) : void
Parameters
$experience : int

increaseGoodAmount()

public increaseGoodAmount(int $goodID, int $amount) : void
Parameters
$goodID : int
$amount : int

increaseLevel()

public increaseLevel(int $level) : void
Parameters
$level : int

increaseUpgrade()

public increaseUpgrade(int $upgrade) : void
Parameters
$upgrade : int

isBusted()

public isBusted() : bool
Return values
bool

isCachedVersion()

public isCachedVersion() : bool
Return values
bool

isCreditedAttacker()

Identifies if the given $player is a credited attacker of this port.

public isCreditedAttacker(AbstractPlayer $player) : bool
Parameters
$player : AbstractPlayer
Return values
bool

isUnderAttack()

public isUnderAttack() : bool
Return values
bool

lootPort()

Get a fraction of the credits stored in the port for looting after a successful port raid.

public lootPort(AbstractPlayer $killer) : int
Parameters
$killer : AbstractPlayer
Return values
int

razePort()

Get a reduced fraction of the credits stored in the port for razing after a successful port raid.

public razePort(AbstractPlayer $killer) : int
Parameters
$killer : AbstractPlayer
Return values
int

removePort()

public static removePort(int $gameID, int $sectorID) : void
Parameters
$gameID : int
$sectorID : int

removePortGood()

Remove good with given ID from the port.

public removePortGood(int $goodID) : void

If the port does not have this good, do nothing.

NOTE: make sure to adjust the port level appropriately if calling this function directly.

Parameters
$goodID : int

savePorts()

public static savePorts() : void

sellGoods()

public sellGoods(TradeGood $good, int $goodsTraded, int $exp) : void
Parameters
$good : TradeGood
$goodsTraded : int
$exp : int

setArmour()

public setArmour(int $armour) : void
Parameters
$armour : int

setCDs()

public setCDs(int $combatDrones) : void
Parameters
$combatDrones : int

setCredits()

public setCredits(int $credits) : void
Parameters
$credits : int

setCreditsToDefault()

public setCreditsToDefault() : void

setExperience()

public setExperience(int $experience) : void
Parameters
$experience : int

setLevel()

public setLevel(int $level) : void
Parameters
$level : int

setPortGoods()

Manually set port goods.

public setPortGoods(array<int, TransactionType$goodTransactions) : bool

Only modifies goods that need to change. Returns false on invalid input.

Parameters
$goodTransactions : array<int, TransactionType>
Return values
bool

setRaceID()

public setRaceID(int $raceID) : void
Parameters
$raceID : int

setReinforceTime()

public setReinforceTime(int $reinforceTime) : void
Parameters
$reinforceTime : int

setShields()

public setShields(int $shields) : void
Parameters
$shields : int

setUpgrade()

public setUpgrade(int $upgrade) : void
Parameters
$upgrade : int

shootPlayers()

public shootPlayers(array<string|int, AbstractPlayer$targetPlayers) : PortCombatResults
Parameters
$targetPlayers : array<string|int, AbstractPlayer>
Return values
PortCombatResults

stealGoods()

public stealGoods(TradeGood $good, int $goodsTraded) : void
Parameters
$good : TradeGood
$goodsTraded : int

takeDamage()

public takeDamage(WeaponDamageData $damage) : TakenDamageData
Parameters
$damage : WeaponDamageData
Return values
TakenDamageData

update()

public update() : void

updateSectorPlayersCache()

public updateSectorPlayersCache() : void

upgradeToLevel()

This function should only be used in universe creation to set ports to a specific level.

public upgradeToLevel(int $level) : void
Parameters
$level : int

__construct()

protected __construct(int $gameID, int $sectorID[, DatabaseRecord $dbRecord = null ]) : mixed
Parameters
$gameID : int
$sectorID : int
$dbRecord : DatabaseRecord = null

creditCurrentAttackersForKill()

protected creditCurrentAttackersForKill() : void

doDowngrade()

protected doDowngrade() : void

doUpgrade()

protected doUpgrade() : void

getGoodClassAtLevel()

Returns the good class associated with the given level.

protected getGoodClassAtLevel([int $level = null ]) : int

If no level specified, will use the current port level. This is useful for determining what trade goods to add/remove.

Parameters
$level : int = null
Return values
int

payout()

protected payout(AbstractPlayer $killer, int $credits, string $payoutType) : bool
Parameters
$killer : AbstractPlayer
$credits : int
$payoutType : string
Return values
bool

refreshGoods()

Adds extra stock to goods in the tier above a good that was traded

protected refreshGoods(int $classTraded, int $amountTraded) : void
Parameters
$classTraded : int
$amountTraded : int

selectAndAddGood()

protected selectAndAddGood(int $goodClass) : TradeGood
Parameters
$goodClass : int
Return values
TradeGood

selectAndRemoveGood()

protected selectAndRemoveGood(int $goodClass) : void
Parameters
$goodClass : int

setCachedTime()

protected setCachedTime(int $cachedTime) : void
Parameters
$cachedTime : int

takeDamageToArmour()

protected takeDamageToArmour(int $damage) : int
Parameters
$damage : int
Return values
int

takeDamageToCDs()

protected takeDamageToCDs(int $damage) : int
Parameters
$damage : int
Return values
int

takeDamageToShields()

protected takeDamageToShields(int $damage) : int
Parameters
$damage : int
Return values
int

tradeGoods()

protected tradeGoods(TradeGood $good, int $goodsTraded, int $exp) : void
Parameters
$good : TradeGood
$goodsTraded : int
$exp : int

getGoods()

private getGoods() : void

restockGood()

Used for the automatic resupplying of all goods over time

private restockGood(int $goodID, int $secondsSinceLastUpdate) : void
Parameters
$goodID : int
$secondsSinceLastUpdate : int

setAttackStarted()

private setAttackStarted(int $time) : void
Parameters
$time : int

setGoodAmount()

private setGoodAmount(int $goodID, int $amount[, bool $doUpdate = true ]) : void
Parameters
$goodID : int
$amount : int
$doUpdate : bool = true

updateAttackStarted()

private updateAttackStarted() : void

        
On this page

Search results