/// <summary> /// Create new Game Session /// </summary> /// <returns></returns> public static GameMatch NewMatch(string gameId) { GameMatch newMatch; if (_RunningGames.TryGetValue(gameId, out newMatch) == true) { throw new InvalidOperationException("Game ID is not Unique"); } newMatch = new GameMatch() { GameId = gameId, }; _RunningGames.Add(gameId, newMatch); var hub = GlobalHost.ConnectionManager.GetHubContext <FailHub>(); hub.Clients.All.NewMatchCreated(GameMatch.AllOpenMatch().ToList()); return(newMatch); }
/// <summary> /// Submid Draw Command /// </summary> /// <param name="gameId"></param> public void SubmitVote(string gameId, int index) { GameMatch.ById(gameId).SubmitVote(index); }
/// <summary> /// Submid Draw Command /// </summary> /// <param name="gameId"></param> public void SubmitDrawCommand(string gameId, dynamic command) { GameMatch.ById(gameId).SubmitDrawCommand(command, this.Context); }
/// <summary> /// List all match that user can join /// </summary> /// <returns></returns> public List <GameMatch> ListMatch() { return(GameMatch.AllOpenMatch().ToList()); }
/// <summary> /// Join Game /// </summary> /// <param name="gameId"></param> /// <param name="playername"></param> /// <returns>True if player is the last player in the team - cannot draw only vote</returns> public void JoinMatch(string gameId, int team, dynamic playerInfo) { GameMatch.ById(gameId).Join(team, playerInfo, this.Context); }
public string CreateMatch(string gameName) { var newMatch = GameMatch.NewMatch(gameName); return(newMatch.GameId); }