hathora-et-labora-game
Version:
Game logic reducer for Uwe Rosenberg's Ora et Labora
20 lines • 926 B
JavaScript
import { always, curry, map, min, 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';
import { ResourceEnum } from '../types';
export const refectory = (param = '') => {
const { meat = 0 } = parseResourceParam(param);
const iterations = Math.min(4, meat);
return withActivePlayer(pipe(
//
getCost({ beer: 1, meat: 1 }), payCost({ meat: iterations }), getCost({ ceramic: iterations })));
};
export const complete = curry((partial, state) => match(partial)
.with([], () => {
const { meat = 0 } = view(activeLens(state), state);
return map(stringRepeater(ResourceEnum.Meat), reverse(range(0, 2 + min(3, meat))));
})
.with([P._], always(['']))
.otherwise(always([])));
//# sourceMappingURL=refectory.js.map