mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 22:55:35 +00:00
Add stats mapper to show certain synthetic props in ModificationsMenu
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
|||||||
} from '../utils/BlueprintFunctions';
|
} from '../utils/BlueprintFunctions';
|
||||||
import { getBlueprintInfo, getExperimentalInfo } from 'ed-forge/lib/data/blueprints';
|
import { getBlueprintInfo, getExperimentalInfo } from 'ed-forge/lib/data/blueprints';
|
||||||
import { getModuleInfo } from 'ed-forge/lib/data/items';
|
import { getModuleInfo } from 'ed-forge/lib/data/items';
|
||||||
|
import { SHOW } from '../shipyard/StatsMapping';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifications menu
|
* Modifications menu
|
||||||
@@ -149,12 +150,10 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
|
|
||||||
let onSet = m.set.bind(m);
|
let onSet = m.set.bind(m);
|
||||||
// Show resistance instead of effectiveness
|
// Show resistance instead of effectiveness
|
||||||
if (property.endsWith('effectiveness')) {
|
const mapped = SHOW[property];
|
||||||
const oldProperty = property;
|
if (mapped) {
|
||||||
property = property.replace('effectiveness', 'resistance');
|
property = mapped.as;
|
||||||
onSet = (_, v) => {
|
onSet = mapped.setter.bind(undefined, m);
|
||||||
m.set(oldProperty, 1 - v / 100);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Modification key={property} m={m} property={property}
|
return <Modification key={property} m={m} property={property}
|
||||||
|
|||||||
33
src/app/shipyard/StatsMapping.js
Normal file
33
src/app/shipyard/StatsMapping.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { Module } from 'ed-forge';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a resistance value of a module as
|
||||||
|
* @param {Module} module Module to set the property
|
||||||
|
* @param {string} prop Property name; must end with 'resistance'
|
||||||
|
* @param {number} val Resistance value to set
|
||||||
|
*/
|
||||||
|
function setterResToEff(module, prop, val) {
|
||||||
|
module.set(
|
||||||
|
prop.replace('resistance', 'effectiveness'),
|
||||||
|
1 - val / 100,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SHOW = {
|
||||||
|
causticeffectiveness: {
|
||||||
|
as: 'causticresistance',
|
||||||
|
setter: setterResToEff,
|
||||||
|
},
|
||||||
|
explosiveeffectiveness: {
|
||||||
|
as: 'explosiveresistance',
|
||||||
|
setter: setterResToEff,
|
||||||
|
},
|
||||||
|
kineticeffectiveness: {
|
||||||
|
as: 'kineticresistance',
|
||||||
|
setter: setterResToEff,
|
||||||
|
},
|
||||||
|
thermiceffectiveness: {
|
||||||
|
as: 'thermicresistance',
|
||||||
|
setter: setterResToEff,
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user