aotds-docks/src/lib/shipDux/structure/streamlining.js

33 lines
625 B
JavaScript
Raw Normal View History

2022-03-04 21:31:05 +00:00
import { Updux } from "updux";
import u from "updeep";
import reqs from "../reqs.js";
const dux = new Updux({
subduxes: {
reqs,
},
initial: {
type: "none",
},
actions: {
setStreamlining: null,
},
});
export default dux;
dux.setMutation("setStreamlining", ({ shipMass, type }) =>
u({
type,
reqs: calcStreamliningReqs({ shipMass, type }),
})
);
function calcStreamliningReqs({ shipMass, type }) {
const mass = Math.ceil(
(shipMass * (type === "none" ? 0 : type === "partial" ? 5 : 10)) / 100
);
return { mass, cost: 2 * mass };
}