I've just started making a Turn Based Strategy engine in GameMaker's GML language... And I was cruising along nicely until it came time to handle the turn cycle, and determining who is controlling what player, and also how to handle the camera and what is displayed on screen.
Here's an outline of the main switch happening in my main game loop at the moment:
switch (GameState)
{
case BEGIN_TURN:
// Start of turn operations/routines
break;
case MID_TURN:
switch (PControlledBy[Turn])
{
case HUMAN:
switch (MidTurnState)
{
case MT_SELECT:
// No units selected, 'idle' UI state
break;
case MT_MOVE:
// Unit selected and attempting to move
break;
case MT_ATTACK:
break;
}
break;
case COMPUTER:
// AI ROUTINES GO HERE
break;
case OBSERVER:
// OBSERVER ROUTINES GO HERE
break;
}
break;
case END_TURN:
// End of turn routines/operations, and move Turn to next player
break;
}
Now, I can see a couple of problems with this set-up already... But I don't have any idea how to go about making it 'right'. Turn is a global variable that stores which player's turn it is, and the BEGIN_TURN and END_TURN states make perfect sense to me... But the MID_TURN state is baffling me because of the things I want to happen here:
If there are players controlled by humans, I want the AI to do it's thing on its turn here, but I want to be able to have the camera follow the AI as it makes moves in the human player's vision.
If there are no human controlled player's, I'd like to be able to watch two or more AI's battle it out on the map with god-like 'observer' vision.
So basically I'm wondering if there are any resources for how to structure a Turn Based Strategy engine? I've found lots of writing about pathfinding and AI, and those are all great... But when it comes to handling the turn structure and the game states I am having trouble finding any resources at all. How should the states be divided to allow flexibility between the players and the controllers (HUMAN, COMPUTER, OBSERVER)?
Also, maybe if I'm on the right track I just need some reassurance before I lay down another few hundred lines of code...