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.
25 lines (22 loc) • 717 B
text/typescript
import { T, __, always, cond, curry, gte } from 'ramda'
import { match } from 'ts-pattern'
import { getCost, withActivePlayer } from '../board/player'
import { GameStatePlaying, StateReducer } from '../types'
export const spinningMill = (): StateReducer => {
return withActivePlayer((player) => {
// TODO: this could be an evolve?
return getCost({
penny: cond([
[gte(__, 9), always(6)],
[gte(__, 5), always(5)],
[gte(__, 1), always(3)],
[T, always(0)],
])(player.sheep ?? 0),
})(player)
})
}
export const complete = curry((partial: string[], _state: GameStatePlaying): string[] =>
match(partial)
.with([], always(['']))
.otherwise(always([]))
)