Stratego game:


Client Frames (Frame Types 1-4):
1- Sign On Frame
Payload: Username (String)
2- Setup Frame
Payload: Location of Piece (Piece Id (char), x-Coordinate (int), y-Coordinate (int))
Piece IDs: (1-9 for ranked piece, “F” for flag, “B” for bomb, and “S” for spy)
Coordinate System: 0-9 for X and Y, server uses a 10x10 grid, first player occupies
3- Ready Frame
Client acknowledges that they are finished placing their pieces and is ready to begin playing .
Payload: (“ready” String)
4- Move Frame
Location of piece to be moved and location to move to. If the location is occupied by the enemy, the server recognizes that a battle occurs.
Payload: 4 ints (x,y origin + x,y target)
Server Frames (Frame Types 1-9):
1- Wait Frame
If no other player is connected server tells client to wait
Payload: (“wait” String)
2- Connected Frame
Server tells client that another player is there, this frame begins the setup phase Payload: (“connected” String)
3- Placement Valid Frame
Server acknowledges that the user’s piece placement is valid
Payload: (“valid” String)
4- Placement Invalid Frame
Server tells client that the piece placement is invalid
Payload: (“invalid” String)
5- Playing Frame
Both setups have been received; playing phase begins
Payload: (username of first turn player String)
6- Move Frame
Tells both clients where the player has moved
Payload: 4 ints (x,y origin + x,y target)
7- Board Frame
Sends the entire game board to a player with the identities (chars) of their pieces revealed and the locations of the opponent’s unidentified pieces (represented by a standard char value).
Payload: 100 chars, following the sequence (0,0) (1,0) (2,0) …(100,100). The x-value is the column number and the y-value is the row number.
8- Move Invalid Frame
Tells client that move was not accepted
Payload: (String “invalid move”)
9- Battle Frame
Server tells client which piece won the battle or if a tie occurred
Payload: (String “tie” or username of winner + (char)Piece Id of attacker + (char)Piece Id of defender)
10- Game Over Frame
Server tells client which user won
Payload: (String username)
Protocol:
1. First user sends Sign on Frame.
2. Server sends Wait Frame.
3. Second user sends Sign On Frame.
4. Server sends Connected Frame to both users.
5. Both users send piece placements (Setup Frames).
6. Server sends Placement Valid Frame or Placement Invalid Frame after each placement.
7. After placement is finished, users send Ready Frames.
8. Server sends Playing Frame and Board Frame when both players are ready.
9. Moves are sent from user (Move Frame) to Server.
10. Server keeps track of turns and sends Move Invalid Frame if player sends a Move Frame out of turn or move is invalid
11. Server sends other both players the valid move or a battle result if necessary (Move Frame or Battle Frame).
12. After each move or battle the Server sends each player a Board Frame so that each player sees the updated board.
13. Once a user has won Game Over Frame is sent.

**Referred to protocol posted on Cytron's website