I think I have a bad design.
I’d appreciate some pointers or directions on how to evolve this design.
This game is a port of a hex-based board-game. It’s a pretty complicated board game (400 pages of rules) with 1000’s of different units, many with LOTs of special case rules. My code is in C++ and using Allegro as well (although that is pretty hidden in my design, I could swap that out if I wanted too)
At a high level I have a class for the game itself which includes the core variables about game state, maps of all the core game elements and pointers to the major core steps.
There are classes for each of the core game elements (players, units, fleets, planets, etc.). As previously mentioned the actual instances of these elements are in their own std::maps in the core game class.
For each major phase of the game (economics step, production step, etc…) there is a class which contains all relevant information for that
step (screen initializations, game logic for that step, listeners for input, etc.). There is a pointer to the instance of each of these in the core game class.
From a GUI standpoint, anything that needs to put something on the screen (or for that matter interact with the human player) calls a GUIFactory class, which in turn calls classes for the various screen elements (button,image, dropdown, etc.). I’ve further broken it out that those classes call a separate library of classes for actually rendering.
My class hierarchy is pretty flat for the core elements, although there is quite a bit of inheritance going on the GUI side (some layers are from the library though).
Anyway it does work…it’s just I’m barely scratching the surface on the rules/game content that I need to create and its feeling fragile/difficult to maintain already. And I haven’t even looked at some of things I know I need to tackle like network play or if I wanted to make an AI player. Maybe I have done it “right” and it’s just a complicated game…but before I get too much further I thought I’d ask the experts.
Clearly this isn’t enough information for you to redesign it for me…because I don’t want you too…I want to do it [learn better that way]…but
some pointers on how I should be thinking about this would be appreciated.
Happy to post code if you need a better explanation.