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.

9 Likes

HAHAHAHAHA

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!

3 Likes

@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.

5 Likes

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

2 Likes

Now this is a cool thread

3 Likes

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!

2 Likes

@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!

1 Like

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.

1 Like

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

2 Likes

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

1 Like

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:

6 Likes

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

4 Likes

same_hat_dot_meme

3 Likes

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:

3 Likes

So, I came up with a layout that I’m happy with for the codex online project. Excited to start working on it more.

Anyone have experience automating chopping up image files? I bought the print-and-play set, and it seems silly to manually chop out the cards and make icons out of the tokens when they’re regularly arranged.

2 Likes

The image files are all publicly accessible via the codexcarddb

https://res.cloudinary.com/rgdelato/image/fetch/f_auto/http://codexcards-assets.surge.sh/images/0011_chaos_mirror.jpg

The code for that site is here:

The json files could be scraped for all the file names

Ryan (@LK4O4 ) might be able to just dump you a ZIP

If anyone does know of a place the files are named a little more programmatically (like the filename attribute, rather than the sirlins_filename attribute) or know where a ZIP of them is I’d be happy to know about it!

2 Likes

Awesome, this is a great resource!

I was also looking for something like Cropper.js (fengyuanchen.github.io) that I could do specific and repeatable crops. For my layout I’m going to need to be able to crop out the portraits and name plates from most cards, and additionally being able to crop out the little circles on the spell portraits sounds like it could enable prettiness.

Thanks @LK4O4 for the zip, and I’m also happy that it didn’t contain the tokens, to further justify my purchase of the print-and-play :stuck_out_tongue: .