hathora-et-labora-game
Version:
Plays Uwe Rosenberg's Ora et Labora for the Hathora engine. It reduces a list of moves into a board game state.
29 lines • 1.06 kB
JavaScript
import { always, curry, evolve, pipe, view } from 'ramda';
import { P, match } from 'ts-pattern';
import { activeLens, getCost, payCost, withActivePlayer } from '../board/player';
import { costMoney, parseResourceParam } from '../board/resource';
export const scriptorium = (pennies = '') => {
const input = parseResourceParam(pennies);
const paid = Math.min(costMoney(input), 1);
return withActivePlayer(pipe(payCost(input), getCost({
book: paid,
meat: paid,
whiskey: paid,
})));
};
export const complete = curry((partial, state) => match(partial)
.with([], () => {
const outputs = [];
const attachIfTruthy = (token) => (n) => n && outputs.push(token);
// okay i guess
evolve({
penny: attachIfTruthy('Pn'),
nickel: attachIfTruthy('Ni'),
wine: attachIfTruthy('Wn'),
whiskey: attachIfTruthy('Wh'),
}, view(activeLens(state), state));
return [...outputs, ''];
})
.with([P._], always(['']))
.otherwise(always([])));
//# sourceMappingURL=scriptorium.js.map