A turn-based game has one rule every player depends on and no player can enforce alone: whose turn it is. The session holds that rule. Players submit moves to the session, the session accepts or refuses them, and it tells the other players what was played.
GameLobbyFacade is provided in the starter code. Implement the types it uses: the GameMediator contract, the Player colleague, and the GameSession concrete mediator (IGameMediator in C#).
GameMediator exposes play(player, move), which returns the session's answer.Player(name, mediator) exposes getName(), makeMove(move), which delegates to the mediator and returns its answer, plus inform(line) and log().GameSession exposes join(player), start(), leave(player), currentTurn() and playerCount(), and implements the contract.The session behaves as follows:
join adds a player in join order and returns true. A duplicate object, or any join after the start, returns false.start returns true once there are at least two players and the game has not started. Otherwise it returns false.play returns "NOT_STARTED" before the start, "ENDED" after the game has ended, and "NOT_YOUR_TURN" when the mover is not the current player. Otherwise it informs every other player with "<name> played <move>", passes the turn to the next player in join order, wrapping from the last to the first, and returns "OK".leave removes the player and returns true, or false for a player not in the session. After the start, a session left with fewer than two players ends. Otherwise the turn stays with the same next player: when the leaver was the current player, the player after them is now current.currentTurn returns the current player's name, or "NONE" before the start and after the end.The provided GameLobbyFacade exposes this API:
GameLobbyFacade() creates an empty session.boolean join(String name) creates a player and joins them, returning the session's answer. An empty or duplicate name returns false.boolean start(), String currentTurn() and int playerCount() delegate to the session.String play(String name, String move) has that player make the move and returns the answer, or "UNKNOWN" for a name not in the lobby.boolean leave(String name) removes that player from the lobby and the session.String[] log(String name) returns what that player has been told, oldest first, or an empty array for an unknown name.The tests call the provided GameLobbyFacade; your work should be confined to the mediator contract, the player, and the session.
Input:
Output:
Explanation: The first player to join moves first. The second player's early attempt is refused, and the accepted move is announced to everyone except the mover.
Input:
Output:
Explanation: Three players take turns in join order and the turn wraps back to the first. Each player's log holds only the moves made by others.
0 <= name.length <= 20 and 1 <= move.length <= 106 players join one session.100 calls in total are made across all methods.Implement the GameMediator contract, the Player colleague, and the GameSession mediator. GameLobbyFacade is complete and must not be modified.
Full marks when `GameSession` alone tracks the turn and `Player.makeMove` does nothing but delegate to it, so no player can move out of turn or inform another player directly. Lose points heavily when players hold references to each other or a player decides for itself whether it may move.
Full marks when the turn passes in join order and wraps, and a player leaving keeps the turn on the same next player whether the leaver was before, at or after the current index. Lose points when a departure skips a player or makes the index point past the end.
Full marks when `join` is refused after the start, `start` needs two players and happens once, a session with fewer than two players after the start is ended, and `play` answers `NOT_STARTED`, `ENDED` or `NOT_YOUR_TURN` in that order of checks. Lose points for printing to stdout.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new GameLobbyFacade() | null |
| join("a") | true |
| join("b") | true |
| start() | true |
| currentTurn() | "a" |
| play("b", "x") | "NOT_YOUR_TURN" |
| play("a", "e4") | "OK" |
| currentTurn() | "b" |
| log("b") | ["a played e4"] |
| log("a") | [] |
The first player to join moves first. The second player's early attempt is refused, and the accepted move is announced to everyone except the mover.
Run checks these cases. Submit also runs a larger hidden set.

