Skip to content

Commit

Permalink
Merge branch 'release/2.2.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdrmcdonald committed Jan 25, 2017
2 parents 99c0bfc + 89f2273 commit c02f674
Show file tree
Hide file tree
Showing 19 changed files with 491 additions and 64 deletions.
18 changes: 18 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
#2.2.11
* Add help system and initial help file
* Make absolute damage visible
* Add 'average' roll for blueprints
* Update spacing for movement summary to make it more readable
* Provide damage dealt statistics for both shields and hull
* Damage dealt panel only shows enabled weapons
* Add engagement range to damage received panel
* Handle burst rate of fire as an absolute number rather than a perentage modification
* Ensure that clip values are always rounded up
* Ensure that focused weapon mod uses range modifier to increase falloff as well
* Use coriolis-data 2.2.11:
* Remove non-existent chaff launcher capacity blueprint grades
* Fix incorrect values for charge enhanced power distributor
* Remove incorrect AFMU blueprints
* Correct fragment cannon Double Shot blueprint information
* Correct Focused weapon blueprint information

#2.2.10
* Fix detailed export of module reinforcement packages
* Use damagedist for exact breakdown of weapons that have more than one type of damage
Expand Down
5 changes: 4 additions & 1 deletion __tests__/fixtures/anaconda-test-detailed-export-v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"priority": 1,
"modifications": {
"pgen": 1000
}
}
},
"thrusters": {
"class": 6,
Expand Down Expand Up @@ -275,6 +275,9 @@
"totalExplDpe": 0,
"totalExplDps": 0,
"totalExplSDps": 0,
"totalAbsDpe": 3.57,
"totalAbsDps": 18.78,
"totalAbsSDps": 14.45,
"totalHps": 33.62,
"totalKinDpe": 117.48,
"totalKinDps": 24.94,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coriolis_shipyard",
"version": "2.2.10",
"version": "2.2.11",
"repository": {
"type": "git",
"url": "https://github.com/EDCD/coriolis"
Expand Down
18 changes: 16 additions & 2 deletions src/app/Coriolis.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import Persist from './stores/Persist';

import Header from './components/Header';
import Tooltip from './components/Tooltip';
import ModalExport from './components/ModalExport';
import ModalHelp from './components/ModalHelp';
import ModalImport from './components/ModalImport';
import ModalPermalink from './components/ModalPermalink';
import * as CompanionApiUtils from './utils/CompanionApiUtils';
import { outfitURL } from './utils/UrlGenerators';

Expand Down Expand Up @@ -159,14 +162,25 @@ export default class Coriolis extends React.Component {
this._hideModal();
this._closeMenu();
break;
case 72: // 'h'
if (e.ctrlKey || e.metaKey) { // CTRL/CMD + h
e.preventDefault();
this._showModal(<ModalHelp />);
}
break;
case 73: // 'i'
if (e.ctrlKey || e.metaKey) { // CTRL/CMD + i
e.preventDefault();
this._showModal(<ModalImport />);
}
break;
case 101010: // 's'
if (e.ctrlKey || e.metaKey) { // CTRL/CMD + i
case 76: // 'l'
if (e.ctrlKey || e.metaKey) { // CTRL/CMD + l
e.preventDefault();
this._showModal(<ModalPermalink url={window.location.href}/>);
}
case 83: // 's'
if (e.ctrlKey || e.metaKey) { // CTRL/CMD + s
e.preventDefault();
this.emitter.emit('command', 'save');
}
Expand Down
82 changes: 55 additions & 27 deletions src/app/components/DamageDealt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,17 @@ export default class DamageDealt extends TranslatedComponent {

// Track totals
let totals = {};
totals.effectiveness = 0;
totals.effectiveDps = 0;
totals.effectiveSDps = 0;
totals.effectivenessShields = 0;
totals.effectiveDpsShields = 0;
totals.effectiveSDpsShields = 0;
totals.effectivenessHull = 0;
totals.effectiveDpsHull = 0;
totals.effectiveSDpsHull = 0;
let totalDps = 0;

let weapons = [];
for (let i = 0; i < ship.hardpoints.length; i++) {
if (ship.hardpoints[i].m) {
if (ship.hardpoints[i].m && ship.hardpoints[i].enabled) {
const m = ship.hardpoints[i].m;
if (m.getDamage() && m.grp !== 'po') {
let dropoff = 1;
Expand All @@ -134,24 +137,33 @@ export default class DamageDealt extends TranslatedComponent {
}
}
const classRating = `${m.class}${m.rating}${m.missile ? '/' + m.missile : ''}`;
const effectiveness = (m.getPiercing() >= against.properties.hardness ? 1 : m.getPiercing() / against.properties.hardness) * 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;
totals.effectiveDps += effectiveDps;
totals.effectiveSDps += effectiveSDps;
const effectivenessShields = dropoff;
const effectiveDpsShields = m.getDps() * effectivenessShields * dropoff;
const effectiveSDpsShields = (m.getClip() ? (m.getClip() * m.getDps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()) * effectivenessShields : effectiveDpsShields) * dropoff;
const effectivenessHull = (m.getPiercing() >= against.properties.hardness ? 1 : m.getPiercing() / against.properties.hardness) * dropoff;
const effectiveDpsHull = m.getDps() * effectivenessHull * dropoff;
const effectiveSDpsHull = (m.getClip() ? (m.getClip() * m.getDps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()) * effectivenessHull : effectiveDpsHull) * dropoff;
totals.effectiveDpsShields += effectiveDpsShields;
totals.effectiveSDpsShields += effectiveSDpsShields;
totals.effectiveDpsHull += effectiveDpsHull;
totals.effectiveSDpsHull += effectiveSDpsHull;
totalDps += m.getDps();

weapons.push({ id: i,
mount: m.mount,
name: m.name || m.grp,
classRating,
effectiveDps,
effectiveSDps,
effectiveness });
effectiveDpsShields,
effectiveSDpsShields,
effectivenessShields,
effectiveDpsHull,
effectiveSDpsHull,
effectivenessHull });
}
}
}
totals.effectiveness = totals.effectiveDps / totalDps;
totals.effectivenessShields = totalDps == 0 ? 0 : totals.effectiveDpsShields / totalDps;
totals.effectivenessHull = totalDps == 0 ? 0 : totals.effectiveDpsHull / totalDps;

return { weapons, totals };
}
Expand All @@ -169,7 +181,7 @@ export default class DamageDealt extends TranslatedComponent {
*/
_onShipChange(s) {
const against = Ships[s];
const data = this._calcWeapons(this.props.ship, against);
const data = this._calcWeapons(this.props.ship, against, this.state.range * this.state.maxRange);
this.setState({ against, weapons: data.weapons, totals: data.totals });
}

Expand Down Expand Up @@ -201,9 +213,12 @@ export default class DamageDealt extends TranslatedComponent {

switch (predicate) {
case 'n': comp = comp(null, desc); break;
case 'edps': comp = comp((a, b) => a.effectiveDps - b.effectiveDps, desc); break;
case 'esdps': comp = comp((a, b) => a.effectiveSDps - b.effectiveSDps, desc); break;
case 'e': comp = comp((a, b) => a.effectiveness - b.effectiveness, desc); break;
case 'edpss': comp = comp((a, b) => a.effectiveDpsShields - b.effectiveDpsShields, desc); break;
case 'esdpss': comp = comp((a, b) => a.effectiveSDpsShields - b.effectiveSDpsShields, desc); break;
case 'es': comp = comp((a, b) => a.effectivenessShields - b.effectivenessShields, desc); break;
case 'edpsh': comp = comp((a, b) => a.effectiveDpsHull - b.effectiveDpsHull, desc); break;
case 'esdpsh': comp = comp((a, b) => a.effectiveSDpsHull - b.effectiveSDpsHull, desc); break;
case 'eh': comp = comp((a, b) => a.effectivenessHull - b.effectivenessHull, desc); break;
}

this.state.weapons.sort(comp);
Expand Down Expand Up @@ -232,9 +247,12 @@ export default class DamageDealt extends TranslatedComponent {
{weapon.mount == 'T' ? <span onMouseOver={termtip.bind(null, 'turreted')} onMouseOut={tooltip.bind(null, null)}><MountTurret /></span> : null}
{weapon.classRating} {translate(weapon.name)}
</td>
<td className='ri'>{formats.round1(weapon.effectiveDps)}</td>
<td className='ri'>{formats.round1(weapon.effectiveSDps)}</td>
<td className='ri'>{formats.pct(weapon.effectiveness)}</td>
<td className='ri'>{formats.round1(weapon.effectiveDpsShields)}</td>
<td className='ri'>{formats.round1(weapon.effectiveSDpsShields)}</td>
<td className='ri'>{formats.pct(weapon.effectivenessShields)}</td>
<td className='ri'>{formats.round1(weapon.effectiveDpsHull)}</td>
<td className='ri'>{formats.round1(weapon.effectiveSDpsHull)}</td>
<td className='ri'>{formats.pct(weapon.effectivenessHull)}</td>
</tr>);
}
}
Expand Down Expand Up @@ -271,10 +289,17 @@ export default class DamageDealt extends TranslatedComponent {
<table className='summary' style={{ width: '100%' }}>
<thead>
<tr className='main'>
<td className='sortable' onClick={sortOrder.bind(this, 'n')}>{translate('weapon')}</td>
<td className='sortable' onClick={sortOrder.bind(this, 'edps')}>{translate('effective dps')}</td>
<td className='sortable' onClick={sortOrder.bind(this, 'esdps')}>{translate('effective sdps')}</td>
<td className='sortable' onClick={sortOrder.bind(this, 'e')}>{translate('effectiveness')}</td>
<th rowSpan='2' className='sortable' onClick={sortOrder.bind(this, 'n')}>{translate('weapon')}</th>
<th colSpan='3'>{translate('shields')}</th>
<th colSpan='3'>{translate('armour')}</th>
</tr>
<tr>
<th className='lft sortable' onClick={sortOrder.bind(this, 'edpss')}>{translate('effective dps')}</th>
<th className='sortable' onClick={sortOrder.bind(this, 'esdpss')}>{translate('effective sdps')}</th>
<th className='sortable' onClick={sortOrder.bind(this, 'es')}>{translate('effectiveness')}</th>
<th className='lft sortable' onClick={sortOrder.bind(this, 'edpsh')}>{translate('effective dps')}</th>
<th className='sortable' onClick={sortOrder.bind(this, 'esdpsh')}>{translate('effective sdps')}</th>
<th className='sortable' onClick={sortOrder.bind(this, 'eh')}>{translate('effectiveness')}</th>
</tr>
</thead>
<tbody>
Expand All @@ -283,9 +308,12 @@ export default class DamageDealt extends TranslatedComponent {
<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>
<td className='ri'><i>{formats.round1(totals.effectiveDpsShields)}</i></td>
<td className='ri'><i>{formats.round1(totals.effectiveSDpsShields)}</i></td>
<td className='ri'><i>{formats.pct(totals.effectivenessShields)}</i></td>
<td className='ri'><i>{formats.round1(totals.effectiveDpsHull)}</i></td>
<td className='ri'><i>{formats.round1(totals.effectiveSDpsHull)}</i></td>
<td className='ri'><i>{formats.pct(totals.effectivenessHull)}</i></td>
</tr>
</tfoot>
</table>
Expand Down
75 changes: 64 additions & 11 deletions src/app/components/DamageReceived.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Modules } from 'coriolis-data/dist';
import { nameComparator } from '../utils/SlotFunctions';
import { CollapseSection, ExpandSection, MountFixed, MountGimballed, MountTurret } from './SvgIcons';
import Module from '../shipyard/Module';
import Slider from '../components/Slider';

/**
* Generates an internationalization friendly weapon comparator that will
Expand Down Expand Up @@ -62,15 +63,17 @@ export default class DamageReceived extends TranslatedComponent {
this.state = {
predicate: 'n',
desc: true,
expanded: false
expanded: false,
range: 0.1667,
maxRange: 6000
};
}

/**
* Set the initial weapons state
*/
componentWillMount() {
this.setState({ weapons: this._calcWeapons(this.props.ship) });
this.setState({ weapons: this._calcWeapons(this.props.ship, this.state.range * this.state.maxRange) });
}

/**
Expand All @@ -80,27 +83,47 @@ export default class DamageReceived extends TranslatedComponent {
* @return {boolean} Returns true if the component should be rerendered
*/
componentWillReceiveProps(nextProps, nextContext) {
this.setState({ weapons: this._calcWeapons(nextProps.ship) });
if (nextProps.code != this.props.code) {
this.setState({ weapons: this._calcWeapons(nextProps.ship, this.state.range * this.state.maxRange) });
}
return true;
}

/**
* Calculate the damage received by a ship
* @param {Object} ship The ship which will receive the damage
* @param {Object} range The engagement range
* @return {boolean} Returns the per-weapon damage
*/
_calcWeapons(ship) {
let weapons = [];
_calcWeapons(ship, range) {
// Tidy up the range so that it's to 4 decimal places
range = Math.round(10000 * range) / 10000;

let weapons = [];
for (let grp in Modules.hardpoints) {
if (Modules.hardpoints[grp][0].damage && Modules.hardpoints[grp][0].damagedist) {
for (let mId in Modules.hardpoints[grp]) {
const m = new Module(Modules.hardpoints[grp][mId]);
let dropoff = 1;
if (m.getFalloff()) {
// Calculate the dropoff % due to range
if (range > m.getRange()) {
// Weapon is out of range
dropoff = 0;
} else {
const falloff = m.getFalloff();
if (range > falloff) {
const dropoffRange = m.getRange() - falloff;
// Assuming straight-line falloff
dropoff = 1 - (range - falloff) / dropoffRange;
}
}
}
const classRating = `${m.class}${m.rating}${m.missile ? '/' + m.missile : ''}`;

// Base DPS
const baseDps = m.getDps();
const baseSDps = m.getClip() ? (m.getClip() * baseDps / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()) : baseDps;
const baseDps = m.getDps() * dropoff;
const baseSDps = m.getClip() ? ((m.getClip() * baseDps / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload())) * dropoff : baseDps;

// Effective DPS taking in to account shield resistance
let effectivenessShields = 0;
Expand All @@ -116,6 +139,7 @@ export default class DamageReceived extends TranslatedComponent {
if (m.getDamageDist().A) {
effectivenessShields += m.getDamageDist().A;
}
effectivenessShields *= dropoff;
const effectiveDpsShields = baseDps * effectivenessShields;
const effectiveSDpsShields = baseSDps * effectivenessShields;

Expand All @@ -133,7 +157,7 @@ export default class DamageReceived extends TranslatedComponent {
if (m.getDamageDist().A) {
effectivenessHull += m.getDamageDist().A;
}
effectivenessHull *= Math.min(m.getPiercing() / ship.hardness, 1);
effectivenessHull *= Math.min(m.getPiercing() / ship.hardness, 1) * dropoff;
const effectiveDpsHull = baseDps * effectivenessHull;
const effectiveSDpsHull = baseSDps * effectivenessHull;

Expand Down Expand Up @@ -232,14 +256,22 @@ export default class DamageReceived extends TranslatedComponent {
return rows;
}

/**
* Update current range
* @param {number} range Range 0-1
*/
_rangeChange(range) {
this.setState({ range, weapons: this._calcWeapons(this.props.ship, this.state.range * this.state.maxRange) });
}

/**
* Render damage received
* @return {React.Component} contents
*/
render() {
const { language, tooltip, termtip } = this.context;
const { formats, translate } = language;
const { expanded } = this.state;
const { language, onWindowResize, sizeRatio, tooltip, termtip } = this.context;
const { formats, translate, units } = language;
const { expanded, maxRange, range } = this.state;

const sortOrder = this._sortOrder;
const onCollapseExpand = this._onCollapseExpand;
Expand Down Expand Up @@ -267,6 +299,27 @@ export default class DamageReceived extends TranslatedComponent {
<tbody>
{this._renderRows(translate, formats)}
</tbody>
</table>
<table style={{ width: '80%', lineHeight: '1em', backgroundColor: 'transparent', margin: 'auto' }}>
<tbody >
<tr>
<td style={{ verticalAlign: 'top', padding: 0, width: '2.5em' }} onMouseEnter={termtip.bind(null, 'PHRASE_ENGAGEMENT_RANGE')} onMouseLeave={tooltip.bind(null, null)}>{translate('engagement range')}</td>
<td>
<Slider
axis={true}
onChange={this._rangeChange.bind(this)}
axisUnit={translate('m')}
percent={range}
max={maxRange}
scale={sizeRatio}
onResize={onWindowResize}
/>
</td>
<td className='primary' style={{ width: '10em', verticalAlign: 'top', fontSize: '0.9em', textAlign: 'left' }}>
{formats.f2(range * maxRange / 1000)}{units.km}
</td>
</tr>
</tbody>
</table></span> : null }
</span>
);
Expand Down
Loading

0 comments on commit c02f674

Please sign in to comment.