private void SaveResult(VoteVerdictMessage verdict)
        {
            var player      = verdict.Player;
            var playerVotes = _votes.Where(vote => vote.PlayerFrom == player).ToList();

            player.VoteHistory.Add(new VoteHistoryItem(playerVotes, verdict, _playerOnStand));
        }
Esempio n. 2
0
 public VoteHistoryItem(List <PlayerVoteMessage> votes, VoteVerdictMessage verdictMessage, Player target, int order = 0)
 {
     Votes   = votes;
     Time    = verdictMessage.Time;
     Verdict = verdictMessage.Verdict;
     Target  = target;
     Order   = order;
 }
        public ServerMessage CreateMessage(byte[] bytes)
        {
            var messageType = (bytes?.FirstOrDefault() ?? 0).GetMessageType();

            switch (messageType)
            {
            case ServerMessageType.PlayerJoined:
                var playerJoinedMessage = new PlayerJoinedMessage(bytes);
                Players.Add(playerJoinedMessage.Player);
                return(playerJoinedMessage);

            case ServerMessageType.StartOfGame:
                Players.Clear();
                ResetGameTime();
                return(new StartOfGameMessage(bytes));

            case ServerMessageType.StartOfDay:
            case ServerMessageType.StartOfNight:
                Trial.Clear();
                MoveTimeForward();
                return(new MoveTimeForwardMessage(bytes));

            case ServerMessageType.PlayerVote:
                var playerVoteMessage = new PlayerVoteMessage(bytes);
                Trial.AddVote(playerVoteMessage);
                return(playerVoteMessage);

            case ServerMessageType.PlayerOnStand:
                var playerOnStandMessage = new PlayerOnStandMessage(bytes);
                Trial.SetPlayerOnStand(playerOnStandMessage);
                return(playerOnStandMessage);

            case ServerMessageType.VoteVerdict:
                var voteVerdictMessage = new VoteVerdictMessage(bytes);
                Trial.AddVerdict(voteVerdictMessage);
                return(voteVerdictMessage);

            case ServerMessageType.PlayerIsGuilty:
            case ServerMessageType.PlayerIsInnocent:
                Trial.Complete();
                return(new ServerMessage(bytes));

            case ServerMessageType.Chat: return(new ChatMessage(bytes));

            case ServerMessageType.PlayerDead: return(new PlayerDeadMessage(bytes));

            case ServerMessageType.LocalPlayerReport: return(new LocalPlayerReportMessage(bytes));

            case ServerMessageType.MafiaPlayersReport: return(new MafiaPlayersReportMessage(bytes));

            case ServerMessageType.MayorRevealed: return(new MayorRevealedMessage(bytes));

            case ServerMessageType.PlayerRevived: return(new PlayerRevivedMessage(bytes));

            default: return(new ServerMessage(bytes));
            }
        }
 public void AddVerdict(VoteVerdictMessage message) => _verdicts.Add(message);