mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 22:55:35 +00:00
Tidy-ups
This commit is contained in:
@@ -29,8 +29,8 @@ export default class Defence extends TranslatedComponent {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
const { shield, armour, damagetaken } = this._calcMetrics(props.ship, props.opponent, props.sys);
|
const { shield, armour, shielddamage } = this._calcMetrics(props.ship, props.opponent, props.sys);
|
||||||
this.state = { shield, armour, damagetaken };
|
this.state = { shield, armour, shielddamage };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,8 +40,8 @@ export default class Defence extends TranslatedComponent {
|
|||||||
*/
|
*/
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (this.props.marker != nextProps.marker || this.props.sys != nextProps.sys) {
|
if (this.props.marker != nextProps.marker || this.props.sys != nextProps.sys) {
|
||||||
const { shield, armour, damagetaken } = this._calcMetrics(nextProps.ship, nextProps.opponent, nextProps.sys);
|
const { shield, armour, shielddamage } = this._calcMetrics(nextProps.ship, nextProps.opponent, nextProps.sys);
|
||||||
this.setState({ shield, armour, damagetaken });
|
this.setState({ shield, armour, shielddamage });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,16 @@ export default class Defence extends TranslatedComponent {
|
|||||||
_calcMetrics(ship, opponent, sys) {
|
_calcMetrics(ship, opponent, sys) {
|
||||||
const sysResistance = this._calcSysResistance(sys);
|
const sysResistance = this._calcSysResistance(sys);
|
||||||
|
|
||||||
|
// Obtain the opponent's sustained DPS for later damage calculations
|
||||||
|
// const opponentSDps = Calc.sustainedDps(opponent, range);
|
||||||
|
const opponentSDps = {
|
||||||
|
absolute: 62.1,
|
||||||
|
explosive: 0,
|
||||||
|
kinetic: 7.4,
|
||||||
|
thermal: 7.4
|
||||||
|
};
|
||||||
|
|
||||||
|
let shielddamage = {};
|
||||||
let shield = {};
|
let shield = {};
|
||||||
const shieldGeneratorSlot = ship.findInternalByGroup('sg');
|
const shieldGeneratorSlot = ship.findInternalByGroup('sg');
|
||||||
if (shieldGeneratorSlot && shieldGeneratorSlot.enabled && shieldGeneratorSlot.m) {
|
if (shieldGeneratorSlot && shieldGeneratorSlot.enabled && shieldGeneratorSlot.m) {
|
||||||
@@ -122,11 +132,17 @@ export default class Defence extends TranslatedComponent {
|
|||||||
sys: (1 - sysResistance),
|
sys: (1 - sysResistance),
|
||||||
total: (1 - shieldGenerator.getThermalResistance()) * boosterThermDmg * (1 - sysResistance)
|
total: (1 - shieldGenerator.getThermalResistance()) * boosterThermDmg * (1 - sysResistance)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
shielddamage.absolutesdps = opponentSDps.absolute *= shield.absolute.total;
|
||||||
|
shielddamage.explosivesdps = opponentSDps.explosive *= shield.explosive.total;
|
||||||
|
shielddamage.kineticsdps = opponentSDps.kinetic *= shield.kinetic.total;
|
||||||
|
shielddamage.thermalsdps = opponentSDps.thermal *= shield.thermal.total;
|
||||||
|
shielddamage.totalsdps = shielddamage.absolutesdps + shielddamage.explosivesdps + shielddamage.kineticsdps + shielddamage.thermalsdps;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Armour from bulkheads
|
// Armour from bulkheads
|
||||||
const armourBulkheads = ship.baseArmour + (ship.baseArmour * ship.bulkheads.m.getHullBoost());
|
const armourBulkheads = ship.baseArmour + (ship.baseArmour * ship.bulkheads.m.getHullBoost());
|
||||||
let armourReinforcement = 0
|
let armourReinforcement = 0;
|
||||||
|
|
||||||
let modulearmour = 0;
|
let modulearmour = 0;
|
||||||
let moduleprotection = 1;
|
let moduleprotection = 1;
|
||||||
@@ -193,31 +209,7 @@ export default class Defence extends TranslatedComponent {
|
|||||||
total: (1 - ship.bulkheads.m.getThermalResistance()) * hullThermDmg
|
total: (1 - ship.bulkheads.m.getThermalResistance()) * hullThermDmg
|
||||||
};
|
};
|
||||||
|
|
||||||
// Use the SDPS for each weapon type of the opponent to work out how long the shields and armour will last
|
return { shield, armour, shielddamage };
|
||||||
// const opponentSDps = Calc.sustainedDps(opponent, range);
|
|
||||||
const opponentSDps = {
|
|
||||||
absolute: 62.1,
|
|
||||||
explosive: 0,
|
|
||||||
kinetic: 7.4,
|
|
||||||
thermal: 7.4
|
|
||||||
};
|
|
||||||
|
|
||||||
// Modify according to resistances to see how much damage we actually take
|
|
||||||
//opponentSDps.absolute *= shield.absolute.total;
|
|
||||||
//opponentSDps.explosive *= shield.explosive.total;
|
|
||||||
//opponentSDps.kinetic *= shield.kinetic.total;
|
|
||||||
//opponentSDps.thermal *= shield.thermal.total;
|
|
||||||
opponentSDps.total = opponentSDps.absolute + opponentSDps.explosive + opponentSDps.kinetic + opponentSDps.thermal;
|
|
||||||
|
|
||||||
const damagetaken = {
|
|
||||||
absolutesdps: opponentSDps.absolute,
|
|
||||||
explosivesdps: opponentSDps.explosive,
|
|
||||||
kineticsdps: opponentSDps.kinetic,
|
|
||||||
thermalsdps: opponentSDps.thermal,
|
|
||||||
tts: (shield.total + ship.shieldCells) / opponentSDps.total,
|
|
||||||
};
|
|
||||||
|
|
||||||
return { shield, armour, damagetaken };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -237,7 +229,7 @@ export default class Defence extends TranslatedComponent {
|
|||||||
const { ship, sys } = this.props;
|
const { ship, sys } = this.props;
|
||||||
const { language, tooltip, termtip } = this.context;
|
const { language, tooltip, termtip } = this.context;
|
||||||
const { formats, translate, units } = language;
|
const { formats, translate, units } = language;
|
||||||
const { shield, armour, damagetaken } = this.state;
|
const { shield, armour, shielddamage } = this.state;
|
||||||
|
|
||||||
const shieldSourcesData = [];
|
const shieldSourcesData = [];
|
||||||
const effectiveShieldData = [];
|
const effectiveShieldData = [];
|
||||||
@@ -321,58 +313,7 @@ export default class Defence extends TranslatedComponent {
|
|||||||
<div className='group half'>
|
<div className='group half'>
|
||||||
<div className='group half'>
|
<div className='group half'>
|
||||||
<h2 onMouseOver={termtip.bind(null, <div>{shieldTooltipDetails}</div>)} onMouseOut={tooltip.bind(null, null)} className='summary'>{translate('shields')}: {formats.int(shield.total)}{units.MJ}</h2>
|
<h2 onMouseOver={termtip.bind(null, <div>{shieldTooltipDetails}</div>)} onMouseOut={tooltip.bind(null, null)} className='summary'>{translate('shields')}: {formats.int(shield.total)}{units.MJ}</h2>
|
||||||
<table>
|
<h2>{translate('PHRASE_TIME_TO_LOSE_SHIELDS')} {formats.time(shield.total / shielddamage.totalsdps)}</h2>
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td className='le'>{translate('damage type')}</td>
|
|
||||||
<td className='ce'>
|
|
||||||
<span className='icon' onMouseOver={termtip.bind(null, 'absolute')} onMouseOut={tooltip.bind(null, null)}><DamageAbsolute /></span>
|
|
||||||
</td>
|
|
||||||
<td className='ce'>
|
|
||||||
<span className='icon' onMouseOver={termtip.bind(null, 'explosive')} onMouseOut={tooltip.bind(null, null)}><DamageExplosive /></span>
|
|
||||||
</td>
|
|
||||||
<td className='ce'>
|
|
||||||
<span className='icon' onMouseOver={termtip.bind(null, 'kinetic')} onMouseOut={tooltip.bind(null, null)}><DamageKinetic /></span>
|
|
||||||
</td>
|
|
||||||
<td className='ce'>
|
|
||||||
<span className='icon' onMouseOver={termtip.bind(null, 'thermal')} onMouseOut={tooltip.bind(null, null)}><DamageThermal /></span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td className='le'>{translate('damage taken')}</td>
|
|
||||||
<td className='ri'>
|
|
||||||
<span onMouseOver={termtip.bind(null, <div>{shieldAbsoluteTooltipDetails}</div>)} onMouseOut={tooltip.bind(null, null)}>{formats.pct1(shield.absolute.total)}</span>
|
|
||||||
</td>
|
|
||||||
<td className='ri'>
|
|
||||||
<span onMouseOver={termtip.bind(null, <div>{shieldExplosiveTooltipDetails}</div>)} onMouseOut={tooltip.bind(null, null)}>{formats.pct1(shield.explosive.total)}</span>
|
|
||||||
</td>
|
|
||||||
<td className='ri'>
|
|
||||||
<span onMouseOver={termtip.bind(null, <div>{shieldKineticTooltipDetails}</div>)} onMouseOut={tooltip.bind(null, null)}>{formats.pct1(shield.kinetic.total)}</span>
|
|
||||||
</td>
|
|
||||||
<td className='ri'>
|
|
||||||
<span onMouseOver={termtip.bind(null, <div>{shieldThermalTooltipDetails}</div>)} onMouseOut={tooltip.bind(null, null)}>{formats.pct1(shield.thermal.total)}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td className='le'>{translate('effective shield')}</td>
|
|
||||||
<td className='ri'>
|
|
||||||
<span>{formats.int(effectiveAbsoluteShield)}{units.MJ}</span>
|
|
||||||
</td>
|
|
||||||
<td className='ri'>
|
|
||||||
<span>{formats.int(effectiveExplosiveShield)}{units.MJ}</span>
|
|
||||||
</td>
|
|
||||||
<td className='ri'>
|
|
||||||
<span>{formats.int(effectiveKineticShield)}{units.MJ}</span>
|
|
||||||
</td>
|
|
||||||
<td className='ri'>
|
|
||||||
<span>{formats.int(effectiveThermalShield)}{units.MJ}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colSpan='5' className='summary'>{translate('shields will hold against opponent for')} {formats.time(damagetaken.tts)}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
<div className='group half'>
|
<div className='group half'>
|
||||||
<h2>{translate('shield sources')}</h2>
|
<h2>{translate('shield sources')}</h2>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
|||||||
import Measure from 'react-measure';
|
import Measure from 'react-measure';
|
||||||
import * as d3 from 'd3';
|
import * as d3 from 'd3';
|
||||||
|
|
||||||
const CORIOLIS_COLOURS = [ '#FF8C0D', '#1FB0FF', '#519032', '#D5420D' ];
|
const CORIOLIS_COLOURS = ['#FF8C0D', '#1FB0FF', '#519032', '#D5420D'];
|
||||||
const LABEL_COLOUR = '#FFFFFF';
|
const LABEL_COLOUR = '#FFFFFF';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,12 +28,15 @@ export default class PieChart extends Component {
|
|||||||
width: 100,
|
width: 100,
|
||||||
height: 100
|
height: 100
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a slice of the pie chart
|
* Generate a slice of the pie chart
|
||||||
|
* @param {Object} d the data for this slice
|
||||||
|
* @param {number} i the index of this slice
|
||||||
|
* @returns {Object} the SVG for the slice
|
||||||
*/
|
*/
|
||||||
sliceGenerator(d, i) {
|
sliceGenerator(d, i) {
|
||||||
const { width, height } = this.state.dimensions;
|
const { width, height } = this.state.dimensions;
|
||||||
@@ -49,24 +52,28 @@ export default class PieChart extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<g key={`group-${i}`}>
|
<g key={`group-${i}`}>
|
||||||
<path key={`arc-${i}`} d={this.arc(d)} style={{fill: this.colors[i]}} />
|
<path key={`arc-${i}`} d={this.arc(d)} style={{ fill: this.colors[i] }} />
|
||||||
<text key={`label-${i}`} transform={labelTranslate} stroke={LABEL_COLOUR} strokeWidth='1px' fill='None' textAnchor='middle'>{d.value}</text>
|
<text key={`label-${i}`} transform={labelTranslate} stroke={LABEL_COLOUR} strokeWidth='1px' fill='None' textAnchor='middle'>{d.value}</text>
|
||||||
<text key={`key-${i}`} transform={keyTranslate} style={{stroke: this.colors[i], strokeWidth:'1px', fill:'None'}} textAnchor='middle'>{d.data.label}</text>
|
<text key={`key-${i}`} transform={keyTranslate} style={{ stroke: this.colors[i], strokeWidth:'1px', fill:'None' }} textAnchor='middle'>{d.data.label}</text>
|
||||||
</g>
|
</g>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the component
|
||||||
|
* @returns {object} Markup
|
||||||
|
*/
|
||||||
render() {
|
render() {
|
||||||
const { width, height } = this.state.dimensions;
|
const { width, height } = this.state.dimensions;
|
||||||
const pie = this.pie(this.props.data),
|
const pie = this.pie(this.props.data),
|
||||||
translate = `translate(${width / 2}, ${width * 0.4})`;
|
translate = `translate(${width / 2}, ${width * 0.4})`;
|
||||||
|
|
||||||
this.arc.outerRadius(width * 0.4);
|
this.arc.outerRadius(width * 0.4);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Measure width='100%' whitelist={[ 'width', 'top' ]} onMeasure={(dimensions) => { this.setState({dimensions}) }}>
|
<Measure width='100%' whitelist={['width', 'top']} onMeasure={ (dimensions) => { this.setState({ dimensions }); }}>
|
||||||
<div width={width} height={width}>
|
<div width={width} height={width}>
|
||||||
<svg style={{stroke: 'None' }} width={width} height={width * 0.9}>
|
<svg style={{ stroke: 'None' }} width={width} height={width * 0.9}>
|
||||||
<g transform={translate}>
|
<g transform={translate}>
|
||||||
{pie.map((d, i) => this.sliceGenerator(d, i))}
|
{pie.map((d, i) => this.sliceGenerator(d, i))}
|
||||||
</g>
|
</g>
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export default class Pips extends TranslatedComponent {
|
|||||||
if (this.props.ship.canBoost()) {
|
if (this.props.ship.canBoost()) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this._toggleBoost();
|
this._toggleBoost();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 37: // Left arrow == increase SYS
|
case 37: // Left arrow == increase SYS
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -345,7 +345,7 @@ export default class Pips extends TranslatedComponent {
|
|||||||
<div id='pips'>
|
<div id='pips'>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
{ ship.canBoost() ?
|
{ ship.canBoost() ?
|
||||||
<tr>
|
<tr>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import React, { Component } from 'react';
|
|||||||
import Measure from 'react-measure';
|
import Measure from 'react-measure';
|
||||||
import * as d3 from 'd3';
|
import * as d3 from 'd3';
|
||||||
|
|
||||||
const CORIOLIS_COLOURS = [ '#FF8C0D', '#1FB0FF', '#519032', '#D5420D' ];
|
const CORIOLIS_COLOURS = ['#FF8C0D', '#1FB0FF', '#519032', '#D5420D'];
|
||||||
const LABEL_COLOUR = '#FFFFFF';
|
const LABEL_COLOUR = '#FFFFFF';
|
||||||
|
|
||||||
var margin = {top: 10, right: 0, bottom: 0, left: 55};
|
const margin = { top: 10, right: 0, bottom: 0, left: 55 };
|
||||||
|
|
||||||
const ASPECT = 1;
|
const ASPECT = 1;
|
||||||
|
|
||||||
@@ -36,10 +36,14 @@ export default class VerticalBarChart extends Component {
|
|||||||
width: 300,
|
width: 300,
|
||||||
height: 300
|
height: 300
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_renderGraph(props){
|
/**
|
||||||
|
* Render the graph
|
||||||
|
* @param {Object} props React Component properties
|
||||||
|
*/
|
||||||
|
_renderGraph(props) {
|
||||||
let { width, height } = this.state.dimensions;
|
let { width, height } = this.state.dimensions;
|
||||||
|
|
||||||
width = width - margin.left - margin.right,
|
width = width - margin.left - margin.right,
|
||||||
@@ -73,7 +77,7 @@ export default class VerticalBarChart extends Component {
|
|||||||
svg.append('g')
|
svg.append('g')
|
||||||
.attr('class', 'y axis')
|
.attr('class', 'y axis')
|
||||||
.call(this.yAxis)
|
.call(this.yAxis)
|
||||||
.attr('fill', CORIOLIS_COLOURS[0])
|
.attr('fill', CORIOLIS_COLOURS[0]);
|
||||||
|
|
||||||
svg.selectAll('rect.bar')
|
svg.selectAll('rect.bar')
|
||||||
.data(props.data)
|
.data(props.data)
|
||||||
@@ -99,8 +103,10 @@ export default class VerticalBarChart extends Component {
|
|||||||
.text(d => d.value);
|
.text(d => d.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the component
|
||||||
|
* @returns {object} Markup
|
||||||
|
*/
|
||||||
render() {
|
render() {
|
||||||
const { width } = this.state.dimensions;
|
const { width } = this.state.dimensions;
|
||||||
|
|
||||||
@@ -109,7 +115,7 @@ export default class VerticalBarChart extends Component {
|
|||||||
this._renderGraph(this.props);
|
this._renderGraph(this.props);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Measure width='100%' whitelist={[ 'width', 'top' ]} onMeasure={(dimensions) => { this.setState({dimensions}) }}>
|
<Measure width='100%' whitelist={['width', 'top']} onMeasure={ (dimensions) => { this.setState({ dimensions }); }}>
|
||||||
<div width={width} height={width * ASPECT}>
|
<div width={width} height={width * ASPECT}>
|
||||||
{ this.x ?
|
{ this.x ?
|
||||||
<svg ref={ref => this.svg = ref} width={width} height={width * ASPECT} transform={translate}>
|
<svg ref={ref => this.svg = ref} width={width} height={width * ASPECT} transform={translate}>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export const terms = {
|
|||||||
PHRASE_NO_SPECIAL: 'No experimental effect',
|
PHRASE_NO_SPECIAL: 'No experimental effect',
|
||||||
PHRASE_SHOPPING_LIST: 'Stations that sell this build',
|
PHRASE_SHOPPING_LIST: 'Stations that sell this build',
|
||||||
PHRASE_TOTAL_EFFECTIVE_SHIELD: 'Total amount of damage that can be taken from each damage type, if using all shield cells',
|
PHRASE_TOTAL_EFFECTIVE_SHIELD: 'Total amount of damage that can be taken from each damage type, if using all shield cells',
|
||||||
|
PHRASE_TIME_TO_LOSE_SHIELDS: 'Shields will hold for',
|
||||||
|
|
||||||
HELP_MODIFICATIONS_MENU: 'Click on a number to enter a new value, or drag along the bar for small changes',
|
HELP_MODIFICATIONS_MENU: 'Click on a number to enter a new value, or drag along the bar for small changes',
|
||||||
|
|
||||||
@@ -204,6 +205,21 @@ export const terms = {
|
|||||||
optmul_sg: 'Optimal strength',
|
optmul_sg: 'Optimal strength',
|
||||||
maxmul_sg: 'Minimum strength',
|
maxmul_sg: 'Minimum strength',
|
||||||
|
|
||||||
|
// Damage types
|
||||||
|
absolute: 'Absolute',
|
||||||
|
explosive: 'Explosive',
|
||||||
|
kinetic: 'Kinetia',
|
||||||
|
thermal: 'Thermal',
|
||||||
|
|
||||||
|
// Shield sources
|
||||||
|
generator: 'Generator',
|
||||||
|
boosters: 'Boosters',
|
||||||
|
cells: 'Cells',
|
||||||
|
|
||||||
|
// Armour sources
|
||||||
|
bulkheads: 'Bulkheads',
|
||||||
|
reinforcement: 'Reinforcement',
|
||||||
|
|
||||||
// Help text
|
// Help text
|
||||||
HELP_TEXT: `
|
HELP_TEXT: `
|
||||||
<h1>Introduction</h1>
|
<h1>Introduction</h1>
|
||||||
|
|||||||
@@ -1251,7 +1251,6 @@ export default class Ship {
|
|||||||
* @return {this} The ship instance (for chaining operations)
|
* @return {this} The ship instance (for chaining operations)
|
||||||
*/
|
*/
|
||||||
updateMovement() {
|
updateMovement() {
|
||||||
console.log('updateMovement()');
|
|
||||||
this.speeds = Calc.speed(this.unladenMass + this.fuelCapacity, this.speed, this.standard[1].m, this.pipSpeed);
|
this.speeds = Calc.speed(this.unladenMass + this.fuelCapacity, this.speed, this.standard[1].m, this.pipSpeed);
|
||||||
this.topSpeed = this.speeds[4];
|
this.topSpeed = this.speeds[4];
|
||||||
this.topBoost = this.canBoost() ? this.speeds[4] * this.boost / this.speed : 0;
|
this.topBoost = this.canBoost() ? this.speeds[4] * this.boost / this.speed : 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user