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.
49 lines (45 loc) • 1.03 kB
text/typescript
import { BuildingEnum, LandEnum, StateReducer, Tile } from '../../types'
import { makeLandscape } from '../landscape'
import { clergyForColor } from '../player'
export const addNeutralPlayer: StateReducer = (state) => {
if (state === undefined) return state
const { color } = state.players[1]
const clergy = clergyForColor(state.config)(color)
const [row0, row1] = makeLandscape(color)
const landscape: Tile[][] = [
[
[],
[],
[],
[],
[],
[],
row0[6],
[],
[],
],
[
[], // basically its just an empty landscape, but use the right colors
[],
[],
[],
row1[4],
[],
row1[6],
[],
[],
],
]
return {
...state,
players: [
state.players[0],
{
...state.players[1],
color,
clergy,
landscape,
},
],
}
}