Merge branch 'develop'

This commit is contained in:
willyb321
2019-05-20 06:36:43 +10:00
19 changed files with 130 additions and 107 deletions

View File

@@ -1,7 +1,5 @@
import Persist from './stores/Persist'; import Persist from './stores/Persist';
import ReactGA from 'react-ga';
ReactGA.initialize('UA-55840909-18');
let standalone = undefined; let standalone = undefined;
/** /**
@@ -259,16 +257,6 @@ Route.prototype.match = function(path, params) {
* @param {string} path Path to track * @param {string} path Path to track
*/ */
function gaTrack(path) { function gaTrack(path) {
const match = path.match(/\/outfit\/(.*)(\?code=.*)/);
if (match) {
if (match[1]) {
ReactGA.ga('set', 'contentGroup1', match[1]);
}
if (match[2]) {
ReactGA.ga('set', 'contentGroup2', match[2]);
}
}
ReactGA.pageview(path);
const _paq = window._paq || []; const _paq = window._paq || [];
_paq.push(['trackPageView']); _paq.push(['trackPageView']);
} }

View File

@@ -126,7 +126,7 @@ export default class AvailableModulesMenu extends TranslatedComponent {
onSelect: PropTypes.func.isRequired, onSelect: PropTypes.func.isRequired,
diffDetails: PropTypes.func, diffDetails: PropTypes.func,
m: PropTypes.object, m: PropTypes.object,
shipMass: PropTypes.number, ship: PropTypes.object.isRequired,
warning: PropTypes.func, warning: PropTypes.func,
firstSlotId: PropTypes.string, firstSlotId: PropTypes.string,
lastSlotId: PropTypes.string, lastSlotId: PropTypes.string,
@@ -134,10 +134,6 @@ export default class AvailableModulesMenu extends TranslatedComponent {
slotDiv: PropTypes.object slotDiv: PropTypes.object
}; };
static defaultProps = {
shipMass: 0
};
/** /**
* Constructor * Constructor
* @param {Object} props React Component properties * @param {Object} props React Component properties
@@ -159,15 +155,15 @@ export default class AvailableModulesMenu extends TranslatedComponent {
*/ */
_initState(props, context) { _initState(props, context) {
let translate = context.language.translate; let translate = context.language.translate;
let { m, warning, shipMass, onSelect, modules, firstSlotId, lastSlotId } = props; let { m, warning, onSelect, modules, ship } = props;
let list, currentGroup; let list, currentGroup;
let buildGroup = this._buildGroup.bind( let buildGroup = this._buildGroup.bind(
this, this,
ship,
translate, translate,
m, m,
warning, warning,
shipMass - (m && m.mass ? m.mass : 0),
(m, event) => { (m, event) => {
this._hideDiff(event); this._hideDiff(event);
onSelect(m); onSelect(m);
@@ -255,18 +251,16 @@ export default class AvailableModulesMenu extends TranslatedComponent {
/** /**
* Generate React Components for Module Group * Generate React Components for Module Group
* @param {Ship} ship Ship the selection is for
* @param {Function} translate Translate function * @param {Function} translate Translate function
* @param {Object} mountedModule Mounted Module * @param {Object} mountedModule Mounted Module
* @param {Function} warningFunc Warning function * @param {Function} warningFunc Warning function
* @param {number} mass Mass
* @param {function} onSelect Select/Mount callback * @param {function} onSelect Select/Mount callback
* @param {string} grp Group name * @param {string} grp Group name
* @param {Array} modules Available modules * @param {Array} modules Available modules
* @param {string} firstSlotId id of first slot item
* @param {string} lastSlotId id of last slot item
* @return {React.Component} Available Module Group contents * @return {React.Component} Available Module Group contents
*/ */
_buildGroup(translate, mountedModule, warningFunc, mass, onSelect, grp, modules, firstSlotId, lastSlotId) { _buildGroup(ship, translate, mountedModule, warningFunc, onSelect, grp, modules) {
let prevClass = null, prevRating = null, prevName; let prevClass = null, prevRating = null, prevName;
let elems = []; let elems = [];
@@ -287,10 +281,11 @@ export default class AvailableModulesMenu extends TranslatedComponent {
prevName = m.name; prevName = m.name;
if (ModuleUtils.isShieldGenerator(m.grp)) { if (ModuleUtils.isShieldGenerator(m.grp)) {
// Shield generators care about maximum hull mass // Shield generators care about maximum hull mass
disabled = mass > m.maxmass; disabled = ship.hullMass > m.maxmass;
} else if (m.maxmass) { // If the mounted module is experimental as well, we can replace it so
// Thrusters care about total mass // the maximum does not apply
disabled = mass + m.mass > m.maxmass; } else if (m.experimental && (!mountedModule || !mountedModule.experimental)) {
disabled = 4 <= ship.hardpoints.filter(o => o.m && o.m.experimental).length;
} }
let active = mountedModule && mountedModule.id === m.id; let active = mountedModule && mountedModule.id === m.id;
let classes = cn(m.name ? 'lc' : 'c', { let classes = cn(m.name ? 'lc' : 'c', {

View File

@@ -104,10 +104,10 @@ export default class HardpointSlot extends Slot {
onMouseOut={tooltip.bind(null, null)}>{translate('shotdmg')}: {formats.round1(m.getDamage())}</div> : null} onMouseOut={tooltip.bind(null, null)}>{translate('shotdmg')}: {formats.round1(m.getDamage())}</div> : null}
{m.getEps() ? <div className={'l'} onMouseOver={termtip.bind(null, m.getClip() ? 'epsseps' : 'eps')} {m.getEps() ? <div className={'l'} onMouseOver={termtip.bind(null, m.getClip() ? 'epsseps' : 'eps')}
onMouseOut={tooltip.bind(null, null)}>{translate('EPS')}: {formats.round1(m.getEps())}{u.MW} {m.getClip() ? onMouseOut={tooltip.bind(null, null)}>{translate('EPS')}: {formats.round1(m.getEps())}{u.MW} {m.getClip() ?
<span>({formats.round1((m.getClip() * m.getEps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()))}{u.MW})</span> : null}</div> : null} <span>({formats.round1(m.getEps() / m.getDps() * m.getSDps())}{u.MW})</span> : null}</div> : null}
{m.getHps() ? <div className={'l'} onMouseOver={termtip.bind(null, m.getClip() ? 'hpsshps' : 'hps')} {m.getHps() ? <div className={'l'} onMouseOver={termtip.bind(null, m.getClip() ? 'hpsshps' : 'hps')}
onMouseOut={tooltip.bind(null, null)}>{translate('HPS')}: {formats.round1(m.getHps())} {m.getClip() ? onMouseOut={tooltip.bind(null, null)}>{translate('HPS')}: {formats.round1(m.getHps())} {m.getClip() ?
<span>({formats.round1((m.getClip() * m.getHps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()))})</span> : null}</div> : null} <span>({formats.round1(m.getHps() / m.getDps() * m.getSDps())})</span> : null}</div> : null}
{m.getDps() && m.getEps() ? <div className={'l'} onMouseOver={termtip.bind(null, 'dpe')} {m.getDps() && m.getEps() ? <div className={'l'} onMouseOver={termtip.bind(null, 'dpe')}
onMouseOut={tooltip.bind(null, null)}>{translate('DPE')}: {formats.f1(m.getDps() / m.getEps())}</div> : null} onMouseOut={tooltip.bind(null, null)}>{translate('DPE')}: {formats.f1(m.getDps() / m.getEps())}</div> : null}
{m.getRoF() ? <div className={'l'} onMouseOver={termtip.bind(null, 'rof')} {m.getRoF() ? <div className={'l'} onMouseOver={termtip.bind(null, 'rof')}

View File

@@ -157,10 +157,6 @@ export default class HardpointSlotSection extends SlotSection {
<ul> <ul>
<li className='lc' tabIndex='0' onClick={_fill.bind(this, 'nl', 'F')} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['nl-F'] = smRef}>{translate('nl')}</li> <li className='lc' tabIndex='0' onClick={_fill.bind(this, 'nl', 'F')} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['nl-F'] = smRef}>{translate('nl')}</li>
</ul> </ul>
<div className='select-group cap'>{translate('ggc')}</div>
<ul>
<li className='lc' tabIndex='0' onClick={_fill.bind(this, 'ggc', 'F')} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['ggc-F'] = smRef}>{translate('ggc')}</li>
</ul>
<div className='select-group cap'>{translate('rfl')}</div> <div className='select-group cap'>{translate('rfl')}</div>
<ul> <ul>
<li className='c' tabIndex='0' onClick={_fill.bind(this, 'rfl', 'F')} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['rfl-F'] = smRef}><MountFixed className='lg'/></li> <li className='c' tabIndex='0' onClick={_fill.bind(this, 'rfl', 'F')} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['rfl-F'] = smRef}><MountFixed className='lg'/></li>

View File

@@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
import TranslatedComponent from './TranslatedComponent'; import TranslatedComponent from './TranslatedComponent';
import cn from 'classnames'; import cn from 'classnames';
import NumberEditor from 'react-number-editor'; import NumberEditor from 'react-number-editor';
import { isValueBeneficial } from '../utils/BlueprintFunctions'; import { isChangeValueBeneficial } from '../utils/BlueprintFunctions';
import { Modifications } from 'coriolis-data/dist';
/** /**
* Modification * Modification
@@ -79,6 +80,7 @@ export default class Modification extends TranslatedComponent {
let { translate, formats, units } = this.context.language; let { translate, formats, units } = this.context.language;
let { m, name } = this.props; let { m, name } = this.props;
let modValue = m.getChange(name); let modValue = m.getChange(name);
let isOverwrite = Modifications.modifications[name].method === 'overwrite';
if (name === 'damagedist') { if (name === 'damagedist') {
// We don't show damage distribution // We don't show damage distribution
@@ -117,10 +119,10 @@ export default class Modification extends TranslatedComponent {
</td> </td>
<td style={{ textAlign: 'center' }} className={ <td style={{ textAlign: 'center' }} className={
modValue ? modValue ?
isValueBeneficial(name, modValue) ? 'secondary' : 'warning' : isChangeValueBeneficial(name, modValue) ? 'secondary' : 'warning' :
'' ''
}> }>
{formats.f2(modValue / 100) || 0}% {formats.f2(modValue / 100) || 0}{isOverwrite ? '' : '%'}
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -50,6 +50,7 @@ export default class ShipSummaryTable extends TranslatedComponent {
const speedTooltip = canThrust ? 'TT_SUMMARY_SPEED' : 'TT_SUMMARY_SPEED_NONFUNCTIONAL'; const speedTooltip = canThrust ? 'TT_SUMMARY_SPEED' : 'TT_SUMMARY_SPEED_NONFUNCTIONAL';
const canBoost = ship.canBoost(cargo, ship.fuelCapacity); const canBoost = ship.canBoost(cargo, ship.fuelCapacity);
const boostTooltip = canBoost ? 'TT_SUMMARY_BOOST' : canThrust ? 'TT_SUMMARY_BOOST_NONFUNCTIONAL' : 'TT_SUMMARY_SPEED_NONFUNCTIONAL'; const boostTooltip = canBoost ? 'TT_SUMMARY_BOOST' : canThrust ? 'TT_SUMMARY_BOOST_NONFUNCTIONAL' : 'TT_SUMMARY_SPEED_NONFUNCTIONAL';
const canJump = ship.getSlotStatus(ship.standard[2]) == 3;
const sgMetrics = Calc.shieldMetrics(ship, pips.sys); const sgMetrics = Calc.shieldMetrics(ship, pips.sys);
const shipBoost = canBoost ? Calc.calcBoost(ship) : 'No Boost'; const shipBoost = canBoost ? Calc.calcBoost(ship) : 'No Boost';
const restingHeat = Math.sqrt(((ship.standard[0].m.pgen * ship.standard[0].m.eff) / ship.heatCapacity) / 0.2); const restingHeat = Math.sqrt(((ship.standard[0].m.pgen * ship.standard[0].m.eff) / ship.heatCapacity) / 0.2);
@@ -71,7 +72,7 @@ export default class ShipSummaryTable extends TranslatedComponent {
<tr className='main'> <tr className='main'>
<th rowSpan={2} className={ cn({ 'bg-warning-disabled': !canThrust }) }>{translate('speed')}</th> <th rowSpan={2} className={ cn({ 'bg-warning-disabled': !canThrust }) }>{translate('speed')}</th>
<th rowSpan={2} className={ cn({ 'bg-warning-disabled': !canBoost }) }>{translate('boost')}</th> <th rowSpan={2} className={ cn({ 'bg-warning-disabled': !canBoost }) }>{translate('boost')}</th>
<th colSpan={5}>{translate('jump range')}</th> <th colSpan={5} className={ cn({ 'bg-warning-disabled': !canJump }) }>{translate('jump range')}</th>
<th rowSpan={2}>{translate('shield')}</th> <th rowSpan={2}>{translate('shield')}</th>
<th rowSpan={2}>{translate('integrity')}</th> <th rowSpan={2}>{translate('integrity')}</th>
<th rowSpan={2}>{translate('DPS')}</th> <th rowSpan={2}>{translate('DPS')}</th>
@@ -89,11 +90,11 @@ export default class ShipSummaryTable extends TranslatedComponent {
<th rowSpan={2}>{translate('resting heat (Beta)')}</th> <th rowSpan={2}>{translate('resting heat (Beta)')}</th>
</tr> </tr>
<tr> <tr>
<th className='lft'>{translate('max')}</th> <th className={ cn({ 'lft': true, 'bg-warning-disabled': !canJump }) }>{translate('max')}</th>
<th>{translate('unladen')}</th> <th className={ cn({ 'bg-warning-disabled': !canJump }) }>{translate('unladen')}</th>
<th>{translate('laden')}</th> <th className={ cn({ 'bg-warning-disabled': !canJump }) }>{translate('laden')}</th>
<th>{translate('total unladen')}</th> <th className={ cn({ 'bg-warning-disabled': !canJump }) }>{translate('total unladen')}</th>
<th>{translate('total laden')}</th> <th className={ cn({ 'bg-warning-disabled': !canJump }) }>{translate('total laden')}</th>
<th className='lft'>{translate('hull')}</th> <th className='lft'>{translate('hull')}</th>
<th>{translate('unladen')}</th> <th>{translate('unladen')}</th>
<th>{translate('laden')}</th> <th>{translate('laden')}</th>
@@ -103,11 +104,11 @@ export default class ShipSummaryTable extends TranslatedComponent {
<tr> <tr>
<td onMouseEnter={termtip.bind(null, speedTooltip, { cap: 0 })} onMouseLeave={hide}>{ canThrust ? <span>{int(ship.calcSpeed(4, ship.fuelCapacity, 0, false))}{u['m/s']}</span> : <span className='warning'>0 <Warning/></span> }</td> <td onMouseEnter={termtip.bind(null, speedTooltip, { cap: 0 })} onMouseLeave={hide}>{ canThrust ? <span>{int(ship.calcSpeed(4, ship.fuelCapacity, 0, false))}{u['m/s']}</span> : <span className='warning'>0 <Warning/></span> }</td>
<td onMouseEnter={termtip.bind(null, boostTooltip, { cap: 0 })} onMouseLeave={hide}>{ canBoost ? <span>{int(ship.calcSpeed(4, ship.fuelCapacity, 0, true))}{u['m/s']}</span> : <span className='warning'>0 <Warning/></span> }</td> <td onMouseEnter={termtip.bind(null, boostTooltip, { cap: 0 })} onMouseLeave={hide}>{ canBoost ? <span>{int(ship.calcSpeed(4, ship.fuelCapacity, 0, true))}{u['m/s']}</span> : <span className='warning'>0 <Warning/></span> }</td>
<td><span onMouseEnter={termtip.bind(null, 'TT_SUMMARY_MAX_SINGLE_JUMP', { cap: 0 })} onMouseLeave={hide}>{f2(Calc.jumpRange(ship.unladenMass + ship.standard[2].m.getMaxFuelPerJump(), ship.standard[2].m, ship.standard[2].m.getMaxFuelPerJump(), ship))}{u.LY}</span></td> <td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_MAX_SINGLE_JUMP', { cap: 0 })} onMouseLeave={hide}>{ canJump ? <span>{ f2(Calc.jumpRange(ship.unladenMass + ship.standard[2].m.getMaxFuelPerJump(), ship.standard[2].m, ship.standard[2].m.getMaxFuelPerJump(), ship))}{u.LY}</span> : <span className='warning'>0 <Warning/></span> }</td>
<td><span onMouseEnter={termtip.bind(null, 'TT_SUMMARY_UNLADEN_SINGLE_JUMP', { cap: 0 })} onMouseLeave={hide}>{f2(Calc.jumpRange(ship.unladenMass + ship.fuelCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY}</span></td> <td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_UNLADEN_SINGLE_JUMP', { cap: 0 })} onMouseLeave={hide}>{ canJump ? <span>{f2(Calc.jumpRange(ship.unladenMass + ship.fuelCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY}</span> : <span className='warning'>0 <Warning/></span> }</td>
<td><span onMouseEnter={termtip.bind(null, 'TT_SUMMARY_LADEN_SINGLE_JUMP', { cap: 0 })} onMouseLeave={hide}>{f2(Calc.jumpRange(ship.unladenMass + ship.fuelCapacity + ship.cargoCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY}</span></td> <td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_LADEN_SINGLE_JUMP', { cap: 0 })} onMouseLeave={hide}>{ canJump ? <span>{f2(Calc.jumpRange(ship.unladenMass + ship.fuelCapacity + ship.cargoCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY}</span> : <span className='warning'>0 <Warning/></span> }</td>
<td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_UNLADEN_TOTAL_JUMP', { cap: 0 })} onMouseLeave={hide}>{f2(Calc.totalJumpRange(ship.unladenMass + ship.fuelCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY}</td> <td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_UNLADEN_TOTAL_JUMP', { cap: 0 })} onMouseLeave={hide}>{ canJump ? <span>{f2(Calc.totalJumpRange(ship.unladenMass + ship.fuelCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY}</span> : <span className='warning'>0 <Warning/></span> }</td>
<td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_LADEN_TOTAL_JUMP', { cap: 0 })} onMouseLeave={hide}>{f2(Calc.totalJumpRange(ship.unladenMass + ship.fuelCapacity + ship.cargoCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY}</td> <td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_LADEN_TOTAL_JUMP', { cap: 0 })} onMouseLeave={hide}>{ canJump ? <span>{f2(Calc.totalJumpRange(ship.unladenMass + ship.fuelCapacity + ship.cargoCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY}</span> : <span className='warning'>0 <Warning/></span> }</td>
<td className={sgClassNames} onMouseEnter={termtip.bind(null, sgTooltip, { cap: 0 })} onMouseLeave={hide}>{int(ship.shield)}{u.MJ}</td> <td className={sgClassNames} onMouseEnter={termtip.bind(null, sgTooltip, { cap: 0 })} onMouseLeave={hide}>{int(ship.shield)}{u.MJ}</td>
<td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_INTEGRITY', { cap: 0 })} onMouseLeave={hide}>{int(ship.armour)}</td> <td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_INTEGRITY', { cap: 0 })} onMouseLeave={hide}>{int(ship.armour)}</td>
<td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_DPS', { cap: 0 })} onMouseLeave={hide}>{f1(ship.totalDps)}</td> <td onMouseEnter={termtip.bind(null, 'TT_SUMMARY_DPS', { cap: 0 })} onMouseLeave={hide}>{f1(ship.totalDps)}</td>

View File

@@ -127,8 +127,8 @@ export default class Slot extends TranslatedComponent {
menu = <AvailableModulesMenu menu = <AvailableModulesMenu
className={this._getClassNames()} className={this._getClassNames()}
modules={availableModules()} modules={availableModules()}
shipMass={ship.hullMass}
m={m} m={m}
ship={ship}
onSelect={onSelect} onSelect={onSelect}
warning={warning} warning={warning}
diffDetails={diffDetails.bind(ship, this.context.language)} diffDetails={diffDetails.bind(ship, this.context.language)}

View File

@@ -195,6 +195,15 @@ export default class SlotSection extends TranslatedComponent {
if (targetSlot && canMount(this.props.ship, targetSlot, m.grp, m.class)) { if (targetSlot && canMount(this.props.ship, targetSlot, m.grp, m.class)) {
const mCopy = m.clone(); const mCopy = m.clone();
this.props.ship.use(targetSlot, mCopy, false); this.props.ship.use(targetSlot, mCopy, false);
let experimentalNum = this.props.ship.hardpoints
.filter(s => s.m && s.m.experimental).length;
// Remove the module on the last slot if we now exceed the number of
// experimentals allowed
if (m.experimental && 4 < experimentalNum) {
this.props.ship.updateStats(originSlot, null, originSlot.m);
originSlot.m = null; // Empty the slot
originSlot.discountedCost = 0;
}
// Copy power info // Copy power info
targetSlot.enabled = originSlot.enabled; targetSlot.enabled = originSlot.enabled;
targetSlot.priority = originSlot.priority; targetSlot.priority = originSlot.priority;

View File

@@ -109,8 +109,8 @@ export default class StandardSlot extends TranslatedComponent {
menu = <AvailableModulesMenu menu = <AvailableModulesMenu
className='standard' className='standard'
modules={modules} modules={modules}
shipMass={ModuleUtils.isShieldGenerator(m.grp) ? ship.hullMass : ship.unladenMass}
m={m} m={m}
ship={ship}
onSelect={onSelect} onSelect={onSelect}
warning={warning} warning={warning}
diffDetails={diffDetails.bind(ship, this.context.language)} diffDetails={diffDetails.bind(ship, this.context.language)}

View File

@@ -366,7 +366,7 @@
"permalink": "分享", "permalink": "分享",
"URL": "链接", "URL": "链接",
"shortened": "短链接", "shortened": "短链接",
"fastest range": "最长距离", "farthest range": "最长距离",
"Sustained DPS": "持续DPS", "Sustained DPS": "持续DPS",
"build": "配置名", "build": "配置名",
"thrusters": "推进器", "thrusters": "推进器",

View File

@@ -59,7 +59,7 @@
"empty all": "vide tout", "empty all": "vide tout",
"Enter Name": "Entrer nom", "Enter Name": "Entrer nom",
"Explorer": "explorateur", "Explorer": "explorateur",
"fastest range": "gamme la plus rapide", "farthest range": "gamme la plus rapide",
"fuel": "carburant", "fuel": "carburant",
"fuel level": "niveau de carburant", "fuel level": "niveau de carburant",
"full tank": "Réservoir plein", "full tank": "Réservoir plein",

View File

@@ -299,7 +299,7 @@
"edit data": "Редактирование", "edit data": "Редактирование",
"empty all": "пусто все", "empty all": "пусто все",
"Enter Name": "Введите имя", "Enter Name": "Введите имя",
"fastest range": "быстрый диапазон", "farthest range": "быстрый диапазон",
"fuel level": "уровень топлива", "fuel level": "уровень топлива",
"full tank": "Полный бак", "full tank": "Полный бак",
"internal compartments": "внутренние отсеки", "internal compartments": "внутренние отсеки",

View File

@@ -15,7 +15,7 @@ export function jumpRange(mass, fsd, fuel, ship) {
let jumpAddition = 0; let jumpAddition = 0;
if (ship) { if (ship) {
for (const module of ship.internal) { for (const module of ship.internal) {
if (module && module.m && module.m.grp === 'gfsb') { if (module && module.m && module.m.grp === 'gfsb' && ship.getSlotStatus(module) == 3) {
jumpAddition += module.m.getJumpBoost(); jumpAddition += module.m.getJumpBoost();
} }
} }
@@ -1014,7 +1014,10 @@ export function timeToDrainWep(ship, wep) {
*/ */
export function timeToDeplete(amount, dps, eps, capacity, recharge) { export function timeToDeplete(amount, dps, eps, capacity, recharge) {
const drainPerSecond = eps - recharge; const drainPerSecond = eps - recharge;
if (drainPerSecond <= 0) { // If there is nothing to remove, we're don instantly
if (!amount) {
return 0;
} if (drainPerSecond <= 0) {
// Simple result // Simple result
return amount / dps; return amount / dps;
} else { } else {

View File

@@ -207,7 +207,7 @@ export const ShipFacets = [
i: 9 i: 9
}, },
{ // 10 { // 10
title: 'fastest range', title: 'farthest range',
props: ['unladenFastestRange', 'ladenFastestRange'], props: ['unladenFastestRange', 'ladenFastestRange'],
lbls: ['unladen', 'laden'], lbls: ['unladen', 'laden'],
unit: 'LY', unit: 'LY',

View File

@@ -59,14 +59,7 @@ export default class Module {
} else if (modification.method === 'overwrite') { } else if (modification.method === 'overwrite') {
result = modifierActions[name]; result = modifierActions[name];
} else { } else {
// rate of fire is special, as it's really burst interval. Handle that here result = (((1 + result / multiplier) * (1 + modifierActions[name])) - 1) * multiplier;
let mod = null;
if (name === 'rof') {
mod = 1 / (1 + modifierActions[name]) - 1;
} else {
mod = modifierActions[name];
}
result = (((1 + result / multiplier) * (1 + mod)) - 1) * multiplier;
} }
} }
} }
@@ -105,13 +98,6 @@ export default class Module {
} else if (modification.method === 'overwrite') { } else if (modification.method === 'overwrite') {
value = null; value = null;
} else { } else {
// rate of fire is special, as it's really burst interval. Handle that here
let mod = null;
if (name === 'rof') {
mod = 1 / (1 + modifierActions[name]) - 1;
} else {
mod = modifierActions[name];
}
value = ((value / 10000 + 1) / (1 + mod) - 1) * 10000; value = ((value / 10000 + 1) / (1 + mod) - 1) * 10000;
} }
} }
@@ -131,6 +117,13 @@ export default class Module {
* @return {Number} The value queried * @return {Number} The value queried
*/ */
get(name, modified = true) { get(name, modified = true) {
if (name == 'rof' && isNaN(this[name])) {
let fireint = this['fireint'];
if (!isNaN(fireint)) {
this['rof'] = 1 / fireint;
}
}
let val; let val;
if (modified) { if (modified) {
val = this._getModifiedValue(name); val = this._getModifiedValue(name);
@@ -166,14 +159,20 @@ export default class Module {
modValue = value - baseValue; modValue = value - baseValue;
} else if (name === 'shieldboost' || name === 'hullboost') { } else if (name === 'shieldboost' || name === 'hullboost') {
modValue = (1 + value) / (1 + baseValue) - 1; modValue = (1 + value) / (1 + baseValue) - 1;
} else if (name === 'rof') {
let burst = this.get('burst', true) || 1;
let burstInt = 1 / (this.get('burstrof', true) / 1);
let interval = burst / value;
let newFireint = (interval - (burst - 1) * burstInt);
modValue = newFireint / this['fireint'] - 1;
} else { // multiplicative } else { // multiplicative
modValue = baseValue == 0 ? 0 : value / baseValue - 1; modValue = baseValue == 0 ? 0 : value / baseValue - 1;
} }
if (modification.type === 'percentage') { if (modification.type === 'percentage') {
modValue = modValue * 10000; modValue = modValue * 10000;
} else if (modification.type === 'numeric' && name !== 'burst' && } else if (modification.type === 'numeric') {
name !== 'burstrof') {
modValue = modValue * 100; modValue = modValue * 100;
} }
@@ -191,7 +190,14 @@ export default class Module {
*/ */
getPretty(name, modified = true, places = 2) { getPretty(name, modified = true, places = 2) {
const formattingOptions = STATS_FORMATTING[name]; const formattingOptions = STATS_FORMATTING[name];
let val = this.get(name, modified) || 0; let val;
if (formattingOptions && formattingOptions.synthetic) {
val = (this[formattingOptions.synthetic]).call(this, modified);
} else {
val = this.get(name, modified);
}
val = val || 0;
if (formattingOptions && formattingOptions.format.startsWith('pct')) { if (formattingOptions && formattingOptions.format.startsWith('pct')) {
return 100 * val; return 100 * val;
} }
@@ -250,12 +256,17 @@ export default class Module {
} else if (name === 'shieldboost' || name === 'hullboost') { } else if (name === 'shieldboost' || name === 'hullboost') {
result = (1 + result) * (1 + modValue) - 1; result = (1 + result) * (1 + modValue) - 1;
} else { } else {
// Rate of fire modifiers are special as they actually are modifiers
// for fire interval. Translate them accordingly here:
if (name == 'rof') {
modValue = 1 / (1 + modValue) - 1;
}
result = result * (1 + modValue); result = result * (1 + modValue);
} }
} else if (name === 'burstrof') { } else if (name === 'burstrof' || name === 'burst') {
// Burst and burst rate of fire are special, as it can not exist but // Burst and burst rate of fire are special, as it can not exist but
// have a modification // have a modification
result = modValue / 100; result = modValue;
} }
} }
} }
@@ -277,11 +288,7 @@ export default class Module {
formatModifiedValue(name, language, unit, val) { formatModifiedValue(name, language, unit, val) {
const formattingOptions = STATS_FORMATTING[name]; const formattingOptions = STATS_FORMATTING[name];
if (val === undefined) { if (val === undefined) {
if (formattingOptions && formattingOptions.synthetic) { val = this.getPretty(name, true);
val = (this[formattingOptions.synthetic]).call(this, true);
} else {
val = this._getModifiedValue(name);
}
} }
val = val || 0; val = val || 0;
@@ -351,14 +358,18 @@ export default class Module {
if (formattingOptions && formattingOptions.change) { if (formattingOptions && formattingOptions.change) {
let changeFormatting = formattingOptions.change; let changeFormatting = formattingOptions.change;
let baseVal = this[name]; let baseVal = this[name] || 0;
let absVal = this._getModifiedValue(name); let absVal = this._getModifiedValue(name);
if (changeFormatting === 'additive') { if (changeFormatting === 'additive') {
val = absVal - baseVal; val = absVal - baseVal;
} else if (changeFormatting === 'multiplicative') { } else if (changeFormatting === 'multiplicative') {
val = absVal / baseVal - 1; val = absVal / baseVal - 1;
} }
val *= 10000; if (Modifications.modifications[name].method === 'overwrite') {
val *= 100;
} else {
val *= 10000;
}
} }
return val; return val;
} }
@@ -813,15 +824,21 @@ export default class Module {
*/ */
getSDps(modified = true) { getSDps(modified = true) {
let dps = this.getDps(modified); let dps = this.getDps(modified);
if (this.getClip(modified)) { let clipSize = this.getClip(modified);
let clipSize = this.getClip(modified); if (clipSize) {
// If auto-loader is applied, effective clip size will be nearly doubled // If auto-loader is applied, effective clip size will be nearly doubled
// as you get one reload for every two shots fired. // as you get one reload for every two shots fired.
if (this.blueprint && this.blueprint.special && this.blueprint.special.edname === 'special_auto_loader' && modified) { if (this.blueprint && this.blueprint.special && this.blueprint.special.edname === 'special_auto_loader' && modified) {
clipSize += clipSize - 1; clipSize += clipSize - 1;
} }
let timeToDeplete = clipSize / this.getRoF(modified);
return dps * timeToDeplete / (timeToDeplete + this.getReload(modified)); let burstSize = this.get('burst', modified) || 1;
let rof = this.getRoF(modified);
// rof averages burstfire + pause until next interval but for sustained
// rof we need to take another burst without pause into account
let burstOverhead = (burstSize - 1) / (this.get('burstrof', modified) || 1);
let srof = clipSize / ((clipSize - burstSize) / rof + burstOverhead + this.getReload(modified));
return dps * srof / rof;
} else { } else {
return dps; return dps;
} }

View File

@@ -26,8 +26,8 @@ export const STATS_FORMATTING = {
'ammo': { 'format': 'int', }, 'ammo': { 'format': 'int', },
'boot': { 'format': 'int', 'unit': 'secs' }, 'boot': { 'format': 'int', 'unit': 'secs' },
'brokenregen': { 'format': 'round1', 'unit': 'ps' }, 'brokenregen': { 'format': 'round1', 'unit': 'ps' },
'burst': { 'format': 'int' }, 'burst': { 'format': 'int', 'change': 'additive' },
'burstrof': { 'format': 'round1', 'unit': 'ps' }, 'burstrof': { 'format': 'round1', 'unit': 'ps', 'change': 'additive' },
'causres': { 'format': 'pct' }, 'causres': { 'format': 'pct' },
'clip': { 'format': 'int' }, 'clip': { 'format': 'int' },
'damage': { 'format': 'round' }, 'damage': { 'format': 'round' },
@@ -61,7 +61,7 @@ export const STATS_FORMATTING = {
'ranget': { 'format': 'f1', 'unit': 's' }, 'ranget': { 'format': 'f1', 'unit': 's' },
'regen': { 'format': 'round1', 'unit': 'ps' }, 'regen': { 'format': 'round1', 'unit': 'ps' },
'reload': { 'format': 'int', 'unit': 's' }, 'reload': { 'format': 'int', 'unit': 's' },
'rof': { 'format': 'round1', 'unit': 'ps' }, 'rof': { 'format': 'round1', 'unit': 'ps', 'synthetic': 'getRoF', 'higherbetter': true },
'angle': { 'format': 'round1', 'unit': 'ang' }, 'angle': { 'format': 'round1', 'unit': 'ang' },
'scanrate': { 'format': 'int' }, 'scanrate': { 'format': 'int' },
'scantime': { 'format': 'round1', 'unit': 's' }, 'scantime': { 'format': 'round1', 'unit': 's' },

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { Modifications } from 'coriolis-data/dist'; import { Modifications } from 'coriolis-data/dist';
import { STATS_FORMATTING } from '../shipyard/StatsFormatting';
/** /**
* Generate a tooltip with details of a blueprint's specials * Generate a tooltip with details of a blueprint's specials
@@ -280,6 +281,25 @@ export function isValueBeneficial(feature, value) {
} }
} }
/**
* Is the change as shown beneficial?
* @param {string} feature The name of the feature
* @param {number} value The value of the feature as percentage change
* @returns True if the value is beneficial
*/
export function isChangeValueBeneficial(feature, value) {
let changeHigherBetter = STATS_FORMATTING[feature].higherbetter;
if (changeHigherBetter === undefined) {
return isValueBeneficial(feature, value);
}
if (changeHigherBetter) {
return value > 0;
} else {
return value < 0;
}
}
/** /**
* Get a blueprint with a given name and an optional module * Get a blueprint with a given name and an optional module
* @param {string} name The name of the blueprint * @param {string} name The name of the blueprint

View File

@@ -32,15 +32,6 @@
window.CORIOLIS_DATE = '<%- htmlWebpackPlugin.options.date.toISOString().slice(0, 10) %>'; window.CORIOLIS_DATE = '<%- htmlWebpackPlugin.options.date.toISOString().slice(0, 10) %>';
window.BUGSNAG_VERSION = '<%- htmlWebpackPlugin.options.version + '-' + htmlWebpackPlugin.options.date.toISOString() %>'; window.BUGSNAG_VERSION = '<%- htmlWebpackPlugin.options.version + '-' + htmlWebpackPlugin.options.date.toISOString() %>';
</script> </script>
<% if (htmlWebpackPlugin.options.uaTracking) { %>
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', '<%- htmlWebpackPlugin.options.uaTracking %>', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<% } %>
<!-- Matomo --> <!-- Matomo -->
<script type="text/javascript"> <script type="text/javascript">
var _paq = window._paq || []; var _paq = window._paq || [];

View File

@@ -7,8 +7,8 @@ if (workbox) {
workbox.routing.registerNavigationRoute('/index.html'); workbox.routing.registerNavigationRoute('/index.html');
workbox.routing.registerRoute( workbox.routing.registerRoute(
new RegExp('/(.*?)'), /\.(?:png|jpg|jpeg|svg|gif)$/,
workbox.strategies.staleWhileRevalidate({ new workbox.strategies.CacheFirst({
plugins: [ plugins: [
new workbox.cacheableResponse.Plugin({ new workbox.cacheableResponse.Plugin({
statuses: [0, 200] statuses: [0, 200]
@@ -17,9 +17,16 @@ if (workbox) {
}) })
); );
workbox.routing.registerRoute(
/\.(?:js|css)$/,
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'static-resources',
})
);
workbox.routing.registerRoute( workbox.routing.registerRoute(
new RegExp('https://fonts.(?:googleapis|gstatic).com/(.*)'), new RegExp('https://fonts.(?:googleapis|gstatic).com/(.*)'),
workbox.strategies.cacheFirst({ new workbox.strategies.CacheFirst({
cacheName: 'google-fonts', cacheName: 'google-fonts',
plugins: [ plugins: [
new workbox.expiration.Plugin({ new workbox.expiration.Plugin({
@@ -31,12 +38,6 @@ if (workbox) {
] ]
}) })
); );
try {
workbox.googleAnalytics.initialize();
} catch (e) {
console.log('Probably an ad-blocker');
}
} else { } else {
console.log('Boo! Workbox didn\'t load 😬'); console.log('Boo! Workbox didn\'t load 😬');
} }