示例#1
0
        public Task GameSubmitClaim(long gameLobbyID, List <GetGameCard> claims, List <GetGameCard> actual)
        {
            return(Task.Run(() =>
            {
                var gameLobby = gameLobbyService.GetGameLobby(gameLobbyID);
                if (gameLobby == null)
                {
                    return;
                }
                gameLobby.UseLobbyLock(() =>
                {
                    gameLobby.GameLogicController.SubmitClaim(Context.User, claims.GetGameCards(), actual.GetGameCards());
                    gameLobby.GameLogicController.CallPhase(OnGameCheat, OnEndTurn, OnGameFinish);

                    foreach (var gameUser in gameLobby.GetUsers())
                    {
                        var gameState = gameLobby.GameLogicController.GetGameState(gameUser);
                        var connection = userConnectionsService.GameConnectionService.GetConnection(gameUser);

                        var apiObject = new HubApi.GameClaim
                        {
                            GameState = new GetGameState(gameState)
                        };
                        gameHubContext.Clients.Client(connection).GameClaim(apiObject);
                    }
                });
            }));
        }
示例#2
0
        public void OnTurnTimeout(long gameLobbyID)
        {
            var gameLobby = gameLobbyService.GetGameLobby(gameLobbyID);

            if (gameLobby == null)
            {
                return;
            }
            gameLobby.UseLobbyLock(() =>
            {
                gameLobby.GameLogicController.CallPhase(OnGameCheat, OnEndTurn, OnGameFinish);

                foreach (var gameUser in gameLobby.GetUsers())
                {
                    var gameState  = gameLobby.GameLogicController.GetGameState(gameUser);
                    var connection = userConnectionsService.GameConnectionService.GetConnection(gameUser);

                    var apiObject = new HubApi.GameClaim
                    {
                        GameState = new GetGameState(gameState)
                    };
                    gameHubContext.Clients.Client(connection).GameClaim(apiObject);
                }
            });
        }