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.
30 lines (27 loc) • 803 B
text/typescript
import { withRondel } from '../rondel'
const pushArm = (expireAfterTen = false) =>
withRondel((rondel) => {
const next = (rondel.pointingBefore + 1) % 13
const bumper = (from?: number) => {
if (from === next) {
if (expireAfterTen) return undefined
return (from + 1) % 13
}
return from
}
return {
...rondel,
pointingBefore: next,
grain: bumper(rondel.grain),
sheep: bumper(rondel.sheep),
clay: bumper(rondel.clay),
coin: bumper(rondel.coin),
wood: bumper(rondel.wood),
joker: bumper(rondel.joker),
peat: bumper(rondel.peat),
grape: bumper(rondel.grape),
stone: bumper(rondel.stone),
}
})
export const rotateRondel = pushArm()
export const rotateRondelWithExpire = pushArm(true)