예제 #1
0
        public void ProceedAfterVote()
        {
            try
            {
                if (CurrentRound.VoteResults.Result)
                {
                    //Update round:
                    CurrentRound.ElectChancellor();
                    if (FascistCardsOnBoard >= 3 && playersDict[CurrentRound.ChancellorId].Role == Role.Hitler)
                    {
                        CurrentRound.RoundState = RoundState.End;
                        GameResult = new GameResult()
                        {
                            Fascists    = Players.Where(p => p.Role != Role.Liberal).ToList(),
                            WinningTeam = CardType.Fascist,
                            Reason      = "Hitler elected after three fascit Cards Placed on Board"
                        };
                    }
                    else
                    {
                        if (RemainingCards.Count < 3)
                        {
                            DiscardedCards.Shuffle();
                            RemainingCards.AddRange(DiscardedCards);
                            DiscardedCards.Clear();
                        }
                        var cards = new List <Card>()
                        {
                            RemainingCards[0], RemainingCards[1], RemainingCards[2]
                        };
                        RemainingCards.RemoveRange(0, 3);
                        CurrentRound.PreparePresidentToDiscard(cards);
                    }
                }
                else
                {
                    CurrentRound.NbreOfFailedVotes++;
                    if (CurrentRound.NbreOfFailedVotes == 3)
                    {
                        if (RemainingCards.Count < 1)
                        {
                            DiscardedCards.Shuffle();
                            RemainingCards.AddRange(DiscardedCards);
                            DiscardedCards.Clear();
                        }
                        Card card = RemainingCards[0];

                        RemainingCards.RemoveAt(0);
                        CardsOnBoard.Add(card);

                        CurrentRound.NbreOfFailedVotes = 0;
                        MakeActionBeforeEnd();
                    }
                    else
                    {
                        MoveToNextTurn();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ProceedAfterVote.ex : " + ex.Message);
            }
        }