/// <summary> /// Starts a new game. /// </summary> /// <param name="rules">The rules of the game.</param> /// <param name="player1Name">The name for player 1.</param> /// <param name="player2Name">The name for player 2.</param> /// <returns>The Game Session Id.</returns> public static string StartGame (GameRules rules, string player1Name, string player2Name) { Game game = new Game(rules, player1Name, player2Name); string gameSessionId = Guid.NewGuid().ToString(); m_games.Add(gameSessionId, game); return(gameSessionId); }
/// <summary> /// Creates an instance of the Game class. /// </summary> /// <param name="rules">The rules for the current game.</param> /// <param name="player1Name">The player one's name.</param> /// <param name="player2Name">The player two's name.</param> public Game(GameRules rules, string player1Name, string player2Name) { if (rules.GetMoves().Count < 1) { throw new ArgumentException(GameEngineMessages.CreateGameEmptyMovesError); } if ((string.IsNullOrEmpty(player1Name)) || (string.IsNullOrEmpty(player2Name))) { throw new ArgumentException(GameEngineMessages.PlayerNameEmptyError); } this.m_data = new GameData(); this.m_data.Player1Name = player1Name; this.m_data.Player2Name = player2Name; this.m_rules = rules; }