This week I’ve worked on creating a basic signup form and made lots of visual tweaks. There’s not much to talk about here, so I’ll take the opportunity to discuss the game engine.
The game uses a custom scripting language for card effects and rules. Interpreting the language doesn’t just update the game state on the server, it also generates a list of state diffs and animations for the client.
The scripting language can also be modified on the fly, which is a great way to implement effects that change other effects. For example, the card “Sickness” changes all healing to do damage instead, so it simply replaces all healing with damage in the scripts it cares about.
This approach has proved to be really powerful. Not only is it easy to write cards with complex effects and animation logic, it’s also made game replays trivial to implement. Replays are just an initial state paired with a list of all the state diffs and animations in the game.
The great thing about Haskell is that it gives a lot of this stuff “for free” using
Free Monads. The custom language is embedded in Haskell itself so gets all of Haskell’s features (including type safety and control structures!), and we didn’t have to write a single parser.