mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 22:33:24 +00:00
More metrics
This commit is contained in:
@@ -129,16 +129,37 @@ export default class Offence extends TranslatedComponent {
|
||||
* @return {React.Component} contents
|
||||
*/
|
||||
render() {
|
||||
const { ship, wep } = this.props;
|
||||
const { ship, opponent, wep, engagementrange } = this.props;
|
||||
const { language, tooltip, termtip } = this.context;
|
||||
const { formats, translate, units } = language;
|
||||
const { damage } = this.state;
|
||||
const sortOrder = this._sortOrder;
|
||||
|
||||
const opponentShields = Calc.shieldMetrics(opponent, 4);
|
||||
const opponentArmour = Calc.armourMetrics(opponent);
|
||||
|
||||
let absoluteShieldsSDps = 0;
|
||||
let explosiveShieldsSDps = 0;
|
||||
let kineticShieldsSDps = 0;
|
||||
let thermalShieldsSDps = 0;
|
||||
let absoluteArmourSDps = 0;
|
||||
let explosiveArmourSDps = 0;
|
||||
let kineticArmourSDps = 0;
|
||||
let thermalArmourSDps = 0;
|
||||
|
||||
const rows = [];
|
||||
for (let i = 0; i < damage.length; i++) {
|
||||
const weapon = damage[i];
|
||||
|
||||
absoluteShieldsSDps += weapon.sdps.shields.absolute;
|
||||
explosiveShieldsSDps += weapon.sdps.shields.explosive;
|
||||
kineticShieldsSDps += weapon.sdps.shields.kinetic;
|
||||
thermalShieldsSDps += weapon.sdps.shields.thermal;
|
||||
absoluteArmourSDps += weapon.sdps.armour.absolute;
|
||||
explosiveArmourSDps += weapon.sdps.armour.explosive;
|
||||
kineticArmourSDps += weapon.sdps.armour.kinetic;
|
||||
thermalArmourSDps += weapon.sdps.armour.thermal;
|
||||
|
||||
const effectivenessShieldsTooltipDetails = [];
|
||||
effectivenessShieldsTooltipDetails.push(<div key='range'>{translate('range') + ' ' + formats.pct1(weapon.effectiveness.shields.range)}</div>);
|
||||
effectivenessShieldsTooltipDetails.push(<div key='resistance'>{translate('resistance') + ' ' + formats.pct1(weapon.effectiveness.shields.resistance)}</div>);
|
||||
@@ -176,16 +197,25 @@ export default class Offence extends TranslatedComponent {
|
||||
</tr>);
|
||||
}
|
||||
|
||||
// const armourDamageTakenData = [];
|
||||
// armourDamageTakenData.push({ value: Math.round(armour.absolute.total * 100), label: translate('absolute') });
|
||||
// armourDamageTakenData.push({ value: Math.round(armour.explosive.total * 100), label: translate('explosive') });
|
||||
// armourDamageTakenData.push({ value: Math.round(armour.kinetic.total * 100), label: translate('kinetic') });
|
||||
// armourDamageTakenData.push({ value: Math.round(armour.thermal.total * 100), label: translate('thermal') });
|
||||
const totalShieldsSDps = absoluteShieldsSDps + explosiveShieldsSDps + kineticShieldsSDps + thermalShieldsSDps;
|
||||
const totalArmourSDps = absoluteArmourSDps + explosiveArmourSDps + kineticArmourSDps + thermalArmourSDps;
|
||||
|
||||
const shieldsSDpsData = [];
|
||||
shieldsSDpsData.push({ value: Math.round(absoluteShieldsSDps), label: translate('absolute') });
|
||||
shieldsSDpsData.push({ value: Math.round(explosiveShieldsSDps), label: translate('explosive') });
|
||||
shieldsSDpsData.push({ value: Math.round(kineticShieldsSDps), label: translate('kinetic') });
|
||||
shieldsSDpsData.push({ value: Math.round(thermalShieldsSDps), label: translate('thermal') });
|
||||
|
||||
const armourSDpsData = [];
|
||||
armourSDpsData.push({ value: Math.round(absoluteArmourSDps), label: translate('absolute') });
|
||||
armourSDpsData.push({ value: Math.round(explosiveArmourSDps), label: translate('explosive') });
|
||||
armourSDpsData.push({ value: Math.round(kineticArmourSDps), label: translate('kinetic') });
|
||||
armourSDpsData.push({ value: Math.round(thermalArmourSDps), label: translate('thermal') });
|
||||
|
||||
return (
|
||||
<span id='offence'>
|
||||
<div className='group half'>
|
||||
<table width='100%'>
|
||||
<div className='group full'>
|
||||
<table>
|
||||
<thead>
|
||||
<tr className='main'>
|
||||
<th rowSpan='2' className='sortable' onClick={sortOrder.bind(this, 'n')}>{translate('weapon')}</th>
|
||||
@@ -204,6 +234,19 @@ export default class Offence extends TranslatedComponent {
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className='group quarter'>
|
||||
<h2>{translate('shield damage')}</h2>
|
||||
<h2 onMouseOver={termtip.bind(null, translate('TT_TIME_TO_REMOVE_SHIELDS'))} onMouseOut={tooltip.bind(null, null)}>{translate('PHRASE_TIME_TO_REMOVE_SHIELDS')}<br/>{totalShieldsSDps == 0 ? translate('never') : formats.time(opponentShields.total / totalShieldsSDps)}</h2>
|
||||
<h2 onMouseOver={termtip.bind(null, translate('TT_TIME_TO_REMOVE_ARMOUR'))} onMouseOut={tooltip.bind(null, null)}>{translate('PHRASE_TIME_TO_REMOVE_ARMOUR')}<br/>{totalArmourSDps == 0 ? translate('never') : formats.time(opponentArmour.total / totalArmourSDps)}</h2>
|
||||
</div>
|
||||
<div className='group quarter'>
|
||||
<h2 onMouseOver={termtip.bind(null, translate('armour metrics'))} onMouseOut={tooltip.bind(null, null)}>{translate('shield damage sources')}</h2>
|
||||
<PieChart data={shieldsSDpsData} />
|
||||
</div>
|
||||
<div className='group quarter'>
|
||||
<h2 onMouseOver={termtip.bind(null, translate('PHRASE_ARMOUR_DAMAGE'))} onMouseOut={tooltip.bind(null, null)}>{translate('armour damage sources')}</h2>
|
||||
<PieChart data={armourSDpsData} />
|
||||
</div>
|
||||
</span>);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,9 @@ export default class PieChart extends Component {
|
||||
const labelTranslate = `translate(${labelX * 1.5}, ${labelY * 1.5})`;
|
||||
|
||||
// Put the keys in a line with equal spacing
|
||||
const keyX = -width / 2 + (width / data.length) * (i + 0.5);
|
||||
const nonZeroItems = data.filter(d => d.value != 0).length;
|
||||
const thisItemIndex = data.slice(0, i + 1).filter(d => d.value != 0).length - 1;
|
||||
const keyX = -width / 2 + (width / nonZeroItems) * (thisItemIndex + 0.5);
|
||||
const keyTranslate = `translate(${keyX}, ${width * 0.45})`;
|
||||
|
||||
return (
|
||||
|
||||
@@ -24,7 +24,7 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
||||
* @return {React.Component} Summary table
|
||||
*/
|
||||
render() {
|
||||
const { ship, fuel, eng, cargo, boost } = this.props;
|
||||
const { ship, fuel, eng, wep, cargo, boost } = this.props;
|
||||
let { language, tooltip, termtip } = this.context;
|
||||
let translate = language.translate;
|
||||
let u = language.units;
|
||||
@@ -40,6 +40,8 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
||||
sgRecharge = time(ship.calcShieldRecharge());
|
||||
}
|
||||
|
||||
const timeToDrain = Calc.timeToDrainWep(ship, wep);
|
||||
|
||||
return <div id='summary'>
|
||||
<table id='summaryTable'>
|
||||
<thead>
|
||||
@@ -74,7 +76,7 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
||||
<td>{ ship.canBoost() ? <span>{int(ship.calcSpeed(eng, fuel, cargo, true))}{u['m/s']}</span> : <span className='warning'>0 <Warning/></span> }</td>
|
||||
<td>{f1(ship.totalDps)}</td>
|
||||
<td>{f1(ship.totalEps)}</td>
|
||||
<td>{ship.timeToDrain === Infinity ? '∞' : time(ship.timeToDrain)}</td>
|
||||
<td>{timeToDrain === Infinity ? '∞' : time(timeToDrain)}</td>
|
||||
<td>{f1(ship.totalHps)}</td>
|
||||
<td>{int(ship.hardness)}</td>
|
||||
<td>{int(ship.armour)}</td>
|
||||
|
||||
@@ -48,6 +48,8 @@ export const terms = {
|
||||
PHRASE_TIME_TO_LOSE_ARMOUR: 'Armour will hold for',
|
||||
PHRASE_MODULE_PROTECTION_EXTERNAL: 'Protection for hardpoints',
|
||||
PHRASE_MODULE_PROTECTION_INTERNAL: 'Protection for all other modules',
|
||||
PHRASE_SHIELD_DAMAGE: 'Breakdown of sources for sustained DPS against shields',
|
||||
PHRASE_ARMOUR_DAMAGE: 'Breakdown of sources for sustained DPS against armour',
|
||||
|
||||
TT_TIME_TO_LOSE_SHIELDS: 'Against sustained fire from all opponent\'s weapons',
|
||||
TT_TIME_TO_LOSE_ARMOUR: 'Against sustained fire from all opponent\'s weapons',
|
||||
|
||||
@@ -710,6 +710,7 @@ export function _sustainedDps(ship, opponent, opponentShields, opponentArmour, e
|
||||
* @returns {Object} Sustained DPS for shield and armour
|
||||
*/
|
||||
export function _weaponSustainedDps(m, opponent, opponentShields, opponentArmour, engagementrange) {
|
||||
const opponentHasShields = opponentShields.generator ? true : false;
|
||||
const weapon = {
|
||||
damage: {
|
||||
shields: {
|
||||
@@ -730,7 +731,7 @@ export function _weaponSustainedDps(m, opponent, opponentShields, opponentArmour
|
||||
effectiveness: {
|
||||
shields: {
|
||||
range: 1,
|
||||
sys: opponentShields.absolute.sys,
|
||||
sys: opponentHasShields ? opponentShields.absolute.sys : 1,
|
||||
resistance: 1
|
||||
},
|
||||
armour: {
|
||||
@@ -761,27 +762,27 @@ export function _weaponSustainedDps(m, opponent, opponentShields, opponentArmour
|
||||
let shieldsResistance = 0;
|
||||
let armourResistance = 0;
|
||||
if (m.getDamageDist().A) {
|
||||
weapon.damage.shields.absolute += sDps * m.getDamageDist().A * opponentShields.absolute.total;
|
||||
weapon.damage.shields.absolute += sDps * m.getDamageDist().A * (opponentHasShields ? opponentShields.absolute.total : 1);
|
||||
weapon.damage.armour.absolute += sDps * m.getDamageDist().A * armourMultiple * opponentArmour.absolute.total;
|
||||
shieldsResistance += m.getDamageDist().A * opponentShields.absolute.generator * opponentShields.absolute.boosters;
|
||||
shieldsResistance += m.getDamageDist().A * (opponentHasShields ? opponentShields.absolute.generator * opponentShields.absolute.boosters : 1);
|
||||
armourResistance += m.getDamageDist().A * opponentArmour.absolute.bulkheads * opponentArmour.absolute.reinforcement;
|
||||
}
|
||||
if (m.getDamageDist().E) {
|
||||
weapon.damage.shields.explosive += sDps * m.getDamageDist().E * opponentShields.explosive.total;
|
||||
weapon.damage.shields.explosive += sDps * m.getDamageDist().E * (opponentHasShields ? opponentShields.explosive.total : 1);
|
||||
weapon.damage.armour.explosive += sDps * m.getDamageDist().E * armourMultiple * opponentArmour.explosive.total;
|
||||
shieldsResistance += m.getDamageDist().E * opponentShields.explosive.generator * opponentShields.explosive.boosters;
|
||||
shieldsResistance += m.getDamageDist().E * (opponentHasShields ? opponentShields.explosive.generator * opponentShields.explosive.boosters : 1);
|
||||
armourResistance += m.getDamageDist().E * opponentArmour.explosive.bulkheads * opponentArmour.explosive.reinforcement;
|
||||
}
|
||||
if (m.getDamageDist().K) {
|
||||
weapon.damage.shields.kinetic += sDps * m.getDamageDist().K * opponentShields.kinetic.total;
|
||||
weapon.damage.shields.kinetic += sDps * m.getDamageDist().K * (opponentHasShields ? opponentShields.kinetic.total : 1);
|
||||
weapon.damage.armour.kinetic += sDps * m.getDamageDist().K * armourMultiple * opponentArmour.kinetic.total;
|
||||
shieldsResistance += m.getDamageDist().K * opponentShields.kinetic.generator * opponentShields.kinetic.boosters;
|
||||
shieldsResistance += m.getDamageDist().K * (opponentHasShields ? opponentShields.kinetic.generator * opponentShields.kinetic.boosters : 1);
|
||||
armourResistance += m.getDamageDist().K * opponentArmour.kinetic.bulkheads * opponentArmour.kinetic.reinforcement;
|
||||
}
|
||||
if (m.getDamageDist().T) {
|
||||
weapon.damage.shields.thermal += sDps * m.getDamageDist().T * opponentShields.thermal.total;
|
||||
weapon.damage.shields.thermal += sDps * m.getDamageDist().T * (opponentHasShields ? opponentShields.thermal.total : 1);
|
||||
weapon.damage.armour.thermal += sDps * m.getDamageDist().T * armourMultiple * opponentArmour.thermal.total;
|
||||
shieldsResistance += m.getDamageDist().T * opponentShields.thermal.generator * opponentShields.thermal.boosters;
|
||||
shieldsResistance += m.getDamageDist().T * (opponentHasShields ? opponentShields.thermal.generator * opponentShields.thermal.boosters : 1);
|
||||
armourResistance += m.getDamageDist().T * opponentArmour.thermal.bulkheads * opponentArmour.thermal.reinforcement;
|
||||
}
|
||||
weapon.damage.shields.total = weapon.damage.shields.absolute + weapon.damage.shields.explosive + weapon.damage.shields.kinetic + weapon.damage.shields.thermal;
|
||||
@@ -794,3 +795,30 @@ export function _weaponSustainedDps(m, opponent, opponentShields, opponentArmour
|
||||
weapon.effectiveness.armour.total = weapon.effectiveness.armour.range * weapon.effectiveness.armour.resistance * weapon.effectiveness.armour.hardness;
|
||||
return weapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate time to drain WEP capacitor
|
||||
* @param {object} ship The ship
|
||||
* @param {number} wep Pips to WEP
|
||||
* @return The time to drain the WEP capacitor, in seconds
|
||||
*/
|
||||
export function timeToDrainWep(ship, wep) {
|
||||
let totalSEps = 0;
|
||||
|
||||
for (let slotNum in ship.hardpoints) {
|
||||
const slot = ship.hardpoints[slotNum];
|
||||
if (slot.maxClass > 0 && 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 - ship.standard[4].m.getWeaponsRechargeRate() * wep / 4;
|
||||
if (drainPerSecond <= 0) {
|
||||
// Can fire forever
|
||||
return Infinity;
|
||||
} else {
|
||||
const initialCharge = ship.standard[4].m.getWeaponsCapacity();
|
||||
return initialCharge / drainPerSecond;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +453,6 @@ export default class Ship {
|
||||
.recalculateDps()
|
||||
.recalculateEps()
|
||||
.recalculateHps()
|
||||
.recalculateTtd()
|
||||
.updateMovement();
|
||||
}
|
||||
|
||||
@@ -522,15 +521,11 @@ 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 if (name === 'engcap') {
|
||||
m.setModValue(name, value, sentfromui);
|
||||
// Might have resulted in a change in boostability
|
||||
@@ -668,7 +663,6 @@ export default class Ship {
|
||||
.recalculateDps()
|
||||
.recalculateEps()
|
||||
.recalculateHps()
|
||||
.recalculateTtd()
|
||||
.updateMovement();
|
||||
}
|
||||
|
||||
@@ -850,7 +844,6 @@ export default class Ship {
|
||||
|
||||
if (slot.m.getEps()) {
|
||||
this.recalculateEps();
|
||||
this.recalculateTtd();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -926,7 +919,6 @@ export default class Ship {
|
||||
}
|
||||
if (epsChanged) {
|
||||
this.recalculateEps();
|
||||
this.recalculateTtd();
|
||||
}
|
||||
if (hpsChanged) {
|
||||
this.recalculateHps();
|
||||
@@ -934,9 +926,6 @@ export default class Ship {
|
||||
if (powerGeneratedChange) {
|
||||
this.updatePowerGenerated();
|
||||
}
|
||||
if (powerDistributorChange) {
|
||||
this.recalculateTtd();
|
||||
}
|
||||
if (powerUsedChange) {
|
||||
this.updatePowerUsed();
|
||||
}
|
||||
@@ -974,33 +963,6 @@ export default class Ship {
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
||||
Reference in New Issue
Block a user