mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 07:05:35 +00:00
Update to handle armour
This commit is contained in:
@@ -20,7 +20,7 @@ export default class InternalSlot extends Slot {
|
||||
_getSlotDetails(m, translate, formats, u) {
|
||||
if (m) {
|
||||
let classRating = m.class + m.rating;
|
||||
let { drag, drop } = this.props;
|
||||
let { drag, drop, ship } = this.props;
|
||||
let { termtip, tooltip } = this.context;
|
||||
let validMods = Modifications.validity[m.grp] || [];
|
||||
|
||||
@@ -48,7 +48,7 @@ export default class InternalSlot extends Slot {
|
||||
{ m.rangeLS ? <div className={'l'}>{translate('range')}: {m.rangeLS}{u.Ls}</div> : null }
|
||||
{ m.rangeLS === null ? <div className={'l'}>∞{u.Ls}</div> : null }
|
||||
{ m.rangeRating ? <div className={'l'}>{translate('range')}: {m.rangeRating}</div> : null }
|
||||
{ m.armouradd ? <div className={'l'}>+{m.armouradd} <u className='cap'>{translate('armour')}</u></div> : null }
|
||||
{ m.getHullReinforcement() ? <div className={'l'}>+{formats.int(m.getHullReinforcement() + ship.baseArmour * m.getModValue('hullboost'))} <u className='cap'>{translate('armour')}</u></div> : null }
|
||||
{ m.passengers ? <div className={'l'}>{translate('passengers')}: {m.passengers}</div> : null }
|
||||
{ m && validMods.length > 0 ? <div className='r' ><button onClick={this._toggleModifications.bind(this)} onContextMenu={stopCtxPropagation} onMouseOver={termtip.bind(null, 'modifications')} onMouseOut={tooltip.bind(null, null)}><ListModifications /></button></div> : null }
|
||||
|
||||
|
||||
@@ -24,19 +24,11 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
||||
let u = language.units;
|
||||
let formats = language.formats;
|
||||
let { time, int, round, f1, f2, pct } = formats;
|
||||
let armourDetails = null;
|
||||
let sgClassNames = cn({ warning: ship.sgSlot && !ship.shieldStrength, muted: !ship.sgSlot });
|
||||
let sgRecover = '-';
|
||||
let sgRecharge = '-';
|
||||
let hide = tooltip.bind(null, null);
|
||||
|
||||
if (ship.armourMultiplier > 1 || ship.armourAdded) {
|
||||
armourDetails = <u>({
|
||||
(ship.armourMultiplier > 1 ? formats.rPct(ship.armourMultiplier) : '') +
|
||||
(ship.armourAdded ? ' + ' + ship.armourAdded : '')
|
||||
})</u>;
|
||||
}
|
||||
|
||||
if (ship.shieldStrength) {
|
||||
sgRecover = time(ship.calcShieldRecovery());
|
||||
sgRecharge = time(ship.calcShieldRecharge());
|
||||
@@ -96,7 +88,7 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
||||
<td>{f1(ship.totalDps)}</td>
|
||||
<td>{f1(ship.totalEps)}</td>
|
||||
<td>{f1(ship.totalHps)}</td>
|
||||
<td>{int(ship.armour)} {armourDetails}</td>
|
||||
<td>{int(ship.armour)}</td>
|
||||
<td className={sgClassNames}>{int(ship.shieldStrength)} {u.MJ} { ship.shieldMultiplier > 1 && ship.shieldStrength > 0 ? <u>({formats.rPct(ship.shieldMultiplier)})</u> : null }</td>
|
||||
<td className={sgClassNames}>{sgRecover}</td>
|
||||
<td className={sgClassNames}>{sgRecharge}</td>
|
||||
|
||||
@@ -37,10 +37,11 @@ export const terms = {
|
||||
bsg: 'Bi-Weave Shield Generator',
|
||||
c: 'Cannon',
|
||||
cc: 'Collector Limpet Controller',
|
||||
cm: 'Countermeasure',
|
||||
ch: 'Chaff Launcher',
|
||||
cr: 'Cargo Rack',
|
||||
cs: 'Manifest Scanner',
|
||||
dc: 'Docking Computer',
|
||||
ec: 'Electronic Countermeasure',
|
||||
fc: 'Fragment Cannon',
|
||||
fh: 'Fighter Hangar',
|
||||
fi: 'FSD Interdictor',
|
||||
@@ -50,6 +51,7 @@ export const terms = {
|
||||
fx: 'Fuel Transfer Limpet Controller',
|
||||
hb: 'Hatch Breaker Limpet Controller',
|
||||
hr: 'Hull Reinforcement Package',
|
||||
hs: 'Heat Sink Launcher',
|
||||
kw: 'Kill Warrant Scanner',
|
||||
ls: 'Life Support',
|
||||
mc: 'Multi-cannon',
|
||||
@@ -65,6 +67,7 @@ export const terms = {
|
||||
pcq: 'Luxury Passenger Cabin',
|
||||
pd: 'power distributor',
|
||||
pl: 'Pulse Laser',
|
||||
po: 'Point Defence',
|
||||
pp: 'Power Plant',
|
||||
psg: 'Prismatic Shield Generator',
|
||||
pv: 'Planetary Vehicle Hangar',
|
||||
@@ -88,7 +91,6 @@ export const terms = {
|
||||
|
||||
// Modifications
|
||||
ammo: 'Ammunition maximum',
|
||||
armour: 'Armour',
|
||||
armourpen: 'Armour penetration',
|
||||
boot: 'Boot time',
|
||||
brokenregen: 'Broken regeneration rate',
|
||||
@@ -105,6 +107,7 @@ export const terms = {
|
||||
explres: 'Explosive resistance',
|
||||
facinglimit: 'Facing limit',
|
||||
hullboost: 'Hull boost',
|
||||
hullreinforcement: 'Hull reinforcement',
|
||||
integrity: 'Integrity',
|
||||
jitter: 'Jitter',
|
||||
kinres: 'Kinetic resistance',
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
|
||||
export const ArmourMultiplier = [
|
||||
1, // Lightweight
|
||||
1.4, // Reinforced
|
||||
1.945, // Military
|
||||
1.945, // Mirrored
|
||||
1.945 // Reactive
|
||||
];
|
||||
|
||||
export const SizeMap = ['', 'small', 'medium', 'large', 'capital'];
|
||||
|
||||
export const StandardArray = [
|
||||
|
||||
@@ -283,11 +283,11 @@ export default class Module {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the armour for this module, taking in to account modifications
|
||||
* @return {Number} the armour of this module
|
||||
* Get the hull reinforcement for this module, taking in to account modifications
|
||||
* @return {Number} the hull reinforcement of this module
|
||||
*/
|
||||
getArmour() {
|
||||
return this._getModifiedValue('armour');
|
||||
getHullReinforcement() {
|
||||
return this._getModifiedValue('hullreinforcement');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,4 +487,13 @@ export default class Module {
|
||||
getFacingLimit() {
|
||||
return this._getModifiedValue('facinglimit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hull boost for this module, taking in to account modifications
|
||||
* @return {Number} the hull boost for this module
|
||||
*/
|
||||
getHullBoost() {
|
||||
return this._getModifiedValue('hullboost');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ArmourMultiplier } from './Constants';
|
||||
import * as Calc from './Calculations';
|
||||
import * as ModuleUtils from './ModuleUtils';
|
||||
import Module from './Module';
|
||||
@@ -213,7 +212,6 @@ export default class Ship {
|
||||
calcShieldRecovery() {
|
||||
if (this.shieldStrength && this.sgSlot) {
|
||||
let brokenRegenRate = 1 + this.sgSlot.m.getModValue('brokenregen');
|
||||
console.log('Broken regen rate is ' + brokenRegenRate);
|
||||
// 50% of shield strength / recovery recharge rate + 15 second delay before recharge starts
|
||||
return ((this.shieldStrength / 2) / (this.sgSlot.m.recover * brokenRegenRate)) + 15;
|
||||
}
|
||||
@@ -447,6 +445,9 @@ export default class Ship {
|
||||
} else if (name == 'shieldmul') {
|
||||
m.setModValue(name, value);
|
||||
this.updateShieldStrength();
|
||||
} else if (name == 'hullboost') {
|
||||
m.setModValue(name, value);
|
||||
this.updateArmour();
|
||||
} else {
|
||||
// Generic
|
||||
m.setModValue(name, value);
|
||||
@@ -473,8 +474,7 @@ export default class Ship {
|
||||
this.fuelCapacity = 0;
|
||||
this.cargoCapacity = 0;
|
||||
this.ladenMass = 0;
|
||||
this.armourAdded = 0;
|
||||
this.armourMultiplier = 1;
|
||||
this.armour = this.baseArmour;
|
||||
this.shieldMultiplier = 1;
|
||||
this.totalCost = this.m.incCost ? this.m.discountedCost : 0;
|
||||
this.unladenMass = this.hullMass;
|
||||
@@ -559,6 +559,7 @@ export default class Ship {
|
||||
this.updatePower()
|
||||
.updateJumpStats()
|
||||
.updateShieldStrength()
|
||||
.updateArmour()
|
||||
.updateTopSpeed();
|
||||
}
|
||||
|
||||
@@ -751,6 +752,8 @@ export default class Ship {
|
||||
updateStats(slot, n, old, preventUpdate) {
|
||||
let powerChange = slot == this.standard[0];
|
||||
|
||||
let armourChange = (slot == this.bulkheads) || (n && n.grp == 'hr') || (old && old.grp == 'hr');
|
||||
|
||||
if (old) { // Old modul now being removed
|
||||
switch (old.grp) {
|
||||
case 'ft':
|
||||
@@ -759,9 +762,6 @@ export default class Ship {
|
||||
case 'cr':
|
||||
this.cargoCapacity -= old.cargo;
|
||||
break;
|
||||
case 'hr':
|
||||
this.armourAdded -= old.armouradd;
|
||||
break;
|
||||
case 'sb':
|
||||
this.shieldMultiplier -= slot.enabled ? old.getShieldMul() : 0;
|
||||
break;
|
||||
@@ -801,9 +801,6 @@ export default class Ship {
|
||||
case 'cr':
|
||||
this.cargoCapacity += n.cargo;
|
||||
break;
|
||||
case 'hr':
|
||||
this.armourAdded += n.armouradd;
|
||||
break;
|
||||
case 'sb':
|
||||
this.shieldMultiplier += slot.enabled ? n.getShieldMul() : 0;
|
||||
break;
|
||||
@@ -831,12 +828,14 @@ export default class Ship {
|
||||
}
|
||||
|
||||
this.ladenMass = this.unladenMass + this.cargoCapacity + this.fuelCapacity;
|
||||
this.armour = this.armourAdded + Math.round(this.baseArmour * this.armourMultiplier);
|
||||
|
||||
if (!preventUpdate) {
|
||||
if (powerChange) {
|
||||
this.updatePower();
|
||||
}
|
||||
if (armourChange) {
|
||||
}
|
||||
this.updateArmour();
|
||||
this.updateTopSpeed();
|
||||
this.updateJumpStats();
|
||||
this.updateShieldStrength();
|
||||
@@ -885,6 +884,27 @@ export default class Ship {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update armour
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
updateArmour() {
|
||||
// Armour from bulkheads
|
||||
let bulkhead = this.bulkheads.m;
|
||||
let armour = this.baseArmour + (this.baseArmour * bulkhead.getHullBoost());
|
||||
|
||||
// Armour from HRPs
|
||||
for (let slot of this.internal) {
|
||||
if (slot.m && slot.m.grp == 'hr') {
|
||||
armour += slot.m.getHullReinforcement();
|
||||
// Hull boost for HRPs is applied against the ship's base armour
|
||||
armour += this.baseArmour * slot.m.getModValue('hullboost');
|
||||
}
|
||||
}
|
||||
this.armour = armour;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jump Range and total range calculations
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
@@ -1049,7 +1069,6 @@ export default class Ship {
|
||||
let oldBulkhead = this.bulkheads.m;
|
||||
this.bulkheads.m = this.availCS.getBulkhead(index);
|
||||
this.bulkheads.discountedCost = this.bulkheads.m.cost * this.moduleCostMultiplier;
|
||||
this.armourMultiplier = ArmourMultiplier[index];
|
||||
this.updateStats(this.bulkheads, this.bulkheads.m, oldBulkhead, preventUpdate);
|
||||
this.serialized.standard = null;
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user