I don't like how there is currently so much duplication between tags. Like for everything that a tag might change on a city, there is one tag on a building, the same on a trait and a civic.
The software architecture also splits that code in a hard coded way to many different functions where it is mixed in between a lot of other information (and as a result we have some large monster classes).
What I would like to introduce to change that is the Effect System. An effect is a class that inherits from an abstract base class a specific interface which includes virtual functions that are called when the effect begins, when the effect ends and one that is called once per turn. Also functions for reading its parameters from XML and both writing and reading to streams for savegame and cache. Finally a display function that generates info text about the effect and an AI value function (there might be more, tbd).
An effect specifies what kind of game object it applies to. So an effect might apply to cities which means that if the XML adds that effect to a trait, then all the cities of that player will get the effect.
Each effect class registers a singleton factory class for itself at a central registration with a tag name associated and gets an ID assigned that way (which is used for storing it in streams and remapping savegames).
All tags in XML info classes that support the effect system will be scanned if they fit to any of the registered effects and if they do the effect XML will be read and an instance of the effect class added to an array in the info class.
Application of an effect to a game object (e.g. a city) can be one time (just do something the moment it is applied), temporary (a certain number of turns) or bound to how long the game object modifier (e.g. a building) the effect was defined on is active.
This is only a concept at the moment. No code has been written yet.
What do you think?
Would you help with the implementation of the system, use it to implement effects or use it in XML?
The software architecture also splits that code in a hard coded way to many different functions where it is mixed in between a lot of other information (and as a result we have some large monster classes).
What I would like to introduce to change that is the Effect System. An effect is a class that inherits from an abstract base class a specific interface which includes virtual functions that are called when the effect begins, when the effect ends and one that is called once per turn. Also functions for reading its parameters from XML and both writing and reading to streams for savegame and cache. Finally a display function that generates info text about the effect and an AI value function (there might be more, tbd).
An effect specifies what kind of game object it applies to. So an effect might apply to cities which means that if the XML adds that effect to a trait, then all the cities of that player will get the effect.
Each effect class registers a singleton factory class for itself at a central registration with a tag name associated and gets an ID assigned that way (which is used for storing it in streams and remapping savegames).
All tags in XML info classes that support the effect system will be scanned if they fit to any of the registered effects and if they do the effect XML will be read and an instance of the effect class added to an array in the info class.
Application of an effect to a game object (e.g. a city) can be one time (just do something the moment it is applied), temporary (a certain number of turns) or bound to how long the game object modifier (e.g. a building) the effect was defined on is active.
This is only a concept at the moment. No code has been written yet.
What do you think?
Would you help with the implementation of the system, use it to implement effects or use it in XML?