Update DPS/HPS/EPS in real-time as modifiers change

This commit is contained in:
Cmdr McDonald
2016-11-07 10:15:20 +00:00
parent 04caef9613
commit 108ab3b1ee
2 changed files with 58 additions and 0 deletions

5
ChangeLog.md Normal file
View File

@@ -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

View File

@@ -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)