diff --git a/src/app/components/DamageDealt.jsx b/src/app/components/DamageDealt.jsx
index 5562db34..95b168a0 100644
--- a/src/app/components/DamageDealt.jsx
+++ b/src/app/components/DamageDealt.jsx
@@ -69,8 +69,8 @@ export default class DamageDealt extends TranslatedComponent {
const ship = this.props.ship;
const against = DamageDealt.DEFAULT_AGAINST;
- const range = 0.1667;
- const maxRange = 6000;
+ const range = 0.5;
+ const maxRange = this._calcMaxRange(ship);
const maxDps = this._calcMaxDps(ship, against)
const weaponNames = this._weaponNames(ship, context);
@@ -83,7 +83,8 @@ export default class DamageDealt extends TranslatedComponent {
maxRange,
maxDps,
weaponNames,
- calcDpsFunc: this._calcDps.bind(this, context, ship, weaponNames, against)
+ calcHullDpsFunc: this._calcDps.bind(this, context, ship, weaponNames, against, true),
+ calcShieldsDpsFunc: this._calcDps.bind(this, context, ship, weaponNames, against, false)
};
}
@@ -91,7 +92,7 @@ export default class DamageDealt extends TranslatedComponent {
* Set the initial weapons state
*/
componentWillMount() {
- const data = this._calcWeaponsDps(this.props.ship, this.state.against, this.state.range * this.state.maxRange);
+ const data = this._calcWeaponsDps(this.props.ship, this.state.against, this.state.range * this.state.maxRange, true);
this.setState({ weapons: data.weapons, totals: data.totals });
}
@@ -103,12 +104,13 @@ export default class DamageDealt extends TranslatedComponent {
*/
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.code != this.props.code) {
- const data = this._calcWeaponsDps(nextProps.ship, this.state.against, this.state.range * this.state.maxRange);
+ const data = this._calcWeaponsDps(nextProps.ship, this.state.against, this.state.range * this.state.maxRange, this.props.hull);
const weaponNames = this._weaponNames(nextProps.ship, nextContext);
this.setState({ weapons: data.weapons,
totals: data.totals,
weaponNames,
- calcDpsFunc: this._calcDps.bind(this, nextContext, nextProps.ship, this.state.weaponNames, this.state.against) });
+ calcHullDpsFunc: this._calcDps.bind(this, nextContext, nextProps.ship, this.state.weaponNames, this.state.against, true),
+ calcShieldsDpsFunc: this._calcDps.bind(this, nextContext, nextProps.ship, this.state.weaponNames, this.state.against, false) });
}
return true;
}
@@ -124,7 +126,7 @@ export default class DamageDealt extends TranslatedComponent {
for (let i =0; i < ship.hardpoints.length; i++) {
if (ship.hardpoints[i].m && ship.hardpoints[i].enabled) {
const m = ship.hardpoints[i].m;
- const thisDps = m.getDps() * (m.getPiercing() >= against.properties.hardness ? 1 : m.getPiercing() / against.properties.hardness);
+ const thisDps = m.getDps();// * (m.getPiercing() >= against.properties.hardness ? 1 : m.getPiercing() / against.properties.hardness);
if (thisDps > maxDps) {
maxDps = thisDps;
}
@@ -140,18 +142,35 @@ export default class DamageDealt extends TranslatedComponent {
* @param {Object} range The engagement range
* @return {array} The array of weapon DPS
*/
- _calcDps(context, ship, weaponNames, against, range) {
+ _calcDps(context, ship, weaponNames, against, hull, range) {
let results = {}
let weaponNum = 0;
for (let i = 0; i < ship.hardpoints.length; i++) {
if (ship.hardpoints[i].m && ship.hardpoints[i].enabled) {
const m = ship.hardpoints[i].m;
- results[weaponNames[weaponNum++]] = this._calcWeaponDps(context, m, against, range);
+ results[weaponNames[weaponNum++]] = this._calcWeaponDps(context, m, against, hull, range);
}
}
return results;
}
+ /**
+ *
+ */
+ _calcMaxRange(ship) {
+ let maxRange = 1000;
+ for (let i =0; i < ship.hardpoints.length; i++) {
+ if (ship.hardpoints[i].maxClass > 0 && ship.hardpoints[i].m && ship.hardpoints[i].enabled) {
+ const thisRange = ship.hardpoints[i].m.getRange();
+ if (thisRange > maxRange) {
+ maxRange = thisRange;
+ }
+ }
+ }
+
+ return maxRange;
+ }
+
/**
* Obtain the weapon names for this ship
* @param {Object} ship The ship
@@ -182,7 +201,7 @@ export default class DamageDealt extends TranslatedComponent {
}
- _calcWeaponDps(context, m, against, range) {
+ _calcWeaponDps(context, m, against, hull, range) {
const translate = context.language.translate
let dropoff = 1;
if (m.getFalloff()) {
@@ -214,7 +233,7 @@ export default class DamageDealt extends TranslatedComponent {
const effectiveDpsHull = m.getDps() * effectivenessHull;
const effectiveSDpsHull = (m.getClip() ? (m.getClip() * m.getDps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()) * effectivenessHull : effectiveDpsHull);
- return effectiveSDpsHull;
+ return hull ? effectiveSDpsHull : effectiveSDpsShields;
}
/**
@@ -222,7 +241,7 @@ export default class DamageDealt extends TranslatedComponent {
* @param {Object} ship The ship which will deal the damage
* @param {Object} against The ship against which damage will be dealt
* @param {Object} range The engagement range
- * @return {boolean} Returns the per-weapon damage
+ * @return {object} Returns the per-weapon damage
*/
_calcWeaponsDps(ship, against, range) {
const translate = this.context.language.translate;
@@ -319,7 +338,8 @@ export default class DamageDealt extends TranslatedComponent {
weapons: data.weapons,
totals: data.totals,
maxDps,
- calcDpsFunc: this._calcDps.bind(this, this.context, this.props.ship, this.state.weaponNames, against) });
+ calcHullDpsFunc: this._calcDps.bind(this, this.context, this.props.ship, this.state.weaponNames, against, true),
+ calcShieldsDpsFunc: this._calcDps.bind(this, this.context, this.props.ship, this.state.weaponNames, against, false) });
}
/**
@@ -385,11 +405,11 @@ export default class DamageDealt extends TranslatedComponent {
{weapon.classRating} {translate(weapon.name)}
{weapon.engineering ? ' (' + weapon.engineering + ')' : null }
-
{formats.round1(weapon.effectiveDpsShields)} |
- {formats.round1(weapon.effectiveSDpsShields)} |
+ {formats.f1(weapon.effectiveDpsShields)} |
+ {formats.f1(weapon.effectiveSDpsShields)} |
{formats.pct(weapon.effectivenessShields)} |
- {formats.round1(weapon.effectiveDpsHull)} |
- {formats.round1(weapon.effectiveSDpsHull)} |
+ {formats.f1(weapon.effectiveDpsHull)} |
+ {formats.f1(weapon.effectiveSDpsHull)} |
{formats.pct(weapon.effectivenessHull)} |
);
}
@@ -407,7 +427,8 @@ export default class DamageDealt extends TranslatedComponent {
this.setState({ range,
weapons: data.weapons,
totals: data.totals,
- calcDpsFunc: this.props.ship.calcDps.bind(this, this.props.ship, this.state.weaponNames, against) });
+ calcHullDpsFunc: this._calcDps.bind(this, this.context, this.props.ship, this.state.weaponNames, this.state.against, true),
+ calcShieldsDpsFunc: this._calcDps.bind(this, this.context, this.props.ship, this.state.weaponNames, this.state.against, false) });
}
/**
@@ -419,7 +440,6 @@ export default class DamageDealt extends TranslatedComponent {
const { formats, translate, units } = language;
const { expanded, maxRange, range, totals } = this.state;
-
const sortOrder = this._sortOrder;
const onCollapseExpand = this._onCollapseExpand;
@@ -450,11 +470,11 @@ export default class DamageDealt extends TranslatedComponent {
| {translate('total')} |
- {formats.round1(totals.effectiveDpsShields)} |
- {formats.round1(totals.effectiveSDpsShields)} |
+ {formats.f1(totals.effectiveDpsShields)} |
+ {formats.f1(totals.effectiveSDpsShields)} |
{formats.pct(totals.effectivenessShields)} |
- {formats.round1(totals.effectiveDpsHull)} |
- {formats.round1(totals.effectiveSDpsHull)} |
+ {formats.f1(totals.effectiveDpsHull)} |
+ {formats.f1(totals.effectiveSDpsHull)} |
{formats.pct(totals.effectivenessHull)} |
@@ -484,15 +504,14 @@ export default class DamageDealt extends TranslatedComponent {
{translate('damage against shields')}
@@ -500,15 +519,14 @@ export default class DamageDealt extends TranslatedComponent {
{translate('damage against hull')}
diff --git a/src/app/components/LineChart.jsx b/src/app/components/LineChart.jsx
index 9cefe98a..4e1ab0a1 100644
--- a/src/app/components/LineChart.jsx
+++ b/src/app/components/LineChart.jsx
@@ -26,7 +26,7 @@ export default class LineChart extends TranslatedComponent {
yLabel: React.PropTypes.string.isRequired,
yMin: React.PropTypes.number,
yMax: React.PropTypes.number.isRequired,
- yUnit: React.PropTypes.string.isRequired,
+ yUnit: React.PropTypes.string,
series: React.PropTypes.array,
colors: React.PropTypes.array,
points: React.PropTypes.number,
@@ -99,7 +99,7 @@ export default class LineChart extends TranslatedComponent {
let yVal = series ? y0[series[i]] : y0;
yTotal += yVal;
return (series ? translate(series[i]) : '') + ' ' + formats.f2(yVal);
- }).append('tspan').attr('class', 'metric').text(' ' + yUnit);
+ }).append('tspan').attr('class', 'metric').text(yUnit ? ' ' + yUnit : '');
tips.selectAll('text').each(function() {
if (this.getBBox().width > tipWidth) {
@@ -228,7 +228,7 @@ export default class LineChart extends TranslatedComponent {
let { xLabel, yLabel, xUnit, yUnit, colors } = this.props;
let { innerWidth, outerHeight, innerHeight, tipHeight, detailElems, markerElems, seriesData, seriesLines } = this.state;
let line = this.line;
- let lines = seriesLines.map((line, i) => );
+ let lines = seriesLines.map((line, i) => );
return