public void CreateGame() { var player = new Player() { User = Hub.Context.User, ConnectionId = Hub.Context.ConnectionId }; player.CreatePlayHand(); var game = new Game(player, Rules.Open, TradeRules.One, GameEnded); Games.AddGame(game); Hub.Groups.Add(Hub.Context.ConnectionId, game.GameId); BroadcastGameList(); Hub.Clients.Caller.updateBoard(game); Hub.Clients.Caller.gameJoined(game.GameId); }
public void CreateGameWithAi() { var player = new Player() { User = Hub.Context.User, ConnectionId = Hub.Context.ConnectionId }; player.CreatePlayHand(); var ai = new AiPlayer(2, 4) { IsReady = true, ConnectionId = "ai_" + IdGenerator.GenerateId() }; ai.CreatePlayHand(); var game = new Game(player, Rules.Open, TradeRules.One, GameEnded); game.SecondPlayer = ai; game.AiMove = AiMove; Games.AddGame(game); Hub.Groups.Add(Hub.Context.ConnectionId, game.GameId); BroadcastGameList(); Hub.Clients.Caller.updateBoard(game); Hub.Clients.Caller.gameJoined(game.GameId); }
public JsonNetResult GetDeck() { var cards = new Player().DbEntity.Deck.Select(c => new Card(c)).ToList(); var json = new JsonNetResult(cards); return json; }