News Shop
Events Chat

Codex Engine Open Sourced

Hi folks,

About two years ago, I decided it would be fun to create a real working Codex game, with full rules engine. The idea was to use the forum to create the community, so I wouldn’t have to handle user management and all that sort of thing - only game state and rules. So, it’d work like this -

  • Go to game site
  • Make your first turn. The game handles all rules for you, all triggers, all state tracking (counters etc), and so on.
  • Game engine saves state and gives you a link to the next player’s turn, which you give to the next player

In practice, the game would actually post the game state (minus secret information) to the forum, along with the link for the next player to take their turn and continue the cycle.

I actually built the engine and it works, supporting most game features. I designed it to be flexible enough to support almost all cards, and implemented some of the tricky ones as tests to make sure that they function.

I began building a very simple client as well, mostly for testing the game, but didn’t get very far. Only a handful of cards are implemented.

Anyway, mid-project I became distracted by work and life, and put it on hold. I’m posting now because having it so near to completion feels like a waste, so I decided to open source it in case anyone else wants to chip away at it. The current state of the game is:

  • Engine: Mostly complete. Overpower is still on the TODO list and it might take an hour or two to finish implementing. Forecast/Fade still need to be implemented, along with a small list of other minor features. I designed a system flexible enough to support all cards I could think of, and implemented a system to make adding cards very simple - mostly copy/paste, even for more complex interactions.

  • Cards: Mostly not implemented, aside from a bunch used for testing. Basic cards can be added to the game in seconds (copy, paste, change values). More complicated cards might take a few minutes, and the most complicated cards upwards of 10 minutes.

  • Client: Has the most work to do; very basic, only for testing. Even start game functionality is not implemented.

  • Code: I wrote everything in TypeScript and the client in React TypeScript, because at the time I was interested in learning these technologies.

Code is here:

I’d welcome anyone who’s interested in contributing and would be able to give some guidance on how to get started.



I literally just started a few days ago on a project to do basically exactly this same thing!

I have a couple of dev bootcamp graduates working on it with me!

Let me take a look at what you have and we will abandon ship here to help your effort!


@tie can you help me understand how the engine works? There’s no start script and it’s unclear to me what one “does” with it.

For some further background, the thought I had to build w/ the bootcamp folks I’m mentoring did not have the rules engine in scope at all (as I felt that was a very difficult thing to undertake, and I imagine you ran up against that as well!), but was to support:

  • Signing in w/ socials
  • Be able to spectate public games, or start new ones (either private, “tourney” where secrets can be seen only by folks with a “TO judge” role NOT playing the game, or fully open to spectators, minus the two players in the game)
  • Laying out the client like a game board
  • “Playing by forum” visually, where you’d still write down “what happened” in your turn, but you would be given a start board / econ / cards state, and could do all the things to manipulate that state into an “end state”.
  • Track stats of games (how many turns to finish, player w/l, deck w/l, spec w/l, starter w/l and P1/2 w/l)

If you think you’re close on a rules engine, we’re happy to work on the other things, but we’ll need some help understanding how to use it.


Sure, I’ll DM you. Probably easiest to do a quick phone call :slight_smile:

1 Like

Now this is a cool thread


Ooh cool! I made a codex engine in Elm last year, implementing the starter set factions. I think Elm is a great option for a project like this since it’s so easy to add more features as the factions get implemented (or even custom factions) without worrying about introducing bugs.

I’d be happy to contribute to the cause!

1 Like

@OffKilter is this project available somewhere? I’ve been unsuccessful with Tie’s repo and my priority remains getting a “PbF UI” together before trying to do rules enforcement (there’s a reason it hasn’t been completed successfully thus far). I don’t know Elm particularly well (I’ve played with it a little), but I’d be happy to take a look at what you have!

Don’t know if anything’s happening with this, but that’s some good work there, @tie. Only thing I can criticise, without a deeper look, is that I don’t think taking damage should be counted as a case of a RuneEvent.

Anything that plays with runes is going to be functional a state based effect, so I think its fine?

1 Like

It’s just potentially confusing. Especially when you have to add Plague Lab.

Rules enforcement, in general, is a very hard problem to solve. From what I can tell @tie has an excellent start on it, but it’ll need a lot of love before it’s ready for integration into a fully featured system. I am proceeding with it in mind but as a v2 or v3 integration, which will probably be years away, unless I get really bored with not coding in my new job.

Which BTW, starting a new job in a couple weeks everyone! My first foray into people managing :wink: If I’m slower to reply on things, that’ll be why. Wish me luck :crossed_fingers:


For some reason, my foray into people managing has left me continuing to do the regular job half the time anyway. Good luck!



1 Like

thanks man :slight_smile: my expectation is that I will have to do some coding still but it was impressed upon me I should avoid getting my hands dirty and instead instruct wherever possible. We’ll see how it goes :wink:

1 Like