UNPKG

hathora-et-labora-game

Version:

Game logic reducer for Uwe Rosenberg's Ora et Labora

20 lines 994 B
import { always, curry, filter, map, reject } from 'ramda'; import { match } from 'ts-pattern'; import { setFrameToAllowFreeUsage } from '../board/frame'; import { findClergy } from '../board/landscape'; import { priors } from '../board/player'; import { BuildingEnum } from '../types'; export const priory = () => (state) => { if (state === undefined) return undefined; const landscapes = map(({ landscape }) => landscape)(state.players); const clergyLocation = map(findClergy(priors(state)), landscapes); const foundClergy = reject((l) => l.length === 0, clergyLocation); const clergyBuildings = map(([[_r, _c, [_l, building]]]) => building, foundClergy); const usableBuildings = filter((b) => b !== BuildingEnum.Priory, clergyBuildings); return setFrameToAllowFreeUsage(usableBuildings)(state); }; export const complete = curry((partial, _state) => match(partial) .with([], always([''])) .otherwise(always([]))); //# sourceMappingURL=priory.js.map