A mixin object for ILogic that makes true or false decisions. There are certain types of logic decisions the game that often require a set of criteria to be fulfilled, in order for that logic to be evaluated as true (or false). However, there is always the possibility that a plugin module might have a reason to further restrict or expand on a particular logic decision. The LogicBooleanMixin class allows this to take place.
The class LogicBooleanMixin is a BaseMixin-derived template class that takes a bool value as its one template parameter. When the LogicBooleanMixin class is called upon to make a decision (via its Decide function), it iterates through all of the mixin string names stored in BaseMixin’s hash map. Each of these string names must be the name of a piece of ILogic in the RuleEngine. The LogicBooleanMixin class goes through the mixed-in ILogic, calling each via the RuleEngine. As soon as one of them returns a value that is the opposite of the boolean template parameter, the LogicBooleanMixin class immediately exits with that value. If all mixed-in ILogic passes, the boolean template value is returned.
This is all rather abstract, so here’s an example. Let’s say it’s the beginning of the game and players are placing initial settlements down. Well, there are some well-known rules for where settlements can and can’t go (like not within one corner of another settlement, not ON another settlement, etc.). When the game needs to draw available spots for settlements on the board, it needs some way of removing every spot that is illegal to place on. The perfect situation for LogicBooleanMixin! The game can just assume that every hex corner is a valid location for a settlement, unless proven otherwise. It is up to the LogicBooleanMixin to prove otherwise. So, in actuality, the <LogicPlaceInitialSettlement> class inherits from LogicBooleanMixin with a the template bool parameter set to true. When the Decide function is called for the class, the LogicBooleanMixin kicks into action. It iterates through each of the mixed-in hex-corner-deciding ILogic. Each mixed-in ILogic examines the hex corner it is given and, if it violates that logic, return false, in which case the LogicBooleanMixin returns false for that hex corner, and it cannot be built on.
Derived From
Logic BaseMixin
Project
RulesCore
Include
LogicBooleanMixin.h
Summary
| A mixin object for ILogic that makes true or false decisions. |
| |
| |
| Renders the boolean decision. |
| |
| |
| Returns the rendered decision of the mixed-in ILogic. |