CRIBBAGEBBER PROTOCOL VERSION 0.1 C = Client CC = Control Client S = Server Individual messages are delmited by the newline character ('\n'). Newline will be translated to NUL in the server, so NULs are NOT permitted. Protocol goes over TCP. *"foo" indicates string "foo" is transmitted. If a word is bracketed by <>, this indicates a word will be substituted as described Client/server link moves through 4 phases: INTRODUCTORY PHASE: Client joins the game, if possible, or gets rejected. WAITING PHASE: Control Client specifies # of players; player waits for enough players to join. HAND SETUP PHASE: Client selects 1 or 2 cards (depending on #of players) to put into the crib PLAY-INACTIVE PHASE: Game is in the play portion, but client is currently NOT playing a card PLAY-ACTIVE PHASE: Game is in the play portion, and client IS currently playing a card COUNTING-INACTIVE PHASE: Game is in the point-counting phase, but client is NOT active. COUNTING-ACTIVE PHASE: Game is in the point-counting phase, and client IS active. ENDGAME: Game is ending, waiting for clients to disconnect or opt to play a new game. special phases: MUGGINS: A player has called muggins. PAUSED: Game is paused. Game is paused because a user has quit after INTRODUCTORY PHASE and before ENDGAME USERPAUSED: Game is paused because a user requested it. QUITTING: User has asked to quit, regardless of phase. This is the disconnect sequence. ERROR: Protocol error phase. Entered any time there was an egregious breach of protocol. This phase is just the server replying with a special phrase *"E: You Brute!". User is disconnected as though they had requested it. If client issues a command out of phase, server replies with *"WA: WRONGPHASE ()" where is the current phase. MESSAGES: During ANY PHASE EXCEPT ERROR and QUITTING, a client may issue the request: C: *"ME:" to send a message (not over 500 characters) to the other clients. the server will then post: C: *"ME:nickname/" to all players. During ANY PHASE, the control player may issue the request: CC: *"EJ:" to eject the player from the game. This is like had quit, EXCEPT that everyone is notified that CC ejected from the game (instead of quit" and the parting message is also different. INTRODUCTORY PHASE: Begins by client contacting server, moves to WAITING PHASE to wait for all players to join S: 2 options: 1) Game is currently running: *"E:GAME" link immediately closes 2) Game is not currently running: *"P:/" Protocol version is , one of the following: "0.1": CRIBBERGEBBER PROTOCOL VERSION 0.1 Variants are game variant flags, and are one of the following: D: deduct points if you call an unsuccessful muggins N: No muggins (antimuggins still works, but no points are awarded) C: *"IM:" [nickname is the nickname selected by the client's user] S: 2 options: 1) Game is not running yet; user IS NOT control player *"WE:" 2) Game is not running yet, and user IS control player (i.e. first to connect) *"CO:" Connection passes to the WAITING PHASE WAITING PHASE: We wait for all clients to connect; N (number of players) is specified. If the player IS the control player, client must specify N and the game variants in effect CC: *"NP:/" Once this occurrs, control player waits like a regular player EXCEPT that they MAY reissue the *"NP:/" request to change # of players/variants in effect If the player IS NOT control player, client waits. Server will state *"UD:WAITING", where M is the number of players yet to join everytime this number changes (including the initial time) Once N players have joined, server says: S: *"RE:" ("ready?") All players must state C: *"YE:" and we then move to the HAND SETUP PHASE. All valid commands will be accepted until this point, though you cannot un-agree once you're agreed. This means that the CP may still change the game rule flags. If you don't like it, you can still complain via messages, or quit. HAND SETUP PHASE: The server says S: *"SE:;/[/[/]];[]; indicating HAND SETUP PHASE is beginning; Y cards are to be put into the crib. Players are , etc. Cards are , and are spcified as a fixed 3-chars where is the card number, is the suit of the card, and is one of: 'H' (hearts), 'D' (diamonds), 'C' (clubs), 'S' (spades). is one of: 'A' (ace), the numbers 2-9, '0' (10), 'J' (Jack), 'Q' (Queen), 'K' (King). after the final semicolon is the dealer and consequently has the crib. The control player is the first dealer; subsequent loops move in order of joining the game (i.e. the players circle is filled dealer-leftwards starting with the dealer as players join. Players choose which card[s] to place into the crib. Server waits for Client to select card[s]. Client selects a card[s] to send to the crib by sending: C: *"CR:[] where is the card number of the card[s] user wishes to place in the crib. Server replies with S: *"DI:[] if this is OK; S: *"WA:BADCRIB()" if this is not OK; phase starts over. Server states S: *"UD:" during this phase when has placed their cards into the crib. when all clients have placed cards into the crib, server says: S: *"TO:" to specify that the top card is . We now move into PLAY metaphase. PLAY METAPHASE: The PLAY METAPHASE consists of the PLAY-ACTIVE and PLAY-INACTIVE phases. The user is in PLAY-INACTIVE and the server states: S: *"AC:" indicating that player is now active player. The active player plays a card with C: *"PL:/" and the server replies to ALL PLAYERS S: *"PL:/// to ALL players if this is OK (total is the player's total points right now; tally is the current tally/count to 31), or S: *"WA:BADPLAY()" to ONLY the ACTIVE PLAYER if this is an invalid play. After the player has played, any INACTIVE player may opt to "call muggins" by stating: C: *"MU:/" and the server sends S: *"MU://" to ALL PLAYERS, indicating the number of points being called, and who called it. We jump to the MUGGINS/ANTIMUGGINS phase to reconcile muggins Each player takes a turn as active player (unless they have no more cards to play this loop) or until no players have cards to play, the server asks all players if they're ready for the COUNTING METAPHASE Each player who's not called muggins on this play nor who played states that they're ready by stating C: *"AG:" else they must call Muggins. If Muggins succeeds, then we move to the COUNTING PHASE, else we go back to this ready-check [ended either when everyone non-mugginsy has agreed, or when everyone has called muggins or been the last player] COUNTING METAPHASE: Each player states how many points they have. As expected, counting starts from the left of the dealer. The server starts by stating: S: "H:/[] stating the player whose turn it is to count, and their hand. All other players are INACTIVE. The ACTIVE player registers its point total by stating: C: "CN:". The server replies by stating to ALL PLAYERS S: "CN://" ALL OTHER USERS must agree by stating C: "AG:" Otherwise, the OTHER USERS MUST call Muggins. Rules are the same as for the final play. When the COUNTING METAPHASE is complete, we loop back to the HAND SETUP PHASE. When the first player pegs 121 points, the game is over and we reset everything and move back to the HAND SETUP PHASE MUGGINS: Antimuggins is just like muggins, EXCEPT that it is for reconciling the fact that players can make mistakes of their own accord. Muggins/Antimuggins may be called in the PLAY, COUNTING, and ENDGAME phases. Muggins-check is the first action in the ENDGAME phase and may not be called at any other time there. In the MUGGINS phase, the server has stated S: *"M:/" indicating the number of points, and who called it. ALL OTHER users (i.e. all but the player who called muggins) must OK the motion, or the player is not given the points. [Possible variant: player is REDUCED points for a failed MUGGINS]. Players voice their opinion of whether or not the caller was right by stating: C: *"YE:" for "Yes, the caller was right" or C: *"NO:" for "No, the caller was wrong" Once all players have registered their vote, player point tallies are updated and play continues from where it left off. PAUSED: Since gameplay cannot change during a game, N must stay fixed. The control client MAY issue a *"N:" request at this time to go back to the WAITING PHASE. If not, we wait for a client to join to replace the former client. USERPAUSED: This is because a user issued the C: *"PA:" request at ANY TIME during COUNTING and PLAY metaphases. Any user may now unpause the game by issuing the C: *"UP:" request. Gameplay continues from where it was. INDEX OF SERVER STATEMENTS: *"PR:" :Sever speaks CRIBBERGEBBER PROTOCOL VERSION (very first statement when game is not in session) *"ER:GAME" :Error: game is in session *"WE:" :welcome user to the game *"CO:" :welcome control player to the game INDEX OF CLIENT REQUESTS: