News for hackers. Stuff that matters.
Re:Boardgame.io: an engine for creating turn-based games usi... by sjrd on Friday December 20, 2024 @04:11PM (#42475075)
The way I did this was to design a more-or-less monadic container `Result<A>` for all my game logic functions. It batches a sequence of animation steps with a result. It can also model error conditions (like not having enough resources for example). I can then instantiate it any concrete result type, such as a full game state or just the result of individual computations. It was very nice to concisely write complicated game logic with animations while retaining the happy path.

https://github.com/sjrd/barrage/blob/main/src/main/scala/be/...

Re:Boardgame.io: an engine for creating turn-based games usi... by LudwigNagasena on Friday December 20, 2024 @05:32PM (#42475752)
Interesting. Unfortunately, your repo seems to be private.
Re:Boardgame.io: an engine for creating turn-based games usi... by sjrd on Friday December 20, 2024 @05:39PM (#42475821)
Oh shoot, yes. I have imitation copies of the original game graphics in there, and so I can't make it public without violating copyright of their assets. :-(

Here is a public gist with the `Result` data structure, as well a good portion of the file handling all the game mechanics, which should show it gets used. https://gist.github.com/sjrd/34fe234d1b6232cf42ffda5d23292d3...