Here is how the game logic is structured in Goblinson Crusoe. It isn't exactly what you are looking for, but it might give you some things to think about.
1) At the beginning of the round, check to see if our turn-list is empty. If it is empty, pump out a request to all combat objects. The request is for a packet of information including:
a) Are you alive?
b) Are you interested in participating this round?
c) What is your faction?
2) Iterate the list returned from the request above. Check to see if there is at least one player-controlled object in the list. If not, it indicates a loss condition. Then, iterate and see if there is at least one hostile enemy combatant in the list. If not, it indicates a victory condition. Otherwise, continue.
3) Initiative determination. Compile a list of all participating combatants and, based on haste modifiers, roll for initiative. Insert them into a list sorted by order of their initiative rolls, re-rolling to break any ties as needed.
4) Check to see if we have a currently active object. If we don't, pull the next object off the turn list compiled above.
5) (If we have a new combatant) Send the combatant a BeginCombatTurn message. This message in effect passes a "token" to the object, indicating that the object is free to move. If it is an AI controlled object, this pulls the AI out of its Wait state and into an Active state. If it is a player object, this passes a message to any linked UI components telling them to activate and show themselves. These UI components are "owned" by the object; that is, each player object has an instance of PlayerUI that is customized to their own individual settings and characteristics. (Siege machinery has a different UI than the player character, etc...) During BeginCombatTurn, the number of movement points to be allocated to the object is passed.
6) (If we already have an active combatant) Pass a CombatUpdate message. For Player objects, this merely checks to see if there is anything in the Command Queue for that object (list of steps to take, attacks to make, etc....) whereas for AI objects it checks to see if the command queue is empty and, if so, calls Think() on the AI controller. Think() will evaluate the current situation based on certain criteria, and attempt to come up with a reasonable set of commands to place in the queue.
7) While an object has movement points and chooses not to Pass, call CombatUpdate.
8) For Player characters, the UI is used to gather input and generate commands for the command queue. Any input action done while an object's UI is active is screened and tested for validity, then used to push commands onto the queue. UI generates a Move command? Call the pathfinder, validate the path, and push the steps onto the queue.
9) CombatUpdate checks the command queue, as indicated, and if there are pending actions it will pull an action off the queue and execute it. If it is a movement command, then TakeStep is called on the combatant controller to move the unit in the given direction. If it is a spell-cast command, then another sequence of steps are executed.
10) When CombatUpdate is called and the queue is empty, and the controller either elects to Pass or hasn't enough movement points to do anything, then the object will de-activate itself so that when, at step 4 above, we check to see if we have an active object, the answer will now be false and the scheduler will move on to the next object. At this point, pass the object an EndCombatTurn message. This de-activates any UI (for player objects) and places any AI controllers in a suspend state.
All of this continues in progression until step 2 indicates a victory/loss condition.
Basically, at heart, it's just a token-passing system. Pass the "Active" token to each object in turn, and when they are done with it hand it on down the line. Exactly how you structure this, though, is really dependent upon your game.
Edited by JTippetts, 09 February 2013 - 04:51 PM.