Skip to content

Commit

Permalink
[744] add support of experimental weapon stabilizer (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMander authored Apr 29, 2024
1 parent 9766f78 commit ef82cf4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
41 changes: 36 additions & 5 deletions src/app/components/AvailableModulesMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as ModuleUtils from '../shipyard/ModuleUtils';
import TranslatedComponent from './TranslatedComponent';
import { stopCtxPropagation } from '../utils/UtilityFunctions';
import cn from 'classnames';
import { MountFixed, MountGimballed, MountTurret } from './SvgIcons';
import { CoriolisLogo, MountFixed, MountGimballed, MountTurret } from './SvgIcons';
import FuzzySearch from 'react-fuzzy';

const PRESS_THRESHOLD = 500; // mouse/touch down threshold
Expand Down Expand Up @@ -84,6 +84,8 @@ const GRPCAT = {
// Assists
'dc': 'flight assists',
'sua': 'flight assists',
// Stabilizers
'ews': 'weapon stabilizers',
};
// Order here is the order in which items will be shown in the modules menu
const CATEGORIES = {
Expand All @@ -107,11 +109,12 @@ const CATEGORIES = {
// Utilities
'sb': ['sb'],
'hs': ['hs'],
'csl': ['csl'],
'defence': ['ch', 'po', 'ec'],
'scanners': ['sc', 'ss', 'cs', 'kw', 'ws'], // Overloaded with internal scanners
// Experimental
'experimental': ['axmc', 'axmr', 'rfl', 'tbrfl', 'tbsc', 'tbem', 'xs', 'sfn', 'rcpl', 'dtl', 'rsl', 'mahr',],

'weapon stabilizers': ['ews'],
// Guardian
'guardian': ['gpp', 'gpd', 'gpc', 'ggc', 'gsrp', 'gfsb', 'ghrp', 'gmrp', 'gsc'],

Expand Down Expand Up @@ -250,6 +253,24 @@ export default class AvailableModulesMenu extends TranslatedComponent {
return { list, currentGroup, fuzzy, trackingFocus };
}

/**
* Return Is expiremental capacity reached
* @return {boolean} Is experimental capacity reached
*/
_experimentalCapacityReached() {
const ship = this.props.ship;
const ews = ship.internal.filter(o => o.m && o.m.grp === 'ews');
let expCap;

if(ews.length < 1){
expCap = 4;
} else{
expCap = ews[0].m.class == 3 ? 5 : 6;
}

return expCap <= this.props.ship.hardpoints.filter(o => o.m && o.m.experimental).length;
}

/**
* Generate React Components for Module Group
* @param {Ship} ship Ship the selection is for
Expand Down Expand Up @@ -286,7 +307,7 @@ export default class AvailableModulesMenu extends TranslatedComponent {
// If the mounted module is experimental as well, we can replace it so
// the maximum does not apply
} else if (m.experimental && (!mountedModule || !mountedModule.experimental)) {
disabled = 4 <= ship.hardpoints.filter(o => o.m && o.m.experimental).length;
disabled = this._experimentalCapacityReached();
} else if (m.grp === 'mlc' && (!mountedModule || mountedModule.grp !== 'mlc')) {
disabled = 1 <= ship.internal.filter(o => o.m && o.m.grp === 'mlc').length;
}
Expand Down Expand Up @@ -385,6 +406,7 @@ export default class AvailableModulesMenu extends TranslatedComponent {
if (this.props.modules instanceof Array) {
return;
}
const mountedModule = this.props.m;
return (
<FuzzySearch
list={this.state.fuzzy}
Expand All @@ -396,11 +418,20 @@ export default class AvailableModulesMenu extends TranslatedComponent {
onSelect={e => this.props.onSelect.bind(null, e.m)()}
resultsTemplate={(props, state, styles, clickHandler) => {
return state.results.map((val, i) => {
let disabled;

if(val.m.experimental && (!mountedModule || !mountedModule.experimental)) {
disabled = this._experimentalCapacityReached();
} else{
disabled = false;
}
const handler = disabled ? null : () => clickHandler(i);

return (
<div
key={i}
className={'lc'}
onClick={() => clickHandler(i)}
className={cn('lc', {disabled})}
onClick={handler}
>
{val.name}
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"ch": "Chaff Launcher",
"cr": "Cargo Rack",
"cs": "Manifest Scanner",
"csl": "Caustic Sink Launcher",
"dc": "Docking Computer",
"ec": "Electronic Countermeasure",
"fc": "Fragment Cannon",
Expand All @@ -113,6 +114,7 @@
"mlc": "Multi Limpet Controller",
"mr": "Missile Rack",
"axmr": "AX Missile Rack",
"ews": "Experimental Weapon Stabilizer",
"mrp": "Module Reinforcement Package",
"nl": "Mine Launcher",
"pa": "Plasma Accelerator",
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"ch": "Разбрасыватель дипольных отражателей",
"cr": "Грузовой стеллаж",
"cs": "Сканер содержимого",
"csl": "Антикор катапульта",
"dc": "Стыковочный компьютер",
"ec": "Радиоэлектронное подавление",
"fc": "Залповое орудие",
Expand All @@ -113,6 +114,7 @@
"ml": "Проходочный лазер",
"mr": "Блок ракет",
"axmr": "Блок ракет АИ",
"ews": "Стабилизатор экспериментального вооружения",
"mrp": "Набор для усиления модуля",
"nl": "Мины",
"pa": "Ускоритель плазмы",
Expand Down
2 changes: 1 addition & 1 deletion src/app/shipyard/Ship.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Ships, Modifications } from 'coriolis-data/dist';
import { chain } from 'lodash';
const zlib = require('zlib');

const UNIQUE_MODULES = ['psg', 'sg', 'bsg', 'rf', 'fs', 'fh', 'gfsb', 'dc'];
const UNIQUE_MODULES = ['psg', 'sg', 'bsg', 'rf', 'fs', 'fh', 'gfsb', 'dc', 'ews'];

// Constants for modifications struct
const SLOT_ID_DONE = -1;
Expand Down

0 comments on commit ef82cf4

Please sign in to comment.