Transferring all Actions to ListStore to regain unidirectional data flow for all stores. Other Stores only will store section-specific data e.g. filters.
39 lines
659 B
JavaScript
39 lines
659 B
JavaScript
import APStore from '../stores/APStore';
|
|
|
|
// AC = Activation Cost
|
|
// IC = Improvement Cost
|
|
|
|
export function getIC(ic, sr) {
|
|
const f = ic === 5 ? 15 : ic;
|
|
if (sr < 12 || (ic === 5 && sr < 14)) {
|
|
return f;
|
|
} else {
|
|
return (sr - (ic === 5 ? 13 : 11)) * f;
|
|
}
|
|
}
|
|
|
|
export function final(ic, sr) {
|
|
if (sr) {
|
|
let add = 1;
|
|
if (ic < 0) {
|
|
ic = Math.abs(ic);
|
|
add = -1;
|
|
}
|
|
return getIC(ic, sr) * add;
|
|
} else {
|
|
return ic;
|
|
}
|
|
}
|
|
|
|
export function check(cost) {
|
|
if (cost > 0) {
|
|
let available = APStore.getAvailable();
|
|
return cost <= available;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
export const validate = (ic, sr) => check(final(ic, sr));
|
|
|
|
export default validate;
|