예제 #1
0
        public CGMessage EndGame(Game game)
        {
            _methodName = $"{ClassName}.EndGame";
            CGMessage returnMessage = new();

            try
            {
                _gameEngine.EndGame(game);
                returnMessage.Status = true;
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, ex, $"{_methodName}; Error: {ex.Message}", returnMessage);
            }
            return(returnMessage);
        }
예제 #2
0
        public async Task VoteForParty(ApprovalVoteOptionsEnum approvalVote)
        {
            _playerEngine.VoteForParty(GameId, Username, approvalVote);

            if (_gameEngine.TryToApproveParty(GameId, out Dictionary <string, ApprovalVoteOptionsEnum> userVotes, out string newKingUsername))
            {
                if (_gameEngine.HaveFivePartiesFailed(GameId))
                {
                    var gameSummary = _gameEngine.EndGame(GameId, GameResultEnum.EvilWins);
                    await Clients.Groups(PublicGameId).ReceiveUserApprovalVotes(userVotes, newKingUsername, gameSummary);
                }
                else
                {
                    await Clients.Groups(PublicGameId).ReceiveUserApprovalVotes(userVotes, newKingUsername);
                }
            }
        }