UNPKG

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.

26 lines 1.29 kB
import { always, curry, pipe, view } from 'ramda'; import { P, match } from 'ts-pattern'; import { activeLens, getWonder, payCost, withActivePlayer } from '../board/player'; import { parseResourceParam } from '../board/resource'; import { removeWonder } from '../board/state'; import { ResourceEnum } from '../types'; export const sacristy = (param = '') => { var _a, _b, _c, _d; const input = parseResourceParam(param); const iterations = Math.min(1, Math.max( // (_a = input.book) !== null && _a !== void 0 ? _a : 0, (_b = input.ceramic) !== null && _b !== void 0 ? _b : 0, (_c = input.ornament) !== null && _c !== void 0 ? _c : 0, (_d = input.reliquary) !== null && _d !== void 0 ? _d : 0)); return pipe(withActivePlayer(pipe( // payCost(input), getWonder(iterations))), removeWonder); }; export const complete = curry((partial, state) => match(partial) .with([], () => { const { book = 0, ceramic = 0, ornament = 0, reliquary = 0 } = view(activeLens(state), state); if (book && ceramic && ornament && reliquary) return [`${ResourceEnum.Book}${ResourceEnum.Ceramic}${ResourceEnum.Ornament}${ResourceEnum.Reliquary}`, '']; return ['']; }) .with([P._], always([''])) .otherwise(always([]))); //# sourceMappingURL=sacristy.js.map