mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
dw2 build work
This commit is contained in:
@@ -20,10 +20,19 @@ export default class StandardSlotSection extends SlotSection {
|
||||
super(props, context, 'standard', 'core internal');
|
||||
this._optimizeStandard = this._optimizeStandard.bind(this);
|
||||
this._selectBulkhead = this._selectBulkhead.bind(this);
|
||||
this._showDW2Menu = this._showDW2Menu.bind(this);
|
||||
this._dw2 = this._dw2.bind(this);
|
||||
this.selectedRefId = null;
|
||||
this.firstRefId = 'maxjump';
|
||||
this.lastRefId = 'racer';
|
||||
this.lastRefId = 'dw2';
|
||||
this.state = {
|
||||
showDW2: false,
|
||||
DW2Tier: -1,
|
||||
DW2Eng: -1,
|
||||
DW2Role: ''
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle focus if the component updates
|
||||
* @param {Object} prevProps React Component properties
|
||||
@@ -72,6 +81,91 @@ export default class StandardSlotSection extends SlotSection {
|
||||
this._close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.props.ship.updateModificationsString()
|
||||
this.props.onChange();
|
||||
this.props.onCargoChange(this.props.ship.cargoCapacity);
|
||||
this.props.onFuelChange(this.props.ship.fuelCapacity);
|
||||
this._close();
|
||||
}
|
||||
|
||||
_showDW2Menu(translate) {
|
||||
return (
|
||||
<div className='select' onClick={(e) => e.stopPropagation()} onContextMenu={stopCtxPropagation}>
|
||||
<div className='select-group cap'>{translate('Tier')}</div>
|
||||
<ul id={'tier'}>
|
||||
<li className={cn({ active: this.state.DW2Tier === 1 }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Tier: 1 })} onKeyDown={this._keyDown}
|
||||
>{translate('1- Hardcore exploration, fully maximize jump range')}</li>
|
||||
<li className={cn({ active: this.state.DW2Tier === 2 }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Tier: 2 })} onKeyDown={this._keyDown}
|
||||
>{translate('2- Classical shielded exploration')}</li>
|
||||
<li className={cn({ active: this.state.DW2Tier === 3 }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Tier: 3 })} onKeyDown={this._keyDown}
|
||||
>{translate('3- Surface exploration, improved shield')}</li>
|
||||
<li className={cn({ active: this.state.DW2Tier === 4 }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Tier: 4 })} onKeyDown={this._keyDown}
|
||||
>{translate('4- Surface flight, improved shield and thrusters')}</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
<div className='select-group cap'>{translate('Engineering Level')}</div>
|
||||
<ul id={'engLevel'}>
|
||||
<li className={cn({ active: this.state.DW2Eng === 1 }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Eng: 1 })} onKeyDown={this._keyDown}
|
||||
>{translate('No engineering')}</li>
|
||||
<li className={cn({ active: this.state.DW2Eng === 2 }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Eng: 2 })} onKeyDown={this._keyDown}
|
||||
>{translate('Only Felicity Farseer and Elvira Martuuk')}</li>
|
||||
<li className={cn({ active: this.state.DW2Eng === 3 }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Eng: 3 })} onKeyDown={this._keyDown}
|
||||
>{translate('All exploration related engineers')}</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
<div className='select-group cap'>{translate('Role')}</div>
|
||||
<ul id={'role'}>
|
||||
<li className={cn({ active: this.state.DW2Role === 'exploration' }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Role: 'exploration' })}
|
||||
onKeyDown={this._keyDown}
|
||||
>{translate('Exploration')}</li>
|
||||
<li className={cn({ active: this.state.DW2Role === 'surface' }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Role: 'surface' })}
|
||||
onKeyDown={this._keyDown}
|
||||
>{translate('Surface exploration')}</li>
|
||||
<li className={cn({ active: this.state.DW2Role === 'fullmining' }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Role: 'fullmining' })}
|
||||
onKeyDown={this._keyDown}
|
||||
>{translate('Big Rig, full mining')}</li>
|
||||
<li className={cn({ active: this.state.DW2Role === 'prospector' }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Role: 'prospector' })}
|
||||
onKeyDown={this._keyDown}
|
||||
>{translate('Saper / Prospector mining')}</li>
|
||||
<li className={cn({ active: this.state.DW2Role === 'rat' }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Role: 'rat' })} onKeyDown={this._keyDown}
|
||||
>{translate('Fuel rat')}</li>
|
||||
<li className={cn({ active: this.state.DW2Role === 'repair' }, 'lc')} tabIndex="0"
|
||||
onClick={() => this.setState({ DW2Role: 'repair' })} onKeyDown={this._keyDown}
|
||||
>{translate('Repair rat')}</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
<ul>
|
||||
<li onClick={this._dw2} className={cn('lc')} tabIndex="0"
|
||||
onKeyDown={this._keyDown}>
|
||||
<button className="button">Apply</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Miner Build
|
||||
* @param {Boolean} shielded True if shield generator should be included
|
||||
@@ -245,19 +339,34 @@ export default class StandardSlotSection extends SlotSection {
|
||||
*/
|
||||
_getSectionMenu(translate) {
|
||||
let planetaryDisabled = this.props.ship.internal.length < 4;
|
||||
if (this.state.showDW2 === true) {
|
||||
return this._showDW2Menu(translate);
|
||||
}
|
||||
return <div className='select' onClick={(e) => e.stopPropagation()} onContextMenu={stopCtxPropagation}>
|
||||
<ul>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeStandard} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['maxjump'] = smRef}>{translate('Maximize Jump Range')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeStandard} onKeyDown={this._keyDown}
|
||||
ref={smRef => this.sectionRefArr['maxjump'] = smRef}>{translate('Maximize Jump Range')}</li>
|
||||
</ul>
|
||||
<div className='select-group cap'>{translate('roles')}</div>
|
||||
<ul>
|
||||
<li className='lc' tabIndex="0" onClick={this._multiPurpose.bind(this, false, 0)} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['multipurpose'] = smRef}>{translate('Multi-purpose')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._multiPurpose.bind(this, true, 2)} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['combat'] = smRef}>{translate('Combat')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeCargo.bind(this, true)} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['trader'] = smRef}>{translate('Trader')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeExplorer.bind(this, false)} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['explorer'] = smRef}>{translate('Explorer')}</li>
|
||||
<li className={cn('lc', { disabled: planetaryDisabled })} tabIndex={planetaryDisabled ? '' : '0'} onClick={!planetaryDisabled && this._optimizeExplorer.bind(this, true)} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['planetary'] = smRef}>{translate('Planetary Explorer')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeMiner.bind(this, true)} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['miner'] = smRef}>{translate('Miner')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeRacer.bind(this)} onKeyDown={this._keyDown} ref={smRef => this.sectionRefArr['racer'] = smRef}>{translate('Racer')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._multiPurpose.bind(this, false, 0)} onKeyDown={this._keyDown}
|
||||
ref={smRef => this.sectionRefArr['multipurpose'] = smRef}>{translate('Multi-purpose')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._multiPurpose.bind(this, true, 2)} onKeyDown={this._keyDown}
|
||||
ref={smRef => this.sectionRefArr['combat'] = smRef}>{translate('Combat')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeCargo.bind(this, true)} onKeyDown={this._keyDown}
|
||||
ref={smRef => this.sectionRefArr['trader'] = smRef}>{translate('Trader')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeExplorer.bind(this, false)} onKeyDown={this._keyDown}
|
||||
ref={smRef => this.sectionRefArr['explorer'] = smRef}>{translate('Explorer')}</li>
|
||||
<li className={cn('lc', { disabled: planetaryDisabled })} tabIndex={planetaryDisabled ? '' : '0'}
|
||||
onClick={!planetaryDisabled && this._optimizeExplorer.bind(this, true)} onKeyDown={this._keyDown}
|
||||
ref={smRef => this.sectionRefArr['planetary'] = smRef}>{translate('Planetary Explorer')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeMiner.bind(this, true)} onKeyDown={this._keyDown}
|
||||
ref={smRef => this.sectionRefArr['miner'] = smRef}>{translate('Miner')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={this._optimizeRacer.bind(this)} onKeyDown={this._keyDown}
|
||||
ref={smRef => this.sectionRefArr['racer'] = smRef}>{translate('Racer')}</li>
|
||||
<li className='lc' tabIndex="0" onClick={() => this.setState({ showDW2: !this.state.showDW2 })}
|
||||
onKeyDown={this._keyDown}
|
||||
ref={smRef => this.sectionRefArr['dw2'] = smRef}>{translate('DW2')}</li>
|
||||
</ul>
|
||||
</div>;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import * as ModuleUtils from './ModuleUtils';
|
||||
import {Modifications} from 'coriolis-data/dist';
|
||||
import { canMount } from '../utils/SlotFunctions';
|
||||
import { getBlueprint, setPercent } from '../utils/BlueprintFunctions';
|
||||
|
||||
|
||||
/**
|
||||
* Standard / typical role for multi-purpose or combat (if shielded with better bulkheads)
|
||||
@@ -24,6 +27,96 @@ export function multiPurpose(ship, shielded, bulkheadIndex) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Distant Worlds 2 role
|
||||
* Tiers:
|
||||
* 1- Hardcore exploration, fully maximize jump range
|
||||
* 2- Classical shielded exploration
|
||||
* 3- Surface exploration, improved shield
|
||||
* 4- Surface flight, improved shield and thrusters
|
||||
*
|
||||
* Engineering level:
|
||||
* No engineering
|
||||
* Only Felicity Farseer and Elvira Martuuk
|
||||
* All exploration related engineers
|
||||
*
|
||||
* Role
|
||||
* Exploration
|
||||
* Surface exploration
|
||||
* Big Rig, full mining
|
||||
* Saper / Prospector mining
|
||||
* Fuel rat
|
||||
* Repair rat
|
||||
*
|
||||
* @param ship {Ship} Ship instance
|
||||
* @param tier {Number}
|
||||
* @param engineeringLevel {Number}
|
||||
* @param role {String}
|
||||
*/
|
||||
export function dw2Build(ship, tier, engineeringLevel, role) {
|
||||
let standardOpts = { ppRating: 'D', pd: 'd3' };
|
||||
ship
|
||||
.emptyInternal()
|
||||
.emptyHardpoints()
|
||||
.emptyUtility();
|
||||
ship.use(ship.standard[2], ModuleUtils.findStandard('fsd', ship.standard[2].maxClass, 'A'))
|
||||
ship.use(ship.standard[3], ModuleUtils.findStandard('ls', ship.standard[3].maxClass, 'D'))
|
||||
ship.use(ship.standard[4], ModuleUtils.findStandard('pd', 1, 'D'))
|
||||
ship.use(ship.standard[5], ModuleUtils.findStandard('s', ship.standard[5].maxClass, 'D'))
|
||||
const fuelNeeded = ship.standard[2].m.maxfuel * 2;
|
||||
const fuelTank = ship.availCS.standard[6]
|
||||
.filter(e => e.fuel)
|
||||
.filter(e => e.fuel >= fuelNeeded)
|
||||
ship.use(ship.standard[6], fuelTank[0])
|
||||
|
||||
if (engineeringLevel === 2) {
|
||||
const bp = getBlueprint('FSD_LongRange', ship.standard[2]);
|
||||
bp.grade = 5
|
||||
bp.special = Modifications.specials['special_fsd_heavy']
|
||||
ship.standard[2].m.blueprint = bp;
|
||||
setPercent(ship, ship.standard[2].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']
|
||||
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']
|
||||
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
|
||||
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
|
||||
ship.standard[5].m.blueprint = sBP;
|
||||
setPercent(ship, ship.standard[5].m, 100);
|
||||
}
|
||||
ship.useBulkhead(0, false);
|
||||
ship.use(ship.standard[0], ship.availCS.lightestPowerPlant(Math.max(ship.powerRetracted, ship.powerDeployed), 'D'))
|
||||
|
||||
// ship.useLightestStandard(standardOpts);
|
||||
ship.updatePowerGenerated()
|
||||
.updatePowerUsed()
|
||||
.recalculateMass()
|
||||
.updateJumpStats()
|
||||
.recalculateShield()
|
||||
.recalculateShieldCells()
|
||||
.recalculateArmour()
|
||||
.recalculateDps()
|
||||
.recalculateEps()
|
||||
.recalculateHps()
|
||||
.updateMovement()
|
||||
.updateModificationsString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Trader Role
|
||||
* @param {Ship} ship Ship instance
|
||||
|
||||
Reference in New Issue
Block a user