Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

TRuleSystem Class Reference

Stores information about the game rules. More...

#include <rulesystem.h>

List of all members.

Public Methods

bool checkDependencies ()
TFleetcreateFleet () const
TItemcreateItem (int2 type) const
TRacecreateRace () const
TSystemcreateSystem () const
TRuleAtomfetchRule (const string &ruleName) const
const list< TRuleSystem::tError > * getErrorList () const
string getModule (const string &module) const
bool getStatus () const
bool load (TDataPackageList *in)
void reset ()
bool save (TDataPackageList *out) const
bool setModule (const string &module, const string &rule)
bool setRuleAtom (const string &rule, const string &ruleset)

Static Public Methods

TRuleSystem & instance ()

Protected Methods

 TRuleSystem ()

Private Attributes

list< tErrorfErrorList
map< string, string > fModules
map< string, string > fRules
bool fVerified


Detailed Description

Stores information about the game rules.

Author:
Marco Krohn, <marco.krohn@gmx.de>
Version:
Id:
rulesystem.h,v 1.16 2002/06/05 00:34:18 mkrohn5 Exp

FIXME

what are rules, modules?

Singelton, reset => set rules, modules => check dependencies => you can ask for rules etc.


Constructor & Destructor Documentation

TRuleSystem::TRuleSystem   [protected]
 

Calls calls reset.

Note: The constructor is protected to ensure that there is exactly one instance of this class available.

See also:
instance


Member Function Documentation

bool TRuleSystem::checkDependencies  
 

Call this method to find out if all rule atoms and modules play nicely together or not and to find out if all neccessary information was provided. (Some rule atoms might need special modules to work properly). This check was introduced to make mixing different rule systems possible without crashing the game. A successful check of the dependencies sets fVerified to true.

Returns:
The new value of fVerified.
See also:
getErrors

TFleet* TRuleSystem::createFleet   const
 

Creates an empty fleet depending on the game rules (e.g. TFleetBasic, TFleetSL, TFleetStars). Note: The fleet is not added to the galaxy (see TGalaxy::Add). Also note that the caller is in charge of deallocation!

Returns:
A new fleet or 0 if an error occured.
See also:
TFleet

TItem* TRuleSystem::createItem int2    type const
 

Creates an item depending on the itemtype. Possible item types are described in TItem. Note that the caller is in charge of deallocation!

Parameters:
itemtype  The type of the item (see TItem::tItemType for details)
Returns:
A new item or 0 if an error occured.
See also:
TItem

TRace* TRuleSystem::createRace   const
 

Creates an empty race depending on the game rules (e.g. TRaceBasic, TRaceSL, TRaceStars). Note that the caller is in charge of deallocation!

Returns:
A new race or 0 if an error occured.
See also:
TRace

TSystem* TRuleSystem::createSystem   const
 

Creates an empty system depending on the game rules (e.g. TSystemBasic, TSystemSL, TSystemStars). Note: The system is not added to the galaxy (see TGalaxy::Add). Also note that the caller is in charge of deallocation!

Returns:
A new system or 0 if an error occured.
See also:
TSystem

TRuleAtom* TRuleSystem::fetchRule const string &    ruleName const
 

Looks up a specific rule (please see TRuleAtom for more information and example code).

Parameters:
ruleName  The name of the rule e.g. "fleet movement".
Returns:
Either the searched rule or 0 if the rule does not exist. Note that the caller is in charge of deallocation!
See also:
TRuleAtom

const list<TRuleSystem::tError>* TRuleSystem::getErrorList   const
 

Returns:
The list of errors created by the last checkDependencies call.

string TRuleSystem::getModule const string &    module const
 

Parameters:
module  The name of the module e.g. "system", "fleet", ...
Returns:
The used rules for that module, or there is nothing defined yet.
See also:
setModule

bool TRuleSystem::getStatus   const
 

Returns:
the value of fVerified.

TRuleSystem& TRuleSystem::instance   [static]
 

Returns:
The unique instance of TRuleSystem.

bool TRuleSystem::load TDataPackageList   in
 

Loads a TRuleSystem object. Note that you have to call checkDependencies after loading on your own and also note that this method triggers a call to the reset method.

Parameters:
in  The list of data packages.
Returns:
true means that everything was loaded correctly, otherwise this method will return false.

void TRuleSystem::reset  
 

Sets the modules and the rule atoms to the default value: NONE. Especially this means that fVerified is set to false and therefore you have to call checkDependencies in order to get any rules. You should know what you are doing! Use with care!

bool TRuleSystem::save TDataPackageList   out const
 

Saves a TRuleSystem object by adding the data packages to the list.

Parameters:
out  The output stream of data packages.
Returns:
true means that everything was saved correctly, otherwise this method will return false.

bool TRuleSystem::setModule const string &    module,
const string &    rule
 

Sets the used rule set for a module. Note that no dependency check is done (see checkDependencies) and also note that you have to check dependencies again after calling this method.

Parameters:
module  The module e.g. "fleet", "race", ...
rule  The used rule set for that module e.g. "basic", "stars", ...
Returns:
true means the change was accepted, otherwise false.

bool TRuleSystem::setRuleAtom const string &    rule,
const string &    ruleset
 

Sets the used rule set for a rule atom. Note that no dependency check is done (see checkDependencies) and also note that you have to check dependencies again after calling this method.

Parameters:
rule  The rule atom (e.g. "fleet movement").
ruleset  The used rule set for that rule set e.g. "basic", "stars", ...
Returns:
true means the change was accepted, otherwise false.


Member Data Documentation

list<tError> TRuleSystem::fErrorList [private]
 

List of errors from the last check dependencies call

map<string, string> TRuleSystem::fModules [private]
 

Stores which version of a module (e.g. fleet, race, etc.) is used

map<string, string> TRuleSystem::fRules [private]
 

Stores which rule system for the rule atoms are used in this game

bool TRuleSystem::fVerified [private]
 

Stores the information if all rule atoms / modules play nicely together or not. true means everything is o.k., while false means that it either wasn't checked, or that there is some conflict in the rule system.

See also:
checkDependencies


The documentation for this class was generated from the following file:
Generated on Thu Jun 20 18:13:30 2002 for Stellar Legacy by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001