RuleSet

A repository of all things rules-related.  A RuleSet is an aggregate container that can hold the many types of objects needed to run a certain set of rules in the game.  A RuleSet can range in size from a single IRule for a very small variant, to dozens of IRules and ILogic, custom ImageSets, special BankData, PlayerData, or BuildData for the BankUI, PlayerUI and BuildUI, IDrawObjects, IGameObjects, and even an entire system of IRule branching logic for core game rules or an extensive variant, or anything in between.  Every RuleSet must have a unique name (within its plugin object), and a flag to indicate whether an AI is required for a computer to play with the RuleSet.

The plugin rule objects (.dlls on Win32, .so files on Linux), provide the RuleSets that the core application has access to.  A plugin object has its own <RuleSetDatabase> that stores all of the RuleSets until they are needed (if ever) by the core application.  The PluginEngine queries all plugins that it can find and keeps record of them.  Certain Maps require certain RuleSets in order to be played.  The core application is responsible for ensuring that all RuleSets that a given Map needs are loaded before the game begins or continues from a saved spot.  See PluginEngine, RuleEngine, and <RuleSetDatabase> for more details on how RuleSets are used throughout the game.

Derived From

RuleBase

Project

RulesCore

Include

RuleSet.h

Summary
A repository of all things rules-related.
The RuleSet constructor.
Returns the AI flag.
Provides an iterator to the start of the PriorityLogicHash hash.
Provides an iterator to the end of the PriorityLogicHash hash.
Provides an iterator to the start of the IGameObject hash.
Provides an iterator to the end of the IGameObject set.
Provides an iterator to the start of the IDrawObject set.
Provides an iterator to the end of the IDrawObject set.
Provides an iterator to the start of the ImageSet list.
Provides an iterator to the end of the ImageSet list.
Provides an iterator to the start of the BankData list.
Provides an iterator to the end of the BankData list.
Provides an iterator to the start of the PlayerData list.
Provides an iterator to the end of the PlayerData list.
Provides an iterator to the start of the BuildData list.
Provides an iterator to the end of the BuildData list.
The RuleSet copy constructor.
Adds a piece of branch logic to the rule chain.
Adds an IGameObject to the RuleSet.
Adds an IDrawObject to the RuleSet.
Adds an ImageSet to the RuleSet.
Adds a piece of BankData to the RuleSet.
Adds a piece of PlayerData to the RuleSet.
Adds a piece of BuildData to the RuleSet.
The name of this RuleSet.
Whether this ruleset requires an AI for it to played in single player mode.
The hash of rule branching logic.
The hash of IGameObjects the RuleSet provides.
The std::set of IDrawObjects the RuleSet provides.
The std::list of ImageSets the RuleSet provides.
The std::list of BankData in the RuleSet.
The std::list of PlayerData in the RuleSet.
The std::list of BuildData in the RuleSet.

Public

Summary
The RuleSet constructor.
Returns the AI flag.
Provides an iterator to the start of the PriorityLogicHash hash.
Provides an iterator to the end of the PriorityLogicHash hash.
Provides an iterator to the start of the IGameObject hash.
Provides an iterator to the end of the IGameObject set.
Provides an iterator to the start of the IDrawObject set.
Provides an iterator to the end of the IDrawObject set.
Provides an iterator to the start of the ImageSet list.
Provides an iterator to the end of the ImageSet list.
Provides an iterator to the start of the BankData list.
Provides an iterator to the end of the BankData list.
Provides an iterator to the start of the PlayerData list.
Provides an iterator to the end of the PlayerData list.
Provides an iterator to the start of the BuildData list.
Provides an iterator to the end of the BuildData list.

Constructors

RuleSet

RuleSet(const wxString &name,
bool needsAI)

The RuleSet constructor.  Sets the name and the AI flag.  The AI flag indicates to the system whether or not a RuleSet needs AI written for its rules in order for the computer to play with it or not.  For example, a RuleSet that simply alters the number of points the game is played to, or the number of stock cities, does not need an AI, but a RuleSet that adds a new tile type as a resource definitely needs an AI.

Parameters

nameThe name of the RuleSet.  Must be unique within the plugin object in which it resides.
needsAIThe AI flag.  See above notes.

Functions

needsAI

bool needsAI() const

Returns the AI flag.

Returns

A bool indicating if the RuleSet needs an AI for the computer to be able to play.  Set to true if yes, false, if no.

branch_begin

PriorityLogicHash::const_iterator branch_begin() const

Provides an iterator to the start of the PriorityLogicHash hash.

Returns

A const_iterator to the start of prioritized rule branching ILogic hash.

branch_end

PriorityLogicHash::const_iterator branch_end() const

Provides an iterator to the end of the PriorityLogicHash hash.

Returns

A const_iterator to the end of prioritized rule branching ILogic hash.

gameobjects_begin

GameObjectHash::const_iterator gameobjects_begin() const

Provides an iterator to the start of the IGameObject hash.

Returns

A const_iterator to the start of the hash map of IGameObjects in this RuleSet.

gameobjects_end

GameObjectHash::const_iterator gameobjects_end() const

Provides an iterator to the end of the IGameObject set.

Returns

A const_iterator to the end of the hash map of IGameObject in this RuleSet.

drawobjects_begin

DrawObjectSet::const_iterator drawobjects_begin() const

Provides an iterator to the start of the IDrawObject set.

Returns

A const_iterator to the start of the std::set of IDrawObjects in this RuleSet.

drawobjects_end

DrawObjectSet::const_iterator drawobjects_end() const

Provides an iterator to the end of the IDrawObject set.

Returns

A const_iterator to the end of the std::set of IDrawObjects in this RuleSet.

imagesets_begin

ImageSetList::const_iterator imagesets_begin() const

Provides an iterator to the start of the ImageSet list.

Returns

A const_iterator to the start of the std::list of ImageSets in this RuleSet.

imagesets_end

ImageSetList::const_iterator imagesets_end() const

Provides an iterator to the end of the ImageSet list.

Returns

A const_iterator to the end of the std::list of ImageSets in this RuleSet.

bankdata_begin

BankDataList::const_iterator bankdata_begin() const

Provides an iterator to the start of the BankData list.

Returns

A const_iterator to the start of the std::list of BankData in this RuleSet.

bankdata_end

BankDataList::const_iterator bankdata_end() const

Provides an iterator to the end of the BankData list.

Returns

A const_iterator to the end of the std::list of BankData in this RuleSet.

playerdata_begin

PlayerDataList::const_iterator playerdata_begin() const

Provides an iterator to the start of the PlayerData list.

Returns

A const_iterator to the start of the std::list of PlayerData in this RuleSet.

playerdata_end

PlayerDataList::const_iterator playerdata_end() const

Provides an iterator to the end of the PlayerData list.

Returns

A const_iterator to the end of the std::list of PlayerData in this RuleSet.

builddata_begin

BuildDataList::const_iterator builddata_begin() const

Provides an iterator to the start of the BuildData list.

Returns

A const_iterator to the start of the std::list of BuildData in this RuleSet.

builddata_end

BuildDataList::const_iterator builddata_end() const

Provides an iterator to the end of the BuildData list.

Returns

A const_iterator to the end of the std::list of BuildData in this RuleSet.

Private

Summary
The RuleSet copy constructor.
Adds a piece of branch logic to the rule chain.
Adds an IGameObject to the RuleSet.
Adds an IDrawObject to the RuleSet.
Adds an ImageSet to the RuleSet.
Adds a piece of BankData to the RuleSet.
Adds a piece of PlayerData to the RuleSet.
Adds a piece of BuildData to the RuleSet.
The name of this RuleSet.
Whether this ruleset requires an AI for it to played in single player mode.
The hash of rule branching logic.
The hash of IGameObjects the RuleSet provides.
The std::set of IDrawObjects the RuleSet provides.
The std::list of ImageSets the RuleSet provides.
The std::list of BankData in the RuleSet.
The std::list of PlayerData in the RuleSet.
The std::list of BuildData in the RuleSet.

Copy Constructor

RuleSet

RuleSet(const RuleSet &ruleset)

The RuleSet copy constructor.  Private and unimplemented because a RuleSet cannot be copied.

Functions

RegisterBranch

void RegisterBranch(const wxString &rule,
const wxInt32 priority,
const LogicPtr &logic)

Adds a piece of branch logic to the rule chain.  Branch logic is used to determine what IRule will follow after another IRule, when that kind of chaining is required.  (For instance, Rule0 at the start of the game might usually go into placing settlements, but for A New World maps, it should go into placing ports.)  Each piece of branch ILogic can have an associated priority number, and higher priority branch ILogic has precedence over lower numbered priority ILogic.  All pieces of branch ILogic should return a wxString of the next name of the IRule to execute, or an empty string if it cannot decide with the given data.

Parameters

ruleThe rule to branch after.
priorityThe priority of this piece of branch ILogic.  Higher priority numbers have precedence.
logicThe branch ILogic.

RegisterGameObject

void RegisterGameObject(const wxString &name,
const GameObjectPtr &object)

Adds an IGameObject to the RuleSet.  The IGameObjects are stored in a hash so that when loading a saved game from the disk, all IGameObjects can be instantiated correctly.

Parameters

nameThe name of the IGameObject.
objectThe IGameObject to add.

RegisterDrawObject

void RegisterDrawObject(const DrawObjectPtr &object)

Adds an IDrawObject to the RuleSet.  Any IGameObject that needs to be visually represented in the scene graph must have an IDrawObject that knows how to draw it.

Parameters

objectThe IDrawObject to add.

RegisterImageSet

void RegisterImageSet(const ImageSetPtr &imageset)

Adds an ImageSet to the RuleSet.  Some RuleSets might have their own bitmap data that they want to use as OpenGL textures or UI bitmaps.  By providing an ImageSet, the RuleSet allows any other IDrawObjects, BankData, or PlayerData that need the images access through the ImageEngine.

Parameters

imagesetThe ImageSet to add.

RegisterBankData

void RegisterBankData(const BankDataPtr &bankdata)

Adds a piece of BankData to the RuleSet.  See BankData for more details.

Parameters

bankdataThe BankData to add.

RegisterPlayerData

void RegisterPlayerData(const PlayerDataPtr &playerdata)

Adds a piece of PlayerData to the RuleSet.  See PlayerData for more details.

Parameters

playerdataThe PlayerData to add.

RegisterBuildData

void RegisterBuildData(const BuildDataPtr &builddata)

Adds a piece of BuildData to the RuleSet.  See BuildData for more details.

Parameters

builddataThe BuildData to add.

Variables

mNames

The name of this RuleSet.  Must be unique within its plugin object.

mNeedsAI

bool mNeedsAI

Whether this ruleset requires an AI for it to played in single player mode.

mBranchHash

PriorityLogicHash mBranchHash

The hash of rule branching logic.  See RegisterBranch above for more details.

mGameObjectHash

GameObjectHash mGameObjectHash

The hash of IGameObjects the RuleSet provides.

mDrawObjectSet

DrawObjectSet mDrawObjectSet

The std::set of IDrawObjects the RuleSet provides.

mImageSetList

ImageSetList mImageSetList

The std::list of ImageSets the RuleSet provides.

mBankDataList

BankDataList mBankDataList

The std::list of BankData in the RuleSet.

mPlayerDataList

PlayerDataList mPlayerDataList

The std::list of PlayerData in the RuleSet.

mBuildDataList

BuildDataList mBuildDataList

The std::list of BuildData in the RuleSet.

RuleSet(const wxString &name,
bool needsAI)
The RuleSet constructor.
bool needsAI() const
Returns the AI flag.
PriorityLogicHash::const_iterator branch_begin() const
Provides an iterator to the start of the PriorityLogicHash hash.
PriorityLogicHash::const_iterator branch_end() const
Provides an iterator to the end of the PriorityLogicHash hash.
GameObjectHash::const_iterator gameobjects_begin() const
Provides an iterator to the start of the IGameObject hash.
An interface for all game objects.
GameObjectHash::const_iterator gameobjects_end() const
Provides an iterator to the end of the IGameObject set.
DrawObjectSet::const_iterator drawobjects_begin() const
Provides an iterator to the start of the IDrawObject set.
The interface for objects that are drawn on screen.
DrawObjectSet::const_iterator drawobjects_end() const
Provides an iterator to the end of the IDrawObject set.
ImageSetList::const_iterator imagesets_begin() const
Provides an iterator to the start of the ImageSet list.
A repository of knowledge about a .tex file.
ImageSetList::const_iterator imagesets_end() const
Provides an iterator to the end of the ImageSet list.
BankDataList::const_iterator bankdata_begin() const
Provides an iterator to the start of the BankData list.
Describes a stack of cards to be drawn in the BankUI.
BankDataList::const_iterator bankdata_end() const
Provides an iterator to the end of the BankData list.
PlayerDataList::const_iterator playerdata_begin() const
Provides an iterator to the start of the PlayerData list.
Describes a piece of information that needs to be displayed in the PlayerUI.
PlayerDataList::const_iterator playerdata_end() const
Provides an iterator to the end of the PlayerData list.
BuildDataList::const_iterator builddata_begin() const
Provides an iterator to the start of the BuildData list.
RulesCore
BuildDataList::const_iterator builddata_end() const
Provides an iterator to the end of the BuildData list.
void RegisterBranch(const wxString &rule,
const wxInt32 priority,
const LogicPtr &logic)
Adds a piece of branch logic to the rule chain.
void RegisterGameObject(const wxString &name,
const GameObjectPtr &object)
Adds an IGameObject to the RuleSet.
void RegisterDrawObject(const DrawObjectPtr &object)
Adds an IDrawObject to the RuleSet.
void RegisterImageSet(const ImageSetPtr &imageset)
Adds an ImageSet to the RuleSet.
void RegisterBankData(const BankDataPtr &bankdata)
Adds a piece of BankData to the RuleSet.
void RegisterPlayerData(const PlayerDataPtr &playerdata)
Adds a piece of PlayerData to the RuleSet.
void RegisterBuildData(const BuildDataPtr &builddata)
Adds a piece of BuildData to the RuleSet.
bool mNeedsAI
Whether this ruleset requires an AI for it to played in single player mode.
PriorityLogicHash mBranchHash
The hash of rule branching logic.
GameObjectHash mGameObjectHash
The hash of IGameObjects the RuleSet provides.
DrawObjectSet mDrawObjectSet
The std::set of IDrawObjects the RuleSet provides.
ImageSetList mImageSetList
The std::list of ImageSets the RuleSet provides.
BankDataList mBankDataList
The std::list of BankData in the RuleSet.
PlayerDataList mPlayerDataList
The std::list of PlayerData in the RuleSet.
BuildDataList mBuildDataList
The std::list of BuildData in the RuleSet.
The interface for a single game rule.
The interface of a single piece of game logic.
Displays stacks of remaining bank cards.
Displays game information for one player.
Displays a possible action for the player.
The default implementation of the IPluginEngine interface.
Still volatile.
The default implementation of the IRuleEngine interface.
A common base class for RuleSet and AI.
RulesCore is the HOSS of Cities3D.
The standard implementation of the IImageEngine interface.