# Defines the protocol for the CaptureTheFlag packets. # The first line is a String by which the packets will be referred. # The remaining lines are the contents of the packet. # Internal packet syntax (comma delimited) # CTFS,Version=,Time=,Type=,=,=,...\n # Data types # byte - a single unsigned byte # int - a signed integer (4 bytes / 32 bits) # char - a single character # string - a string (encoded as a byte length then that many characters) # ----- Constants ----- CONST VERSION : 9 # ----- Packets that are generally sent from clients to the server ----- # Sign in to the server or change username. SignIn PlayerName : string # The new name of the player. # Create a new game on the server (and join it). CreateGame Width : byte # The width of the game board. Height : byte # The height of the game board. Teams : byte # The number of teams in the game. Players : byte # The number of players per team. Flags : byte # The number of flags. Seed : byte # The random seed that generates the board (0 will use system time). # Create a specific pre-programmed scenario. CreateScenario Scenario : string # The assignment the scenario is for. # Create a tournament game. CreateTournament Seed : int # The random seed, set to 0 for a random game. # Create a very long tournament game. CreateLongTournament Seed : int # The random seed, set to 0 for a random game. # List all of the scenarios that are currently available on the server. ListScenarios # List all of the players that are currently available on the server. ListPlayers # Join a game belonging to the given player name. JoinGame Opponent : string # The game ID to join. # Request the game state of the game you are currently in. RequestGameState # Make a move on the game you are currently playing. # Move format: {Source x}x{Source y}-{Destination x}x{Destination y};... # ie: 1x2-1x3;3x4-3x5 will move (1, 2) to (1, 3) and (3, 4) to (3, 5) # All indicies are 0 based. # # Alternatively, you can send "Unsolvable" as the move string. # If you are correct, you win. # If you are incorrect, you lose. MakeMove Move : string # The move string (see above). # Request the number of remaining flags. RemainingFlags Count : int # The number of flags remaining in the game (uncaptured). # Request scores from the server. RequestScores # Set the game to always refer to you as player 0. SetConstantPlayer # Ask the game for the elapsed time for each player (in ms). RequestElapsedTime Player : string # The player you want to know the time for. # ----- Packets that are generally sent from the server to clients. ----- # The action that you requested was completed successfully. Success Origial : string # The timestamp from the original message. # The action that you requested was not completed successfully. Fail Original : string # The timestamp from the original message. Reason : string # The reason that the action failed. # A player has been added to the game you are currently in. PlayerAdded PlayerName : string # The name of the new player added to the game. # Returned when a player requests a game state. # # The game state arry may contain the following objects: # - = empty space # W = wall # X = a currently unowned flag # a-j = a player (player a=0, b=1, ...) # A-J = a player holding a flag (player A=0, B=1, ...) # 0-9 = a base GameState Width : byte # The width of the game board. Height : byte # The height of the game board. State : string # The game board objects (loop across x, then across y) # Returned when a client requests the scenario list. ScenarioList List : string # A semicolon delimited list of possible scenarios. # Returned when a client requests the list of players on the server. PlayerList List : string # A semicolon delimited list of players. # A move was made by another player. MoveMade PlayerID : byte # The ID of the player that made the move (from 0 to 9). MoveString : string # The successfully sent move. # Sent to a player when it is their turn to make a move on their current game. YourTurn PlayerID : byte # The ID of the player (from 0 to 9). Width : byte # The width of the board. Height : byte # The height of the board. State : string # The game board objects (see GameState) # Sent to a player when a game is over. GameOver Winner : string # The player that won the game. # Sent when a player requests scores. Scores ScoreList : string # A semicolon delimited list of scores (your score is first). # The elapsed time for each player. ElapsedTime Player : string # The player who this time belongs too. Time : int # The time spent (in ms).