public JsonResult SendActiveCode([FromBody] ActiveGames activegames) { //activegames is a new model class that is stored in the model folder GameData.Active_games.Add(activegames.Activegames.ToString()); return(Json(new { GameData.Active_games })); }
public void MatchMaker() { _isActive = true; while (_isActive) { if (MatchmakingQueue.Count > 0) { Players.Add(new TempPlayer(this, Players.Count)); MatchmakingQueue.Add(Players[Players.Count - 1]); ActiveGames.Add(new GameHandler(MatchmakingQueue[0], MatchmakingQueue[1], ActiveGames.Count + 1)); MatchmakingQueue.RemoveAt(0); MatchmakingQueue.RemoveAt(0); } } }
public Guid?QueueForGame(Guid playerId) { var gameId = Queue.QueueForGame(playerId); // if game is found but is not started yet, start a game if (gameId != null) { if (!ActiveGames.ContainsKey(gameId.Value)) { var players = Queue.GetPlayerForGame(gameId.Value); GameBLL.StartGame(gameId.Value, players[0], players[1]); ActiveGames[gameId.Value] = new BoardGameState <TFigure>(gameId.Value, players[0], new TRules()); } } return(gameId); }
public BattleShipHub(UnitOfWork unitOfWork, ActiveGames activeGames) { _unitOfWork = unitOfWork; _activeGames = activeGames; }
public JsonResult GetActiveCode([FromBody] ActiveGames activegames) { return(Json(new { GameData.Active_games })); }
public GameHub(ActiveGames gameSessions) { _gameSessions = gameSessions; }