Ship
Ship Model - Encapsulates and models in-game ship behavior
Constructor Summary
Public Constructor | ||
public |
constructor(id: String, properties: Object, slots: Object) |
Member Summary
Public Members | ||
public |
[p]: * |
|
public |
armour: * |
|
public |
availCS: * |
|
public |
|
|
public |
|
|
public |
cargoHatch: {"m": *, "type": string} |
|
public |
costList: * |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
id: * |
|
public |
|
|
public |
|
|
public |
ladenRange: * |
|
public |
|
|
public |
maxJumpCount: * |
|
public |
|
|
public |
modulearmour: * |
|
public |
|
|
public |
|
|
public |
pitches: * |
|
public |
|
|
public |
|
|
public |
powerList: * |
|
public |
|
|
public |
|
|
public |
rolls: * |
|
public |
serialized: {} |
|
public |
shield: * |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
speeds: * |
|
public |
topBoost: * |
|
public |
topPitch: * |
|
public |
topRoll: * |
|
public |
topSpeed: * |
|
public |
topYaw: * |
|
public |
|
|
public |
|
|
public |
|
|
public |
totalCost: * |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
unladenMass: * |
|
public |
unladenRange: * |
|
public |
yaws: * |
Method Summary
Public Methods | ||
public |
applyDiscounts(shipDiscount: Number, moduleDiscount: Number): this Recalculate all item costs and total based on discounts. |
|
public |
Updates an existing ship instance's slots with modules determined by the code. |
|
public |
Builds/Updates the ship instance with the ModuleUtils[comps] passed in. |
|
public |
calcLadenRange(massDelta: Number, fuel: Number, fsd: Object): Number Calculate the hypothetical laden jump range based on a potential change in mass, fuel, or FSD |
|
public |
Calculate the lowest possible mass for this ship. |
|
public |
Calculate the pitch for a given configuration |
|
public |
Calculate the roll for a given configuration |
|
public |
calcShieldStrengthWith(sg: Object, multiplierDelta: Number): Number Calculate the hypothetical shield strength for the ship using the specified parameters |
|
public |
Calculate the speed for a given configuration |
|
public |
calcSpeedsWith(fuel: Number, cargo: Number): array Calculate the hypothetical top speeds at cargo and fuel tonnage |
|
public |
calcUnladenRange(massDelta: Number, fuel: Number, fsd: Object): Number Calculate the hypothetical unladen jump range based on a potential change in mass, fuel, or FSD |
|
public |
Calculate the yaw for a given configuration |
|
public |
Can the ship boost |
|
public |
Can the ship thrust/move |
|
public |
Clear all modification values for a module |
|
public |
Clear blueprint for a module |
|
public |
Clear special for a module |
|
public |
decodeModificationsString(code: String, arr: Array) Populate the modifications array with modification values from the code |
|
public |
decodeModificationsStruct(buffer: String, modArr: Array, blueprintArr: Array) Populate the modifications array with modification values from the code. |
|
public |
diminishingReturns(val: Number, drll: Number, drul: Number): this Calculate diminishing returns value, where values below a given limit are returned as-is, and values between the lower and upper limit of the diminishing returns are given at half value. |
|
public |
emptyHardpoints(): this Empties all hardpoints and utility slots |
|
public |
emptyInternal(): this Empties all Internal slots |
|
public |
emptyUtility(): this Empties all Utility slots |
|
public |
emptyWeapons(): this Empties all hardpoints |
|
public |
findInternalByGroup(group: String): Number Find an internal slot that has an installed modul of the specific group. |
|
public |
Find the shield generator for this ship |
|
public |
Get the set of available modules for this ship |
|
public |
Serializes the hardpoints and utility modules to a string |
|
public |
Serializes the internal modules to a string |
|
public |
Serializes the modifications to a string |
|
public |
Get the serialized module active/inactive settings |
|
public |
Get the serialized module priority settings |
|
public |
getSlotStatus(slot: Object, deployed: boolean): Number Returns the a slots power status: 0 - No status [Blank] 1 - Disabled (Switched off) 2 - Offline (Insufficient power available) 3 - Online |
|
public |
Serializes the standard modules to a string |
|
public |
optimizeMass(m: Object): this Optimize for the lower mass build that can still boost and power the ship without power management. |
|
public |
recalculateArmour(): this Update armour and hull resistances |
|
public |
recalculateDps(): this Calculate damage per second and related items for weapons |
|
public |
recalculateEps(): this Calculate energy per second for weapons |
|
public |
recalculateHps(): this Calculate heat per second for weapons |
|
public |
recalculateMass(): this Eecalculate mass |
|
public |
recalculateShield(): this Update shield |
|
public |
recalculateShieldCells(): this Update shield cells |
|
public |
setCostIncluded(item: Object, included: boolean): this Include/Exclude a item/slot in cost calculations |
|
public |
setModification(m: Object, name: Object, value: Number, sentfromui: bool) Set a modification value and update ship stats |
|
public |
setModuleBlueprint(m: Object, bp: Object) Set blueprint for a module |
|
public |
setModuleSpecial(m: Object, special: Object) Set special for a module |
|
public |
setSlotEnabled(slot: Object, enabled: boolean): this Set slot active/inactive |
|
public |
setSlotPriority(slot: Object, newPriority: Number): boolean Will change the priority of the specified slot if the new priority is valid |
|
public |
Serializes the ship to a string |
|
public |
updateJumpStats(): this Jump Range and total range calculations |
|
public |
updateModificationsString(): this Update the modifications string. |
|
public |
updateMovement(): this Update movement values |
|
public |
updatePowerEnabledString(): this Update the serialized power active/inactive string |
|
public |
updatePowerGenerated(): this Update power calculations when amount generated changes |
|
public |
updatePowerPrioritesString(): this Update the serialized power priorites string |
|
public |
updatePowerUsed(): this Update power calculations when amount consumed changes |
|
public |
updateStats(slot: Object, n: Object, old: Object, preventUpdate: boolean): this Updates the ship's cumulative and aggregated stats based on the module change. |
|
public |
upgradeInternals(internals: array, offset: int, priorities: array, enableds: array, modifications: array, blueprints: array, version: int) Upgrade information about internals with version changes |
|
public |
Update a slot with a the modul if the id is different from the current id for this slot. |
|
public |
useBulkhead(index: Number, preventUpdate: boolean): this Mount the specified bulkhead type (index) |
|
public |
useLightestStandard(m: Object): this Use the lightest standard ModuleUtils unless otherwise specified |
|
public |
useStandard(rating: String): this Set all standard slots to use the speficied rating and class based on the slot's max class |
|
public |
useUtility(group: String, rating: String, name: String, clobber: boolean): this Fill all utility slots with the specified module |
|
public |
[useWeapon description] |
Public Members
public [p]: * source
public armour: * source
public availCS: * source
public costList: * source
public fullTankRange: * source
public id: * source
public ladenFastestRange: * source
public ladenRange: * source
public maxJumpCount: * source
public modulearmour: * source
public moduleprotection: * source
public pitches: * source
public powerAvailable: * source
public powerDeployed: * source
public powerList: * source
public powerRetracted: * source
public rolls: * source
public serialized: {} source
public shield: * source
public speeds: * source
public topBoost: * source
public topPitch: * source
public topRoll: * source
public topSpeed: * source
public topYaw: * source
public totalCost: * source
public unladenFastestRange: * source
public unladenMass: * source
public unladenRange: * source
public yaws: * source
Public Methods
public applyDiscounts(shipDiscount: Number, moduleDiscount: Number): this source
Recalculate all item costs and total based on discounts.
Return:
this | The current ship instance for chaining |
public buildFrom(serializedString: String): this source
Updates an existing ship instance's slots with modules determined by the code.
Params:
Name | Type | Attribute | Description |
serializedString | String | The string to deserialize |
Return:
this | The current ship instance for chaining |
public buildWith(comps: Object, priorities: array, enabled: Array, mods: Array, blueprints: Array): this source
Builds/Updates the ship instance with the ModuleUtils[comps] passed in.
Return:
this | The current ship instance for chaining |
public calcLadenRange(massDelta: Number, fuel: Number, fsd: Object): Number source
Calculate the hypothetical laden jump range based on a potential change in mass, fuel, or FSD
public calcLowestPossibleMass(m: Object): number source
Calculate the lowest possible mass for this ship.
Params:
Name | Type | Attribute | Description |
m | Object | Module override set (standard type => Module) |
public calcPitch(eng: Number, fuel: Number, cargo: Number, boost: boolean): Number source
Calculate the pitch for a given configuration
public calcRoll(eng: Number, fuel: Number, cargo: Number, boost: boolean): Number source
Calculate the roll for a given configuration
public calcShieldStrengthWith(sg: Object, multiplierDelta: Number): Number source
Calculate the hypothetical shield strength for the ship using the specified parameters
public calcSpeed(eng: Number, fuel: Number, cargo: Number, boost: boolean): Number source
Calculate the speed for a given configuration
public calcSpeedsWith(fuel: Number, cargo: Number): array source
Calculate the hypothetical top speeds at cargo and fuel tonnage
Return:
array | Speed at pip settings |
public calcUnladenRange(massDelta: Number, fuel: Number, fsd: Object): Number source
Calculate the hypothetical unladen jump range based on a potential change in mass, fuel, or FSD
public calcYaw(eng: Number, fuel: Number, cargo: Number, boost: boolean): Number source
Calculate the yaw for a given configuration
public canBoost(cargo: Number, fuel: Number): [type] source
Can the ship boost
Return:
[type] | True if boost capable |
public canThrust(cargo: Number, fuel: Number): [type] source
Can the ship thrust/move
Return:
[type] | True if thrusters operational |
public clearModifications(m: Number) source
Clear all modification values for a module
Params:
Name | Type | Attribute | Description |
m | Number | The module for which to clear the modifications |
public clearModuleBlueprint(m: Object) source
Clear blueprint for a module
Params:
Name | Type | Attribute | Description |
m | Object | The module for which to clear the blueprint |
public clearModuleSpecial(m: Object) source
Clear special for a module
Params:
Name | Type | Attribute | Description |
m | Object | The module for which to clear the blueprint |
public decodeModificationsString(code: String, arr: Array) source
Populate the modifications array with modification values from the code
public decodeModificationsStruct(buffer: String, modArr: Array, blueprintArr: Array) source
Populate the modifications array with modification values from the code. See updateModificationsString() for details of the structure.
public diminishingReturns(val: Number, drll: Number, drul: Number): this source
Calculate diminishing returns value, where values below a given limit are returned as-is, and values between the lower and upper limit of the diminishing returns are given at half value. Commonly used for resistances.
Return:
this | The ship instance (for chaining operations) |
public emptyHardpoints(): this source
Empties all hardpoints and utility slots
Return:
this | The current ship instance for chaining |
public emptyInternal(): this source
Empties all Internal slots
Return:
this | The current ship instance for chaining |
public emptyUtility(): this source
Empties all Utility slots
Return:
this | The current ship instance for chaining |
public emptyWeapons(): this source
Empties all hardpoints
Return:
this | The current ship instance for chaining |
public findInternalByGroup(group: String): Number source
Find an internal slot that has an installed modul of the specific group.
Params:
Name | Type | Attribute | Description |
group | String | Module group/type |
public getHardpointsString(): String source
Serializes the hardpoints and utility modules to a string
public getSlotStatus(slot: Object, deployed: boolean): Number source
Returns the a slots power status: 0 - No status [Blank] 1 - Disabled (Switched off) 2 - Offline (Insufficient power available) 3 - Online
public optimizeMass(m: Object): this source
Optimize for the lower mass build that can still boost and power the ship without power management.
Params:
Name | Type | Attribute | Description |
m | Object | Standard Module overrides |
Return:
this | The current ship instance for chaining |
public recalculateArmour(): this source
Update armour and hull resistances
Return:
this | The ship instance (for chaining operations) |
public recalculateDps(): this source
Calculate damage per second and related items for weapons
Return:
this | The ship instance (for chaining operations) |
public recalculateEps(): this source
Calculate energy per second for weapons
Return:
this | The ship instance (for chaining operations) |
public recalculateHps(): this source
Calculate heat per second for weapons
Return:
this | The ship instance (for chaining operations) |
public recalculateMass(): this source
Eecalculate mass
Return:
this | The ship instance (for chaining operations) |
public recalculateShield(): this source
Update shield
Return:
this | The ship instance (for chaining operations) |
public recalculateShieldCells(): this source
Update shield cells
Return:
this | The ship instance (for chaining operations) |
public setCostIncluded(item: Object, included: boolean): this source
Include/Exclude a item/slot in cost calculations
Return:
this | The current ship instance for chaining |
public setModification(m: Object, name: Object, value: Number, sentfromui: bool) source
Set a modification value and update ship stats
Params:
Name | Type | Attribute | Description |
m | Object | The module to change |
|
name | Object | The name of the modification to change |
|
value | Number | The new value of the modification. The value of the modification is scaled to provide two decimal places of precision in an integer. For example 1.23% is stored as 123 |
|
sentfromui | bool | True if this update was sent from the UI |
public setSlotEnabled(slot: Object, enabled: boolean): this source
Set slot active/inactive
Return:
this | The current ship instance for chaining |
public setSlotPriority(slot: Object, newPriority: Number): boolean source
Will change the priority of the specified slot if the new priority is valid
public updateJumpStats(): this source
Jump Range and total range calculations
Return:
this | The ship instance (for chaining operations) |
public updateModificationsString(): this source
Update the modifications string. This is a binary structure. It starts with a byte that identifies a slot, with bulkheads being ID 0 and moving through standard modules, hardpoints, and finally internal modules. It then contains one or more modifications, with each modification being a one-byte modification ID and at two-byte modification value. Modification IDs are based on the array in Modifications.modifications. The list of modifications is terminated by a modification ID of -1. The structure then repeats for the next module, and the next, and is terminated by a slot ID of -1.
Return:
this | The ship instance (for chaining operations) |
public updateMovement(): this source
Update movement values
Return:
this | The ship instance (for chaining operations) |
public updatePowerEnabledString(): this source
Update the serialized power active/inactive string
Return:
this | The ship instance (for chaining operations) |
public updatePowerGenerated(): this source
Update power calculations when amount generated changes
Return:
this | The ship instance (for chaining operations) |
public updatePowerPrioritesString(): this source
Update the serialized power priorites string
Return:
this | The ship instance (for chaining operations) |
public updatePowerUsed(): this source
Update power calculations when amount consumed changes
Return:
this | The ship instance (for chaining operations) |
public updateStats(slot: Object, n: Object, old: Object, preventUpdate: boolean): this source
Updates the ship's cumulative and aggregated stats based on the module change.
Return:
this | The ship instance (for chaining operations) |
public upgradeInternals(internals: array, offset: int, priorities: array, enableds: array, modifications: array, blueprints: array, version: int) source
Upgrade information about internals with version changes
Params:
Name | Type | Attribute | Description |
internals | array | the internals from the ship code |
|
offset | int | the offset of the internals information in the priorities etc. arrays |
|
priorities | array | the existing priorities arrray |
|
enableds | array | the existing enableds arrray |
|
modifications | array | the existing modifications arrray |
|
blueprints | array | the existing blueprints arrray |
|
version | int | the version of the information |
public use(slot: Object, mdef: Object, preventUpdate: boolean): this source
Update a slot with a the modul if the id is different from the current id for this slot. Has logic handling ModuleUtils that you may only have 1 of (Shield Generator or Refinery).
Return:
this | The ship instance (for chaining operations) |
public useBulkhead(index: Number, preventUpdate: boolean): this source
Mount the specified bulkhead type (index)
Return:
this | The ship instance (for chaining operations) |
public useLightestStandard(m: Object): this source
Use the lightest standard ModuleUtils unless otherwise specified
Params:
Name | Type | Attribute | Description |
m | Object | Module override set (standard type => module ID) |
Return:
this | The ship instance (for chaining operations) |
public useStandard(rating: String): this source
Set all standard slots to use the speficied rating and class based on the slot's max class
Params:
Name | Type | Attribute | Description |
rating | String | Module Rating (A-E) |
Return:
this | The ship instance (for chaining operations) |
public useUtility(group: String, rating: String, name: String, clobber: boolean): this source
Fill all utility slots with the specified module
Return:
this | The ship instance (for chaining operations) |
public useWeapon(group: [type], mount: [type], missile: [type], clobber: boolean): this source
[useWeapon description]
Params:
Name | Type | Attribute | Description |
group | [type] | [description] |
|
mount | [type] | [description] |
|
missile | [type] | [description] |
|
clobber | boolean | Overwrite non-empty slots |
Return:
this | The ship instance (for chaining operations) |