Add total DPS and effectiveness information to 'Damage Dealt' section

This commit is contained in:
Cmdr McDonald
2017-01-14 16:20:48 +00:00
parent 3def84e435
commit ad06e23afa
3 changed files with 39 additions and 18 deletions

View File

@@ -2,8 +2,9 @@
* Use SSL-enabled server for shortlinks * Use SSL-enabled server for shortlinks
* Add falloff for weapons * Add falloff for weapons
* Use falloff when calculating weapon effectiveness in damage dealt * Use falloff when calculating weapon effectiveness in damage dealt
* Add engagement range slider to allow user to see change in weapon effectiveness with range * Add engagement range slider to 'Damage Dealt' section to allow user to see change in weapon effectiveness with range
* Use better DPE calculation methodology * Use better DPE calculation methodology
* Add total DPS and effectiveness information to 'Damage Dealt' section
#2.2.8 #2.2.8
* Fix issue where filling all internals with cargo racks would include restricted slots * Fix issue where filling all internals with cargo racks would include restricted slots

View File

@@ -77,8 +77,8 @@ export default class DamageDealt extends TranslatedComponent {
* Set the initial weapons state * Set the initial weapons state
*/ */
componentWillMount() { componentWillMount() {
const weapons = this._calcWeapons(this.props.ship, this.state.against, this.state.range * this.state.maxRange); const data = this._calcWeapons(this.props.ship, this.state.against, this.state.range * this.state.maxRange);
this.setState({ weapons }); this.setState({ weapons: data.weapons, totals: data.totals });
} }
/** /**
@@ -89,8 +89,8 @@ export default class DamageDealt extends TranslatedComponent {
*/ */
componentWillReceiveProps(nextProps, nextContext) { componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.code != this.props.code) { if (nextProps.code != this.props.code) {
const weapons = this._calcWeapons(this.props.ship, this.state.against, this.state.range * this.state.maxRange); const data = this._calcWeapons(this.props.ship, this.state.against, this.state.range * this.state.maxRange);
this.setState({ weapons }); this.setState({ weapons: data.weapons, totals: data.totals });
} }
return true; return true;
} }
@@ -106,6 +106,13 @@ export default class DamageDealt extends TranslatedComponent {
// Tidy up the range so that it's to 4 decimal places // Tidy up the range so that it's to 4 decimal places
range = Math.round(10000 * range) / 10000; range = Math.round(10000 * range) / 10000;
// Track totals
let totals = {};
totals.effectiveness = 0;
totals.effectiveDps = 0;
totals.effectiveSDps = 0;
let totalDps = 0;
let weapons = []; let weapons = [];
for (let i = 0; i < ship.hardpoints.length; i++) { for (let i = 0; i < ship.hardpoints.length; i++) {
if (ship.hardpoints[i].m) { if (ship.hardpoints[i].m) {
@@ -130,6 +137,9 @@ export default class DamageDealt extends TranslatedComponent {
const effectiveness = (m.getPiercing() >= against.properties.hardness ? 1 : m.getPiercing() / against.properties.hardness) * dropoff; const effectiveness = (m.getPiercing() >= against.properties.hardness ? 1 : m.getPiercing() / against.properties.hardness) * dropoff;
const effectiveDps = m.getDps() * effectiveness * dropoff; const effectiveDps = m.getDps() * effectiveness * dropoff;
const effectiveSDps = (m.getClip() ? (m.getClip() * m.getDps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()) * effectiveness : effectiveDps) * dropoff; const effectiveSDps = (m.getClip() ? (m.getClip() * m.getDps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()) * effectiveness : effectiveDps) * dropoff;
totals.effectiveDps += effectiveDps;
totals.effectiveSDps += effectiveSDps;
totalDps += m.getDps();
weapons.push({ id: i, weapons.push({ id: i,
mount: m.mount, mount: m.mount,
@@ -141,8 +151,9 @@ export default class DamageDealt extends TranslatedComponent {
} }
} }
} }
totals.effectiveness = totals.effectiveDps / totalDps;
return weapons; return {weapons: weapons, totals: totals};
} }
/** /**
@@ -158,8 +169,8 @@ export default class DamageDealt extends TranslatedComponent {
*/ */
_onShipChange(s) { _onShipChange(s) {
const against = Ships[s]; const against = Ships[s];
const weapons = this._calcWeapons(this.props.ship, against); const data = this._calcWeapons(this.props.ship, against);
this.setState({ against, weapons }); this.setState({ against, weapons: data.weapons, totals: data.totals });
} }
/** /**
@@ -236,8 +247,8 @@ export default class DamageDealt extends TranslatedComponent {
* @param {number} range Range 0-1 * @param {number} range Range 0-1
*/ */
_rangeChange(range) { _rangeChange(range) {
const weapons = this._calcWeapons(this.props.ship, this.state.against, this.state.range * this.state.maxRange); const data = this._calcWeapons(this.props.ship, this.state.against, this.state.range * this.state.maxRange);
this.setState({ range, weapons }); this.setState({ range, weapons: data.weapons, totals: data.totals });
} }
/** /**
@@ -247,7 +258,7 @@ export default class DamageDealt extends TranslatedComponent {
render() { render() {
const { language, onWindowResize, sizeRatio, tooltip, termtip } = this.context; const { language, onWindowResize, sizeRatio, tooltip, termtip } = this.context;
const { formats, translate, units } = language; const { formats, translate, units } = language;
const { expanded, maxRange, range } = this.state; const { expanded, maxRange, range, totals } = this.state;
const sortOrder = this._sortOrder; const sortOrder = this._sortOrder;
const onCollapseExpand = this._onCollapseExpand; const onCollapseExpand = this._onCollapseExpand;
@@ -269,6 +280,14 @@ export default class DamageDealt extends TranslatedComponent {
<tbody> <tbody>
{this._renderRows(translate, formats)} {this._renderRows(translate, formats)}
</tbody> </tbody>
<tfoot>
<tr className='main'>
<td className='ri'><i>{translate('total')}</i></td>
<td className='ri'><i>{formats.round1(totals.effectiveDps)}</i></td>
<td className='ri'><i>{formats.round1(totals.effectiveSDps)}</i></td>
<td className='ri'><i>{formats.pct(totals.effectiveness)}</i></td>
</tr>
</tfoot>
</table> </table>
<table style={{ width: '80%', lineHeight: '1em', backgroundColor: 'transparent', margin: 'auto' }}> <table style={{ width: '80%', lineHeight: '1em', backgroundColor: 'transparent', margin: 'auto' }}>
<tbody > <tbody >

View File

@@ -125,6 +125,7 @@ export const terms = {
'internal protection': 'Internal protection', 'internal protection': 'Internal protection',
'external protection': 'External protection', 'external protection': 'External protection',
'engagement range': 'Engagement range', 'engagement range': 'Engagement range',
'total': 'Total',
// Modifications // Modifications
ammo: 'Ammunition maximum', ammo: 'Ammunition maximum',