When we get to implementing the game logic for 0.1, and future revisions, there are a lot of constants that will need to be defined someplace.
For example: Initial population for new colonies, production numbers, ratios for starlane/non-starlane movement, etc etc
I've already got one of them, the initial colony population, as a constant declared in order.cpp, but I really dont want it to stay there.
These "rule-constants" would be cumbersome and difficult to change if we had their definitions scattered all over the code. Therefore, I propose we create a singleton class to centralize all of the rules in a single location.
The idea is that whenever you need one of these 'rule constants', you add it to the rules file, and update the rule manager class, adding accessors and data members for the constant. This way, all the rules are centralized in an external location, they're easy to change, and we're all getting at them the same way.
I've already specced out a class definition:
* GameRuleSet is a singleton class to manage all of the various
* game parameters which should be constant during a game, but which
* we may wish to change or tweak. This includes things like
* default population levels in a colony, production numbers,
* default ship speeds, and the like. Any constant values pertaining
* to the rules of the game should be accessed through this class
/// Instance method -- this guy's a singleton
static GameRuleSet& instance();
/// Method to read game rules from a rule file.
* This method will read the specified rule file and obtain data
* for all of the game rule constants.
* The method should throw an std::runtime_error if any problems occur
void LoadRuleFile(const std::string& filename);
/// Returns the default initial population level for a new colony
int InitialColonyPop() const;
/// Constructor - initializes all members
* Initializes all member variables to some meaningless default value
* (like 0 or NULL). LoadRuleFile() should be called at game-start
* to read actual values from a configuration file.
/// default initial population for a new colony (amount of ppl carried on colony ship)
Add any other rule related constants that we need. Candidates are
default planet population caps, default ship speeds, offroad vs starlane ratio
etc etc etc