Add 'Piercing' information to hardpoints; add 'Hardness' information to ship summary

This commit is contained in:
Cmdr McDonald
2016-12-18 09:36:33 +00:00
parent b8cff0c2fc
commit 51d7b6c9aa
7 changed files with 50 additions and 32 deletions

View File

@@ -15,6 +15,8 @@
* Do not include disabled shield boosters in calculations
* Add 'Damage dealt' section
* Add 'Damage received' section
* Add 'Piercing' information to hardpoints
* Add 'Hardness' information to ship summary
#2.2.5
* Calculate rate of fire for multi-burst weapons

View File

@@ -73,20 +73,30 @@ export default class DamageDealt extends TranslatedComponent {
*/
componentWillMount() {
const weapons = this._calcWeapons(this.props.ship, this.state.against);
this.setState({ weapons: weapons });
this.setState({ weapons });
}
/**
* Set the updated weapons state
* Set the updated weapons state if our ship changes
* @param {Object} nextProps Incoming/Next properties
* @param {Object} nextContext Incoming/Next conext
* @return {boolean} Returns true if the component should be rerendered
*/
componentWillReceiveProps(nextProps, nextContext) {
const weapons = this._calcWeapons(this.props.ship, this.state.against);
this.setState({ weapons: weapons });
if (nextProps.code != this.props.code) {
const weapons = this._calcWeapons(this.props.ship, this.state.against);
this.setState({ weapons });
}
return true;
}
/**
* Calculate the damage dealt by a ship
* @param {Object} ship The ship which will deal the damage
* @param {Object} against The ship against which damage will be dealt
* @return {boolean} Returns the per-weapon damage
*/
_calcWeapons(ship, against) {
// Create a list of the ship's weapons and include required stats - this is so that we muck around with re-ordering and the like on the fly
let weapons = [];
for (let i = 0; i < ship.hardpoints.length; i++) {
@@ -97,13 +107,13 @@ export default class DamageDealt extends TranslatedComponent {
const effectiveDps = m.getDps() * effectiveness;
const effectiveSDps = m.getClip() ? (m.getClip() * m.getDps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()) * effectiveness : effectiveDps;
weapons.push({id: i,
mount: m.mount,
name: m.name || m.grp,
classRating: classRating,
effectiveDps: effectiveDps,
effectiveSDps: effectiveSDps,
effectiveness: effectiveness});
weapons.push({ id: i,
mount: m.mount,
name: m.name || m.grp,
classRating,
effectiveDps,
effectiveSDps,
effectiveness });
}
}
@@ -111,16 +121,13 @@ export default class DamageDealt extends TranslatedComponent {
}
/**
* Triggered when the ship changes
* Triggered when the ship we compare against changes
* @param {string} s the new ship ID
*/
_onShipChange(s) {
const against = Ships[s];
const weapons = this._calcWeapons(this.props.ship, against);
// This is not the correct 'this'
console.log('1) State against is' + this.state.against.properties.name);
this.setState({ against: against, weapons: weapons });
console.log('2) State against is' + this.state.against.properties.name);
this.setState({ against, weapons });
}
/**

View File

@@ -72,14 +72,21 @@ export default class DamageReceived extends TranslatedComponent {
/**
* Set the updated weapons state
* @param {Object} nextProps Incoming/Next properties
* @param {Object} nextContext Incoming/Next conext
* @return {boolean} Returns true if the component should be rerendered
*/
componentWillReceiveProps(nextProps, nextContext) {
this.setState({ weapons: this._calcWeapons(nextProps.ship) });
return true;
}
/**
* Calculate the damage received by a ship
* @param {Object} ship The ship which will receive the damage
* @return {boolean} Returns the per-weapon damage
*/
_calcWeapons(ship) {
// Create a list of all weapons and include their stats - this is so that we can muck around with re-ordering and the like on the fly
let weapons = [];
for (let grp in Modules.hardpoints) {
@@ -132,16 +139,16 @@ export default class DamageReceived extends TranslatedComponent {
const effectiveDpsHull = baseDps * effectivenessHull;
const effectiveSDpsHull = baseSDps * effectivenessHull;
weapons.push({id: m.id,
classRating: classRating,
name: m.name || m.grp,
mount: m.mount,
effectiveDpsShields: effectiveDpsShields,
effectiveSDpsShields: effectiveSDpsShields,
effectivenessShields: effectivenessShields,
effectiveDpsHull: effectiveDpsHull,
effectiveSDpsHull: effectiveSDpsHull,
effectivenessHull: effectivenessHull});
weapons.push({ id: m.id,
classRating,
name: m.name || m.grp,
mount: m.mount,
effectiveDpsShields,
effectiveSDpsShields,
effectivenessShields,
effectiveDpsHull,
effectiveSDpsHull,
effectivenessHull });
}
}
}

View File

@@ -76,6 +76,7 @@ export default class HardpointSlot extends Slot {
{ m.getRange() ? <div className={'l'}>{translate('range')} {formats.f1(m.getRange() / 1000)}{u.km}</div> : null }
{ m.getShieldBoost() ? <div className={'l'}>+{formats.pct1(m.getShieldBoost())}</div> : null }
{ m.getAmmo() ? <div className={'l'}>{translate('ammunition')}: {formats.int(m.getClip())}/{formats.int(m.getAmmo())}</div> : null }
{ m.getPiercing() ? <div className={'l'}>{translate('piercing')}: {formats.int(m.getPiercing())}</div> : null }
{ m.getJitter() ? <div className={'l'}>{translate('jitter')}: {formats.f2(m.getJitter())}°</div> : null }
{ showModuleResistances && m.getExplosiveResistance() ? <div className='l'>{translate('explres')}: {formats.pct(m.getExplosiveResistance())}</div> : null }
{ showModuleResistances && m.getKineticResistance() ? <div className='l'>{translate('kinres')}: {formats.pct(m.getKineticResistance())}</div> : null }

View File

@@ -43,6 +43,7 @@ export default class ShipSummaryTable extends TranslatedComponent {
<th onMouseEnter={termtip.bind(null, 'damage per second')} onMouseLeave={hide} rowSpan={2}>{translate('DPS')}</th>
<th onMouseEnter={termtip.bind(null, 'energy per second')} onMouseLeave={hide} rowSpan={2}>{translate('EPS')}</th>
<th onMouseEnter={termtip.bind(null, 'heat per second')} onMouseLeave={hide} rowSpan={2}>{translate('HPS')}</th>
<th rowSpan={2}>{translate('hardness')}</th>
<th rowSpan={2}>{translate('armour')}</th>
<th rowSpan={2}>{translate('shields')}</th>
<th colSpan={3}>{translate('mass')}</th>
@@ -71,6 +72,7 @@ export default class ShipSummaryTable extends TranslatedComponent {
<td>{f1(ship.totalDps)}</td>
<td>{f1(ship.totalEps)}</td>
<td>{f1(ship.totalHps)}</td>
<td>{int(ship.hardness)}</td>
<td>{int(ship.armour)}</td>
<td className={sgClassNames}>{int(ship.shield)} {u.MJ}</td>
<td>{ship.hullMass} {u.T}</td>

View File

@@ -142,10 +142,10 @@ export default class ShipyardPage extends Page {
<td className='le'>{s.manufacturer}</td>
<td className='cap'>{translate(SizeMap[s.class])}</td>
<td className='ri'>{fInt(s.agility)}</td>
<td className='ri'>{fInt(s.hardness)}</td>
<td className='ri'>{fInt(s.speed)}{u['m/s']}</td>
<td className='ri'>{fInt(s.boost)}{u['m/s']}</td>
<td className='ri'>{fInt(s.baseArmour)}</td>
<td className='ri'>{fInt(s.hardness)}</td>
<td className='ri'>{fInt(s.baseShieldStrength)}{u.MJ}</td>
<td className='ri'>{fInt(s.topSpeed)}{u['m/s']}</td>
<td className='ri'>{fInt(s.topBoost)}{u['m/s']}</td>
@@ -270,7 +270,8 @@ export default class ShipyardPage extends Page {
<th rowSpan={2} className='sortable' onClick={sortShips('manufacturer')}>{translate('manufacturer')}</th>
<th rowSpan={2} className='sortable' onClick={sortShips('class')}>{translate('size')}</th>
<th rowSpan={2} className='sortable' onClick={sortShips('agility')}>{translate('agility')}</th>
<th colSpan={5}>{translate('base')}</th>
<th rowSpan={2} className='sortable' onClick={sortShips('hardness')}>{translate('hardness')}</th>
<th colSpan={4}>{translate('base')}</th>
<th colSpan={4}>{translate('max')}</th>
<th colSpan={6}>{translate('core module classes')}</th>
<th colSpan={5} className='sortable' onClick={sortShips('hpCount')}>{translate('hardpoints')}</th>
@@ -283,7 +284,6 @@ export default class ShipyardPage extends Page {
<th className='sortable lft' onClick={sortShips('speed')}>{translate('speed')}</th>
<th className='sortable' onClick={sortShips('boost')}>{translate('boost')}</th>
<th className='sortable' onClick={sortShips('baseArmour')}>{translate('armour')}</th>
<th className='sortable' onClick={sortShips('hardness')}>{translate('hardness')}</th>
<th className='sortable' onClick={sortShips('baseShieldStrength')}>{translate('shields')}</th>
<th className='sortable lft' onClick={sortShips('topSpeed')}>{translate('speed')}</th>

View File

@@ -1666,7 +1666,6 @@ export default class Ship {
/**
* Upgrade information about internals with version changes
* @param {int} shipId the ID of the ship
* @param {array} internals the internals from the ship code
* @param {int} offset the offset of the internals information in the priorities etc. arrays
* @param {array} priorities the existing priorities arrray