hathora-et-labora-game
Version:
Game logic reducer for Uwe Rosenberg's Ora et Labora
18 lines • 785 B
JavaScript
import { always, curry, map, pipe, range, reverse, view } from 'ramda';
import { P, match } from 'ts-pattern';
import { activeLens, getCost, payCost, withActivePlayer } from '../board/player';
import { parseResourceParam, stringRepeater } from '../board/resource';
export const peatCoalKiln = (param = '') => {
const { peat = 0 } = parseResourceParam(param);
return withActivePlayer(pipe(
//
getCost({ coal: 1 + peat, penny: 1 }), payCost({ peat })));
};
export const complete = curry((partial, state) => match(partial)
.with([], () => {
const { peat = 0 } = view(activeLens(state), state);
return map(stringRepeater('Pt'), reverse(range(0, 1 + peat)));
})
.with([P._], always(['']))
.otherwise(always([])));
//# sourceMappingURL=peatCoalKiln.js.map