Introduction
The Orderer class has one job: Determine the order of attacks. Combat provides three customized orderers: NoOrder , RandomOrder , and InitOrder .
The Orderer object can take keyword,value pairs when creating an instance of the Orderer. These can also be passed directly from the CombatManager.setOrderer method.
The BaseOrderManager Class
All Orderers are subclasses of the BaseOrderManager . There are two important methods:
loadcombatants (combatantlist)
The CombatManager calls this automatically in the setOrderer method of the CombatManager class.
neworder
This method returns a list of combatants in some specific order. This is the method to overwrite when creating an Orderer
addlog (s)
Adds the string to the log list. This is used for writing up play-by-plays of fights
dumplog
Returns the log as a list of strings. This is used in the play-by-play generation
Predefined Orderers
There are three Orderers available in Combat.
NoOrder
This is actually the same as BaseOrderManager . The order of combatants it returns is the same order that combatants were passed to the CombatManager
RandomOrder
The neworder method returns the list of combatants in a random order, using the shuffle method from the random module.
InitOrder (roll,att)
The neworder method uses DieRoller string passed by ‘roll’ and adds the value of the combatant attribute specified by ‘att.' The default roll is ‘d20’ and the default attribute is ‘speed’. This determines a new order each turn, as in the older D&D system.
Future Plans
Here are a few ideas I have about the next revision:
- The new D&D rules (3.0+) has all combatants roll initiative once and the combat order is set until the end of combat. I will add this in the next revision.