From 108ab3b1ee1471c8b36732340c372b793e7764db Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Mon, 7 Nov 2016 10:15:20 +0000 Subject: [PATCH] Update DPS/HPS/EPS in real-time as modifiers change --- ChangeLog.md | 5 ++++ src/app/shipyard/Ship.js | 53 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 ChangeLog.md diff --git a/ChangeLog.md b/ChangeLog.md new file mode 100644 index 00000000..ae2c14b8 --- /dev/null +++ b/ChangeLog.md @@ -0,0 +1,5 @@ +#2.2.x + * Update DPS/HPS/EPS in real-time as modifiers change + * Use coriolis-data 2.2.2: + * Add distributor draw modifier to shield generators + * Remove modifiers for sensors diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 25e35110..d1451e7a 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -437,6 +437,11 @@ export default class Ship { } else if (name == 'hullboost') { m.setModValue(name, value); this.updateArmour(); + } else if (name == 'burst' || name == 'clip' || name == 'damage' || name == 'distdraw' || name == 'jitter' || name == 'piercing' || name == 'range' || name == 'reload' || name == 'rof' || name == 'thermload') { + m.setModValue(name, value); + this.recalculateDps(); + this.recalculateHps(); + this.recalculateEps(); } else { // Generic m.setModValue(name, value); @@ -820,6 +825,54 @@ export default class Ship { return this; } + /** + * Calculate damage per second for weapons + * @return {this} The ship instance (for chaining operations) + */ + recalculateDps() { + let totalDps = 0; + + for (let slotNum in this.hardpoints) { + const slot = this.hardpoints[slotNum]; + if (slot.m && slot.enabled && slot.m.getDps()) { + totalDps += slot.m.getDps(); + } + } + this.totalDps = totalDps; + } + + /** + * Calculate heat per second for weapons + * @return {this} The ship instance (for chaining operations) + */ + recalculateHps() { + let totalHps = 0; + + for (let slotNum in this.hardpoints) { + const slot = this.hardpoints[slotNum]; + if (slot.m && slot.enabled && slot.m.getHps()) { + totalHps += slot.m.getHps(); + } + } + this.totalHps = totalHps; + } + + /** + * Calculate energy per second for weapons + * @return {this} The ship instance (for chaining operations) + */ + recalculateEps() { + let totalEps = 0; + + for (let slotNum in this.hardpoints) { + const slot = this.hardpoints[slotNum]; + if (slot.m && slot.enabled && slot.m.getEps()) { + totalEps += slot.m.getEps(); + } + } + this.totalEps = totalEps; + } + /** * Update power calculations when amount generated changes * @return {this} The ship instance (for chaining operations)