Building a hackable poker game

I would rather not make this post a copy+paste of what I wrote at the companion GitHub repository I set up, but think that the introduction I wrote in the README is nice, so here it is:

I really like Balatro's main idea of picking Poker and breaking [almost all] its rules, in a fun and addictive way, so I thought that it would be a nice exercise to replicate it.

The result is this (work in progress) repository: A simple poker game, and a Balatro look'n feel as a tribute. I don't know how far I'll go, e.g. if I will implement Jokers or not, but I'll try to have at minimum "fully hackable" ranking and scoring.

You can try it out here. Presently, if you want to hack the game (available) parameters, open the browser developer tools and go on from there.

Not-Balatro prototype screenshot

So here it is another personal experiment, this time more focused on the game design aspect than the actual coding. I'm lately getting tired quite early of mindless triple-A games, and instead Balatro is so well-designed that I began to try to discern how would you do X or Y in a poker game, in a way that it still felt like poker, but "boundless" (note that there are boundaries, just much bigger ones).

As I mentioned before, experiment is not yet finished. I tried ClaudeAI 3.5 to generate the first game prototype [1], then refactored and improved most areas, and when the game rules began to get complex, I decided to add tests to minimize manual testing. And that's the point where I currently am at, covering with tests all the game logic before I continue making the rules malleable. But it is already a fun endeavour; the moment you increase the play hand size above the normal 5 cards limit, you need to make important decisions about how you calculate hands like a Full House: By default 3 cards of a rank + 2, so... N+1 plus N, where N is half of the play hand size? And what happens when the hand size is an even number? And do you then require the whole played hand size to match that rule, or allow for a "classic full house" of 5 cards even if you play 7?

I also get to try NodeJS' built-in test runner (blazing fast with my unit tests, by the way). I wish I could remove the final block of "runner metrics" so I can just leave the 3 or 4 last lines of the watch mode visible, but I haven't checked the docs, there's probably a config option or flag to do so.

Anyway, if you've played the game or simply are interested, give it a try and/or check the code! I won't post here normal updates, but I will when I consider that the experiment is complete. I don't plan to build a full Balatro clone by any means (e.g. probably no Jokers, or just one or two to showcase their mechanics).

[1] With very mixed results. The initial PoC looked great, complete with the embedded interactive visualization at Claude's website, but the code "just works", wasn't of very high quality. Plus I noticed that on each refinement prompt, the LLM tended to rewrite all code, not just the fragments it should (GitHub Copilot is way smarter in this regard), leading to mutating function and CSS class names, altering CSS effects, and other unexpected and unrelated changes.

Tags: Development Game Dev Javascript Testing Videogames

Building a hackable poker game article, written by Kartones. Published on