From 841e6c3348c92d29d76012e7f986c2da81ad1fba Mon Sep 17 00:00:00 2001 From: willyb321 Date: Fri, 30 Nov 2018 06:37:09 +1100 Subject: [PATCH] More dw2 work, update roles etc --- src/app/components/StandardSlotSection.jsx | 67 ++++----- src/app/shipyard/ShipRoles.js | 152 +++++++++++---------- 2 files changed, 114 insertions(+), 105 deletions(-) diff --git a/src/app/components/StandardSlotSection.jsx b/src/app/components/StandardSlotSection.jsx index 9d32a97a..ddd27905 100644 --- a/src/app/components/StandardSlotSection.jsx +++ b/src/app/components/StandardSlotSection.jsx @@ -86,15 +86,12 @@ export default class StandardSlotSection extends SlotSection { /** * DW2 Build - * @param tier - * @param engineeringLevel - * @param role */ _dw2() { this.selectedRefId = 'dw2'; this.setState({ showDW2: false }); ShipRoles.dw2Build(this.props.ship, this.state.DW2Tier, this.state.DW2Eng, this.state.DW2Role, this.state.DW2Gfsb, this.state.DW2Gpp, this.state.DW2Fighter); - this.props.ship.updateModificationsString() + this.props.ship.updateModificationsString(); this.props.onChange(); this.props.onCargoChange(this.props.ship.cargoCapacity); this.props.onFuelChange(this.props.ship.fuelCapacity); @@ -108,16 +105,16 @@ export default class StandardSlotSection extends SlotSection {
{translate('Engineering Level')}
@@ -130,7 +127,7 @@ export default class StandardSlotSection extends SlotSection { >{translate('Only Felicity Farseer and Elvira Martuuk')}
  • this.setState({ DW2Eng: 3 })} onKeyDown={this._keyDown} - >{translate('All exploration related engineers')}
  • + >{translate('All exploration engineers')}
    {translate('Role')}
    @@ -138,43 +135,50 @@ export default class StandardSlotSection extends SlotSection {
  • this.setState({ DW2Role: 'exploration' })} onKeyDown={this._keyDown} - >{translate('Exploration')}
  • + >{translate('Space exploration')}
  • this.setState({ DW2Role: 'surface' })} onKeyDown={this._keyDown} >{translate('Surface exploration')}
  • -
  • this.setState({ DW2Role: 'fullmining' })} +
  • this.setState({ DW2Role: 'materialProspector' })} + onKeyDown={this._keyDown} + >{translate('Material prospector')}
  • +
  • this.setState({ DW2Role: 'propectorMining' })} + onKeyDown={this._keyDown} + >{translate('Prospector/Sapper Miner')}
  • +
  • this.setState({ DW2Role: 'bigRigMining' })} onKeyDown={this._keyDown} >{translate('Big Rig, full mining')}
  • -
  • this.setState({ DW2Role: 'prospector' })} - onKeyDown={this._keyDown} - >{translate('Saper / Prospector mining')}
  • -
  • this.setState({ DW2Role: 'rat' })} onKeyDown={this._keyDown} - >{translate('Fuel rat')}
  • -
  • this.setState({ DW2Role: 'repair' })} onKeyDown={this._keyDown} - >{translate('Repair rat')}
  • +
  • this.setState({ DW2Role: 'fuelRat' })} onKeyDown={this._keyDown} + >{translate('Fuel Rat')}
  • +
  • this.setState({ DW2Role: 'mechanic' })} onKeyDown={this._keyDown} + >{translate('Mechanic')}
  • +
  • this.setState({ DW2Role: 'trucker' })} onKeyDown={this._keyDown} + >{translate('Trucker')}


  • @@ -293,7 +297,6 @@ export default class StandardSlotSection extends SlotSection { warning={m => m instanceof Module ? m.getMaxMass() < (ship.unladenMass + cargo + fuel - st[1].m.mass + m.mass) : m.maxmass < (ship.unladenMass + cargo + fuel - st[1].m.mass + m.mass)} />; - slots[3] = e.fuel) - .filter(e => e.fuel >= fuelNeeded) - ship.use(ship.standard[6], fuelTank[0]) + .filter(e => e.fuel >= fuelNeeded); + ship.use(ship.standard[6], fuelTank[0]); ship.useBulkhead(0, false); if (engineeringLevel === 2) { const bp = getBlueprint('FSD_LongRange', ship.standard[2]); - bp.grade = 5 - bp.special = Modifications.specials['special_fsd_heavy'] + bp.grade = 5; + bp.special = Modifications.specials['special_fsd_heavy']; ship.standard[2].m.blueprint = bp; setPercent(ship, ship.standard[2].m, 100); // Sensors G3 LW const sBP = getBlueprint('Sensor_Sensor_LightWeight', ship.standard[5]); - sBP.grade = 3 + sBP.grade = 3; ship.standard[5].m.blueprint = sBP; setPercent(ship, ship.standard[5].m, 100); } else if (engineeringLevel === 3) { // Armour G5 HD + Deep Plating const armourBP = getBlueprint('Armour_HeavyDuty', ship.bulkheads); - armourBP.grade = 5 - armourBP.special = Modifications.specials['special_armour_chunky'] + armourBP.grade = 5; + armourBP.special = Modifications.specials['special_armour_chunky']; ship.bulkheads.m.blueprint = armourBP; setPercent(ship, ship.bulkheads.m, 100); // FSD G5 IR + Mass Manager const fsdBP = getBlueprint('FSD_LongRange', ship.standard[2]); - fsdBP.grade = 5 - fsdBP.special = Modifications.specials['special_fsd_heavy'] + fsdBP.grade = 5; + fsdBP.special = Modifications.specials['special_fsd_heavy']; ship.standard[2].m.blueprint = fsdBP; setPercent(ship, ship.standard[2].m, 100); // LS G4 LW const lsBP = getBlueprint('LifeSupport_LightWeight', ship.standard[3]); - lsBP.grade = 4 + lsBP.grade = 4; ship.standard[3].m.blueprint = lsBP; setPercent(ship, ship.standard[3].m, 100); // Sensors G5 LW const sBP = getBlueprint('Sensor_Sensor_LightWeight', ship.standard[5]); - sBP.grade = 5 + sBP.grade = 5; ship.standard[5].m.blueprint = sBP; setPercent(ship, ship.standard[5].m, 100); } @@ -117,10 +121,10 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) } else if (fsd.class === 2 && fsd.rating === 'A') { let fs = ModuleUtils.findInternal('fs', 2, 'A'); let slot = ship.internal.filter(a => a.maxClass >= 2).filter(a => a.maxClass >= fs.class) - .sort((a,b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) [0]; if (slot.m) { - fs = ModuleUtils.findInternal('fs', 1, 'A'); + fs = ModuleUtils.findInternal('fs', 1, 'A'); slot = ship.internal.filter(a => a.maxClass === 1)[0]; ship.use(slot, fs); } else { @@ -129,10 +133,10 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) } else if (fsd.class === 3 && fsd.rating === 'A') { let fs = ModuleUtils.findInternal('fs', 3, 'B'); let slot = ship.internal.filter(a => a.maxClass >= 3).filter(a => a.maxClass >= fs.class) - .sort((a,b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) [0]; if (slot.m) { - fs = ModuleUtils.findInternal('fs', 2, 'A'); + fs = ModuleUtils.findInternal('fs', 2, 'A'); slot = ship.internal.filter(a => a.maxClass === 2)[0]; ship.use(slot, fs); } else { @@ -141,10 +145,10 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) } else if (fsd.class === 4 && fsd.rating === 'A') { let fs = ModuleUtils.findInternal('fs', 4, 'b'); let slot = ship.internal.filter(a => a.maxClass >= 4).filter(a => a.maxClass >= fs.class) - .sort((a,b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) [0]; if (slot.m) { - fs = ModuleUtils.findInternal('fs', 3, 'A'); + fs = ModuleUtils.findInternal('fs', 3, 'A'); slot = ship.internal.filter(a => a.maxClass === 3)[0]; ship.use(slot, fs); } else { @@ -153,12 +157,12 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) } else if (fsd.class === 5 && fsd.rating === 'A') { let fs = ModuleUtils.findInternal('fs', 5, 'B'); let slot = ship.internal.filter(a => a.maxClass >= 5).filter(a => a.maxClass >= fs.class) - .sort((a,b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) [0]; if (slot.m) { - fs = ModuleUtils.findInternal('fs', 4, 'A'); + fs = ModuleUtils.findInternal('fs', 4, 'A'); slot = ship.internal.filter(a => a.maxClass === 4).filter(a => a.maxClass >= fs.class) - .sort((a,b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) [0]; ship.use(slot, fs); } else { @@ -168,10 +172,10 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) let fs = ModuleUtils.findInternal('fs', 6, 'B'); let slot = ship.internal.filter(a => a.maxClass >= 6) .filter(a => a.maxClass >= fs.class) - .sort((a,b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) [0]; if (slot.m) { - fs = ModuleUtils.findInternal('fs', 5, 'A'); + fs = ModuleUtils.findInternal('fs', 5, 'A'); slot = ship.internal.filter(a => a.maxClass === 5)[0]; ship.use(slot, fs); } else { @@ -180,10 +184,10 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) } else if (fsd.class === 7 && fsd.rating === 'A') { let fs = ModuleUtils.findInternal('fs', 7, 'B'); let slot = ship.internal.filter(a => a.maxClass >= 7).filter(a => a.maxClass >= fs.class) - .sort((a,b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) [0]; if (slot.m) { - fs = ModuleUtils.findInternal('fs', 6, 'A'); + fs = ModuleUtils.findInternal('fs', 6, 'A'); slot = ship.internal.filter(a => a.maxClass === 6)[0]; ship.use(slot, fs); } else { @@ -194,9 +198,9 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) if (tier !== 1) { const fuelNeeded = ship.standard[2].m.maxfuel * 3; const fuelTank = ship.availCS.standard[6] - .filter(e => e.fuel) - .filter(e => e.fuel >= fuelNeeded) - ship.use(ship.standard[6], fuelTank[0]) + .filter(e => e.fuel) + .filter(e => e.fuel >= fuelNeeded); + ship.use(ship.standard[6], fuelTank[0]); } if (tier === 2) { @@ -208,8 +212,8 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) const sg = ship.getAvailableModules().lightestShieldGenerator(ship.ladenMass); const slot = ship.internal.filter(a => !a.m) .filter(a => a.maxClass >= sg.class) - .sort((a,b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) - [0]; + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + [0]; ship.use(slot, sg); if (engineeringLevel === 2) { // ELP G3 @@ -240,7 +244,7 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) const sg = ship.getAvailableModules().lightestShieldGenerator(ship.hullMass, 'A'); const slot = ship.internal.filter(a => !a.m) .filter(a => a.maxClass >= sg.class) - .sort((a,b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) [0]; ship.use(slot, sg); if (engineeringLevel === 1) { @@ -288,9 +292,9 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) if (tier !== 4) { if (engineeringLevel === 3) { const pd = ship.availCS.standard[4] - .filter(d => d.rating === 'D') - .filter(d => (d.engcap * 1.728) >= ship.boostEnergy) - .sort((a,b) => a.class.toString().localeCompare(b.class.toString()))[0] + .filter(d => d.rating === 'D') + .filter(d => (d.engcap * 1.728) >= ship.boostEnergy) + .sort((a, b) => a.class.toString().localeCompare(b.class.toString()))[0]; ship.use(ship.standard[4], pd); // CE G5 @@ -301,17 +305,17 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) setPercent(ship, ship.standard[4].m, 100); } else { const pd = ship.availCS.standard[4] - .filter(d => d.rating === 'D') - .filter(d => d.engcap >= ship.boostEnergy) - .sort((a,b) => a.class.toString().localeCompare(b.class.toString()))[0] - [0] - ship.use(ship.standard[4], pd) + .filter(d => d.rating === 'D') + .filter(d => d.engcap >= ship.boostEnergy) + .sort((a, b) => a.class.toString().localeCompare(b.class.toString()))[0] + [0]; + ship.use(ship.standard[4], pd); } } else { if (engineeringLevel === 3) { const pd = ship.availCS.standard[4] - .filter(d => d.rating === 'D') - .sort((a,b) => b.class.toString().localeCompare(a.class.toString()))[0] + .filter(d => d.rating === 'D') + .sort((a, b) => b.class.toString().localeCompare(a.class.toString()))[0]; ship.use(ship.standard[4], pd); // CE G5 @@ -322,18 +326,20 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) setPercent(ship, ship.standard[4].m, 100); } else { const pd = ship.availCS.standard[4] - .filter(d => d.rating === 'D') - .sort((a,b) => b.class.toString().localeCompare(a.class.toString()))[0] + .filter(d => d.rating === 'D') + .sort((a, b) => b.class.toString().localeCompare(a.class.toString()))[0]; ship.use(ship.standard[4], pd); } } if (ship.fighterHangars && fighter) { - const slot = ship.internal.filter(s => s.class === 5 && !s.m)[0]; + const slot = ship.internal.filter(s => s.maxClass >= 5 && !s.m) + .sort((a, b) => a.maxClass.toString().localeCompare(b.maxClass.toString())) + [0]; if (slot) { - const module = ModuleUtils.findInternal('fh', 5, 'D'); - ship.use(slot, module); + const mod = ModuleUtils.findInternal('fh', 5, 'D'); + ship.use(slot, mod); } } @@ -344,17 +350,17 @@ export function dw2Build(ship, tier, engineeringLevel, role, gfsb, gpp, fighter) // ship.useLightestStandard(standardOpts); ship.updatePowerGenerated() - .updatePowerUsed() - .recalculateMass() - .updateJumpStats() - .recalculateShield() - .recalculateShieldCells() - .recalculateArmour() - .recalculateDps() - .recalculateEps() - .recalculateHps() - .updateMovement() - .updateModificationsString(); + .updatePowerUsed() + .recalculateMass() + .updateJumpStats() + .recalculateShield() + .recalculateShieldCells() + .recalculateArmour() + .recalculateDps() + .recalculateEps() + .recalculateHps() + .updateMovement() + .updateModificationsString(); } /** @@ -378,7 +384,7 @@ export function trader(ship, shielded, standardOpts) { .filter(a => (!a.eligible) || a.eligible.sg) .filter(a => a.maxClass >= sg.class) .sort((a, b) => shieldOrder.indexOf(a.maxClass) - shieldOrder.indexOf(b.maxClass)); - shieldInternals.some(function (slot) { + shieldInternals.some(function(slot) { if (canMount(ship, slot, 'sg')) { // Assuming largest slot can hold an eligible shield const shield = ModuleUtils.findInternal('sg', slot.maxClass, 'A'); if (shield && shield.maxmass > ship.hullMass) { @@ -602,7 +608,7 @@ export function miner(ship, shielded) { // Dual mining lasers of highest possible class; remove anything else const miningLaserOrder = [2, 3, 4, 1, 0]; - const miningLaserHardpoints = ship.hardpoints.concat().sort(function (a, b) { + const miningLaserHardpoints = ship.hardpoints.concat().sort(function(a, b) { return miningLaserOrder.indexOf(a.maxClass) - miningLaserOrder.indexOf(b.maxClass); }); for (let s of miningLaserHardpoints) { @@ -616,7 +622,7 @@ export function miner(ship, shielded) { // Number of collector limpets required to be active is a function of the size of the ship and the power of the lasers const miningLaserDps = ship.hardpoints.filter(h => h.m != null) - .reduce(function (a, b) { + .reduce(function(a, b) { return a + b.m.getDps(); }, 0); // Find out how many internal slots we have, and their potential cargo size @@ -647,7 +653,7 @@ export function miner(ship, shielded) { // Power distributor to power the mining lasers indefinitely const wepRateRequired = ship.hardpoints.filter(h => h.m != null) - .reduce(function (a, b) { + .reduce(function(a, b) { return a + b.m.getEps(); }, 0); standardOpts.pd = ship.getAvailableModules().matchingPowerDist({ weprate: wepRateRequired }).id;