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