hathora-et-labora-game
Version:
Game logic reducer for Uwe Rosenberg's Ora et Labora
27 lines • 990 B
JavaScript
import { always, curry, identity, pipe, reduce, view } from 'ramda';
import { P, match } from 'ts-pattern';
import { activeLens, getCost, payCost, withActivePlayer } from '../board/player';
import { allResource, combinations, differentGoods, parseResourceParam } from '../board/resource';
export const filialChurch = (param = '') => {
const inputs = parseResourceParam(param);
if (differentGoods(inputs) < 5)
return identity;
return withActivePlayer(pipe(
//
payCost(inputs), getCost({ reliquary: 1 })));
};
export const complete = curry((partial, state) => match(partial)
.with([], () => {
const player = view(activeLens(state), state);
return [
...combinations(5, reduce((accum, [key, token]) => {
if (player[key])
accum.push(token);
return accum;
}, [], allResource)),
'',
];
})
.with([P._], always(['']))
.otherwise(always([])));
//# sourceMappingURL=filialChurch.js.map