Implementing game rules in a tactical battle board game

Posted by Setzer22 on Game Development See other posts from Game Development or by Setzer22
Published on 2014-08-18T11:20:57Z Indexed on 2014/08/18 16:47 UTC
Read the original article Hit count: 373

Filed under:

I'm trying to create a game similar to what one would find in a typical D&D board game combat. For mor examples you could think of games like Advance Wars, Fire Emblem or Disgaea.

I should say that I'm using design by component so far, but I can't find a nice way to fit components into the part I want to ask.

I'm struggling right now with the "game rules" logic. That is, the code that displays the menu, allows the player to select units, and command them, then tells the unit game objects what to do given the player input. The best way I could thing of handling this was using a big state machine, so everything that could be done in a "turn" is handled by this state machine, and the update code of this state machine does different things depending on the state.

This approach, though, leads to a large amount of code (anything not model-related) to go into a big class. Of course I can subdivide this big class into more classes, but it doesn't feel modular and upgradable enough. I'd like to know of better systems to handle this in order to be able to upgrade the game with new rules without having a monstruous if/else chain (or switch / case, for that matter).

So, any ideas? I'd also like to ask that if you recommend me a specific design pattern to also provide some kind of example or further explanation and not stick to "Yeah you should use MVC and it'll work".

© Game Development or respective owner

Related posts about design-patterns