From df03102c35b3c44de999562e24f6d01a4c7a416e Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Mon, 30 Jan 2017 21:31:55 +0000 Subject: [PATCH 1/6] Added time to drain calculation and display --- ChangeLog.md | 4 ++ .../anaconda-test-detailed-export-v4.json | 16 +++---- package.json | 2 +- src/app/components/ShipSummaryTable.jsx | 8 ++-- src/app/i18n/en.js | 2 + src/app/shipyard/Ship.js | 46 +++++++++++++++++-- 6 files changed, 62 insertions(+), 16 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 099b93a3..d2acfd06 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ +#2.2.13 + * Add 'time to drain' summary value. This is the time to drain the WEP capacitor if firing all enabled weapons + * Do not include utility slot DPS/EPS/HPS in summary information + #2.2.12 * Tidy up old references to coriolis.io * Add ability to add and remove special effects to weapon modifications diff --git a/__tests__/fixtures/anaconda-test-detailed-export-v4.json b/__tests__/fixtures/anaconda-test-detailed-export-v4.json index 638dfd51..fc1f83ee 100644 --- a/__tests__/fixtures/anaconda-test-detailed-export-v4.json +++ b/__tests__/fixtures/anaconda-test-detailed-export-v4.json @@ -269,20 +269,19 @@ "topSpeed": 187.01, "totalCost": 882362058, "totalDpe": 142.68, - "totalDps": 103.8, - "totalEps": 22.71, - "totalHps": 677.29, + "totalDps": 101.13, + "totalEps": 18.71, "totalExplDpe": 0, "totalExplDps": 0, "totalExplSDps": 0, "totalAbsDpe": 3.57, "totalAbsDps": 18.78, "totalAbsSDps": 14.45, - "totalHps": 33.62, + "totalHps": 28.28, "totalKinDpe": 117.48, - "totalKinDps": 24.94, - "totalKinSDps": 18.76, - "totalSDps": 91.84, + "totalKinDps": 22.27, + "totalKinSDps": 16.91, + "totalSDps": 89.99, "totalThermDpe": 21.63, "totalThermDps": 60.08, "totalThermSDps": 58.64, @@ -320,6 +319,7 @@ "shieldCells": 1840, "shieldExplRes": 0.5, "shieldKinRes": 0.4, - "shieldThermRes": -0.2 + "shieldThermRes": -0.2, + "timeToDrain": 7.04 } } diff --git a/package.json b/package.json index 267e1f16..64bd1106 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coriolis_shipyard", - "version": "2.2.12", + "version": "2.2.13b", "repository": { "type": "git", "url": "https://github.com/EDCD/coriolis" diff --git a/src/app/components/ShipSummaryTable.jsx b/src/app/components/ShipSummaryTable.jsx index 54c66e87..0c0202fb 100644 --- a/src/app/components/ShipSummaryTable.jsx +++ b/src/app/components/ShipSummaryTable.jsx @@ -42,10 +42,11 @@ export default class ShipSummaryTable extends TranslatedComponent { {translate('boost')} {translate('DPS')} {translate('EPS')} + {translate('TTD')} {translate('HPS')} - {translate('hardness')} - {translate('armour')} - {translate('shields')} + {translate('hrd')} + {translate('arm')} + {translate('shld')} {translate('mass')} {translate('cargo')} {translate('fuel')} @@ -71,6 +72,7 @@ export default class ShipSummaryTable extends TranslatedComponent { { ship.canBoost() ? {int(ship.topBoost)} {u['m/s']} : 0 } {f1(ship.totalDps)} {f1(ship.totalEps)} + {ship.timeToDrain === Infinity ? '∞' : time(ship.timeToDrain)} {f1(ship.totalHps)} {int(ship.hardness)} {int(ship.armour)} diff --git a/src/app/i18n/en.js b/src/app/i18n/en.js index 5062f672..86b56bf8 100644 --- a/src/app/i18n/en.js +++ b/src/app/i18n/en.js @@ -215,6 +215,8 @@ Along the top of the screen are some of the key values for your build. This is Here, along with most places in Coriolis, acronyms will have tooltips explaining what they mean. Hover over the acronym to obtain more detail, or look in the glossary at the end of this help.

+All values are the highest possible, assuming that you have maximum pips in the relevant capacitor (ENG for speed, WEP for time to drain, etc.).

+

Modules

The next set of panels laid out horizontally across the screen contain the modules you have put in your build. From left to right these are the core modules, the internal modules, the hardpoints and the utility mounts. These represent the available slots in your ship and cannot be altered. Each slot has a class, or size, and in general any module up to a given size can fit in a given slot (exceptions being bulkheads, life support and sensors in core modules and restricted internal slots, which can only take a subset of module depending on their restrictions).

diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index aa4803bc..667f5d34 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -426,6 +426,7 @@ export default class Ship { .recalculateDps() .recalculateEps() .recalculateHps() + .recalculateTtd() .updateMovement(); } @@ -497,11 +498,15 @@ export default class Ship { this.recalculateDps(); this.recalculateHps(); this.recalculateEps(); + this.recalculateTtd(); } else if (name === 'explres' || name === 'kinres' || name === 'thermres') { m.setModValue(name, value, sentfromui); // Could be for shields or armour this.recalculateArmour(); this.recalculateShield(); + } else if (name === 'wepcap' || name === 'weprate') { + m.setModValue(name, value, sentfromui); + this.recalculateTtd(); } else { // Generic m.setModValue(name, value, sentfromui); @@ -634,6 +639,7 @@ export default class Ship { .recalculateDps() .recalculateEps() .recalculateHps() + .recalculateTtd() .updateMovement(); } @@ -815,6 +821,7 @@ export default class Ship { if (slot.m.getEps()) { this.recalculateEps(); + this.recalculateTtd(); } } } @@ -851,6 +858,7 @@ export default class Ship { */ updateStats(slot, n, old, preventUpdate) { let powerGeneratedChange = slot == this.standard[0]; + let powerDistributorChange = slot == this.standard[4]; let powerUsedChange = false; let dpsChanged = n && n.getDps() || old && old.getDps(); let epsChanged = n && n.getEps() || old && old.getEps(); @@ -919,6 +927,9 @@ export default class Ship { if (powerGeneratedChange) { this.updatePowerGenerated(); } + if (powerDistributorChange) { + this.recalculateTtd(); + } if (powerUsedChange) { this.updatePowerUsed(); } @@ -957,7 +968,34 @@ export default class Ship { } /** - * Calculate damage per second for weapons + * Calculate time to drain WEP capacitor + * @return {this} The ship instance (for chaining operations) + */ + recalculateTtd() { + let totalSEps = 0; + + for (let slotNum in this.hardpoints) { + const slot = this.hardpoints[slotNum]; + if (slot.m && slot.enabled && slot.type === 'WEP' && slot.m.getDps()) { + totalSEps += slot.m.getClip() ? (slot.m.getClip() * slot.m.getEps() / slot.m.getRoF()) / ((slot.m.getClip() / slot.m.getRoF()) + slot.m.getReload()) : slot.m.getEps(); + } + } + + // Calculate the drain time + const drainPerSecond = totalSEps - this.standard[4].m.getWeaponsRechargeRate(); + if (drainPerSecond <= 0) { + // Can fire forever + this.timeToDrain = Infinity; + } else { + const initialCharge = this.standard[4].m.getWeaponsCapacity(); + this.timeToDrain = initialCharge / drainPerSecond; + } + + return this; + } + + /** + * Calculate damage per second and related items for weapons * @return {this} The ship instance (for chaining operations) */ recalculateDps() { @@ -979,7 +1017,7 @@ export default class Ship { for (let slotNum in this.hardpoints) { const slot = this.hardpoints[slotNum]; - if (slot.m && slot.enabled && slot.m.getDps()) { + if (slot.m && slot.enabled && slot.type === 'WEP' && slot.m.getDps()) { const dpe = slot.m.getEps() === 0 ? 0 : slot.m.getDps() / slot.m.getEps(); const dps = slot.m.getDps(); const sdps = slot.m.getClip() ? (slot.m.getClip() * slot.m.getDps() / slot.m.getRoF()) / ((slot.m.getClip() / slot.m.getRoF()) + slot.m.getReload()) : dps; @@ -1040,7 +1078,7 @@ export default class Ship { for (let slotNum in this.hardpoints) { const slot = this.hardpoints[slotNum]; - if (slot.m && slot.enabled && slot.m.getHps()) { + if (slot.m && slot.enabled && slot.type === 'WEP' && slot.m.getHps()) { totalHps += slot.m.getHps(); } } @@ -1058,7 +1096,7 @@ export default class Ship { for (let slotNum in this.hardpoints) { const slot = this.hardpoints[slotNum]; - if (slot.m && slot.enabled && slot.m.getEps()) { + if (slot.m && slot.enabled && slot.m.getEps() && slot.type === 'WEP') { totalEps += slot.m.getEps(); } } From b1daf6f799a953ce2963c7efc033849507996c2a Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Wed, 1 Feb 2017 07:45:44 +0000 Subject: [PATCH 2/6] Fix issue with auto loader not showing - #66 --- src/app/components/DamageDealt.jsx | 2 +- src/app/components/HardpointSlot.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/DamageDealt.jsx b/src/app/components/DamageDealt.jsx index 2b88a07c..3fd7e826 100644 --- a/src/app/components/DamageDealt.jsx +++ b/src/app/components/DamageDealt.jsx @@ -142,7 +142,7 @@ export default class DamageDealt extends TranslatedComponent { let engineering; if (m.blueprint && m.blueprint.name) { engineering = translate(m.blueprint.name) + ' ' + translate('grade') + ' ' + m.blueprint.grade; - if (m.blueprint.special && m.blueprint.special.id) { + if (m.blueprint.special && m.blueprint.special.id >= 0) { engineering += ', ' + translate(m.blueprint.special.name); } } diff --git a/src/app/components/HardpointSlot.jsx b/src/app/components/HardpointSlot.jsx index 826bc7c2..ce8416a9 100644 --- a/src/app/components/HardpointSlot.jsx +++ b/src/app/components/HardpointSlot.jsx @@ -48,7 +48,7 @@ export default class HardpointSlot extends Slot { let modTT = translate('modified'); if (m && m.blueprint && m.blueprint.name) { modTT = translate(m.blueprint.name) + ' ' + translate('grade') + ' ' + m.blueprint.grade; - if (m.blueprint.special && m.blueprint.special.id) { + if (m.blueprint.special && m.blueprint.special.id >= 0) { modTT += ', ' + translate(m.blueprint.special.name); } } From e78551f5d9084f9f4fc5f0a0e327693a19b961a8 Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Wed, 1 Feb 2017 08:24:50 +0000 Subject: [PATCH 3/6] Ensure that ship mass is recalculated when appropriate - #67 --- ChangeLog.md | 2 + src/app/shipyard/Ship.js | 80 ++++++++++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index d2acfd06..f6f28418 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,8 @@ #2.2.13 * Add 'time to drain' summary value. This is the time to drain the WEP capacitor if firing all enabled weapons * Do not include utility slot DPS/EPS/HPS in summary information + * Ensure that auto loader special shows in the tooltip + * Ensure that ship mass is recalculated when appropriate #2.2.12 * Tidy up old references to coriolis.io diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 667f5d34..ad8ba19c 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -419,6 +419,7 @@ export default class Ship { m.mods = {}; this.updatePowerGenerated() .updatePowerUsed() + .recalculateMass() .updateJumpStats() .recalculateShield() .recalculateShieldCells() @@ -462,11 +463,9 @@ export default class Ship { this.updatePowerUsed(); } else if (name === 'mass') { // Mass - let oldMass = m.getMass(); + //let oldMass = m.getMass(); m.setModValue(name, value, sentfromui); - let newMass = m.getMass(); - this.unladenMass = this.unladenMass - oldMass + newMass; - this.ladenMass = this.ladenMass - oldMass + newMass; + this.recalculateMass(); this.updateMovement(); this.updateJumpStats(); } else if (name === 'maxfuel') { @@ -632,6 +631,7 @@ export default class Ship { if (comps) { this.updatePowerGenerated() .updatePowerUsed() + .recalculateMass() .updateJumpStats() .recalculateShield() .recalculateShieldCells() @@ -871,15 +871,6 @@ export default class Ship { let shieldCellsChange = (n && n.grp === 'scb') || (old && old.grp === 'scb'); if (old) { // Old modul now being removed - switch (old.grp) { - case 'ft': - this.fuelCapacity -= old.fuel; - break; - case 'cr': - this.cargoCapacity -= old.cargo; - break; - } - if (slot.incCost && old.cost) { this.totalCost -= old.cost * this.moduleCostMultiplier; } @@ -887,20 +878,9 @@ export default class Ship { if (old.getPowerUsage() > 0 && slot.enabled) { powerUsedChange = true; } - - this.unladenMass -= old.getMass() || 0; } if (n) { - switch (n.grp) { - case 'ft': - this.fuelCapacity += n.fuel; - break; - case 'cr': - this.cargoCapacity += n.cargo; - break; - } - if (slot.incCost && n.cost) { this.totalCost += n.cost * this.moduleCostMultiplier; } @@ -908,12 +888,9 @@ export default class Ship { if (n.power && slot.enabled) { powerUsedChange = true; } - - this.unladenMass += n.getMass() || 0; } - this.ladenMass = this.unladenMass + this.cargoCapacity + this.fuelCapacity; - + this.recalculateMass(); if (!preventUpdate) { if (dpsChanged) { this.recalculateDps(); @@ -1168,6 +1145,53 @@ export default class Ship { return this; } + /** + * Eecalculate mass + * @return {this} The ship instance (for chaining operations) + */ + recalculateMass() { + let unladenMass = this.hullMass; + let cargoCapacity = 0; + let fuelCapacity = 0; + + for (let slotNum in this.standard) { + const slot = this.standard[slotNum]; + if (slot.m) { + unladenMass += slot.m.getMass(); + if (slot.m.grp === 'ft') { + fuelCapacity += slot.m.fuel; + } + } + } + + for (let slotNum in this.internal) { + const slot = this.internal[slotNum]; + if (slot.m) { + unladenMass += slot.m.getMass(); + if (slot.m.grp === 'ft') { + fuelCapacity += slot.m.fuel; + } else if (slot.m.grp === 'cr') { + cargoCapacity += slot.m.cargo; + } + } + } + + for (let slotNum in this.hardpoints) { + const slot = this.hardpoints[slotNum]; + if (slot.m) { + unladenMass += slot.m.getMass(); + } + } + + // Update global stats + this.unladenMass = unladenMass; + this.cargoCapacity = cargoCapacity; + this.fuelCapacity = fuelCapacity; + this.ladenMass = unladenMass + fuelCapacity + cargoCapacity; + + return this; + } + /** * Update movement values * @return {this} The ship instance (for chaining operations) From 975432b45a6d8725d9111acdfa7a8d3cca69528b Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Wed, 1 Feb 2017 08:33:16 +0000 Subject: [PATCH 4/6] Lint --- src/app/shipyard/Ship.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index ad8ba19c..07e539c7 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -463,7 +463,6 @@ export default class Ship { this.updatePowerUsed(); } else if (name === 'mass') { // Mass - //let oldMass = m.getMass(); m.setModValue(name, value, sentfromui); this.recalculateMass(); this.updateMovement(); @@ -1154,13 +1153,15 @@ export default class Ship { let cargoCapacity = 0; let fuelCapacity = 0; + unladenMass += this.bulkheads.m.getMass(); + for (let slotNum in this.standard) { const slot = this.standard[slotNum]; if (slot.m) { unladenMass += slot.m.getMass(); if (slot.m.grp === 'ft') { fuelCapacity += slot.m.fuel; - } + } } } @@ -1170,9 +1171,9 @@ export default class Ship { unladenMass += slot.m.getMass(); if (slot.m.grp === 'ft') { fuelCapacity += slot.m.fuel; - } else if (slot.m.grp === 'cr') { + } else if (slot.m.grp === 'cr') { cargoCapacity += slot.m.cargo; - } + } } } From 0221d05b040f5124ffcce775cb720ae50b05f68c Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Wed, 1 Feb 2017 08:57:56 +0000 Subject: [PATCH 5/6] Tweak recalculation of mass --- src/app/shipyard/Ship.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 07e539c7..705b5bea 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -889,8 +889,9 @@ export default class Ship { } } - this.recalculateMass(); if (!preventUpdate) { + // Must recalculate mass first, as movement, jump etc. relies on it + this.recalculateMass(); if (dpsChanged) { this.recalculateDps(); } From a14974fef448d5c930190198fb1c3baf2ec83c75 Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Thu, 2 Feb 2017 23:03:35 +0000 Subject: [PATCH 6/6] Bump package --- ChangeLog.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index f6f28418..e3d5949c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,9 @@ * Do not include utility slot DPS/EPS/HPS in summary information * Ensure that auto loader special shows in the tooltip * Ensure that ship mass is recalculated when appropriate + * Use coriolis-data 2.2.13: + * Add plasma slug special effect for plasma accelerator + * Tweak hull costs of ships #2.2.12 * Tidy up old references to coriolis.io diff --git a/package.json b/package.json index 64bd1106..f4d6bfbb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coriolis_shipyard", - "version": "2.2.13b", + "version": "2.2.13", "repository": { "type": "git", "url": "https://github.com/EDCD/coriolis"