How should I structure the implementation of turn-based board game rules?

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/19 16:31 UTC
Read the original article Hit count: 183

Filed under:
|

I'm trying to create a turn-based strategy game on a tilemap.

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

However, this approach leads to a large amount of code (anything not model-related) going 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).

Any ideas? What specific design pattern other than MVC should I be using?

© Game Development or respective owner

Related posts about design-patterns

Related posts about turn-based