/// <summary> /// Creates a new game room with the selected gameType /// </summary> /// <param name="_gameType"></param> public void CreateGameRoom(GameType _gameType) { try { GameRoom gameRoom = new GameRoom(_gameType, this); GamesArena.AddGameRoom(gameRoom); GamesHistoryRepository.AddGameHistory(gameRoom.GameID, ID); CurrentGameRoom = gameRoom; } catch (Exception) { throw new Exception("Something Went Wrong. Support Code: 1223"); } }
/// <summary> /// adds palyer to existing game room using room code /// </summary> /// <param name="RoomCode"></param> public void JoinGameRoom(string RoomCode) { try { if (!(CurrentGameRoom is null)) { ExitGameRoom(); } GameRoom gameRoom = GamesArena.GetGameRoom(RoomCode); gameRoom.AddPlayer(this); GamesHistoryRepository.AddGameHistory(gameRoom.GameID, ID); CurrentGameRoom = gameRoom; } catch (Exception) { throw; /*new Exception("Something Went Wrong. Support Code: 1443");*/ } }
/// <summary> /// gets a datatable of user's games history /// </summary> /// <returns>DataTable of Game history details</returns> public DataTable MyHistory() => GamesHistoryRepository.GetGamesHistory(ID);