hathora-et-labora-game
Version:
Game logic reducer for Uwe Rosenberg's Ora et Labora
25 lines (22 loc) • 703 B
text/typescript
import { T, __, always, cond, curry, gte } from 'ramda'
import { match } from 'ts-pattern'
import { getCost, withActivePlayer } from '../board/player'
import { GameState, 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: GameState): string[] =>
match(partial)
.with([], always(['']))
.otherwise(always([]))
)