public bool IsPlayerReachedExit(string playerId) { MultiPlayerGame game = this.playerToGame[playerId]; Position goalPos = game.Maze.GoalPos; Position curPos = game.GetPlayer(playerId).Location; return(goalPos.Row == curPos.Row && goalPos.Col == curPos.Col); }
public string Play(string direction, string playerId) { if (!playerToGame.ContainsKey(playerId)) { // Player tried to move although he is not participate in any game. throw new Exception("Player is not in a game, need to be in a game to play"); } // Find the player-info of the player. MultiPlayerGame game = playerToGame[playerId]; PlayerInfo playerInfo = game.GetPlayer(playerId); // Update the player location. bool validMove = playerInfo.Move(game.Maze, direction); if (!validMove) { // The direction of the player was invalid. throw new Exception($"Invalid Direction '{direction}'"); } return(game.Maze.Name); }