Esempio n. 1
0
 public void DiscardCard(int discarded)
 {
     try
     {
         if (CurrentRound != null)
         {
             var cardInd = CurrentRound.CardsInHand.FindIndex(c => c.CardId == discarded);
             if (cardInd >= 0)
             {
                 var card = CurrentRound.CardsInHand[cardInd];
                 DiscardedCards.Add(card);
                 CurrentRound.CardsInHand.RemoveAt(cardInd);
             }
             if (CurrentRound.CardsInHand.Count == 2)
             {
                 CurrentRound.RoundState = RoundState.ChancellorDiscard;
             }
             else if (CurrentRound.CardsInHand.Count == 1)
             {
                 var card = CurrentRound.CardsInHand[0];
                 CardsOnBoard.Add(card);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("DiscardCard.ex: " + ex.Message);
     }
 }
Esempio n. 2
0
 public void Discard(List <Card> cards)
 {
     foreach (Card card in cards)
     {
         DiscardedCards.Add(card);
         DeckOfCards.Remove(card);
     }
 }
Esempio n. 3
0
 public override string ToString()
 {
     return($"Discard Action - {Source.Data.CardName} sends {string.Join(", ", DiscardedCards.Select(c => c.Data.CardName))} to the discard pile.");
 }
Esempio n. 4
0
 public void Discard(Card card)
 {
     DiscardedCards.Add(card);
     DeckOfCards.Remove(card);
 }
Esempio n. 5
0
 public void MakeActionBeforeEnd()
 {
     try
     {
         if (FascistCardsOnBoard == 6)
         {
             CurrentRound.RoundState = RoundState.End;
             GameResult = new GameResult()
             {
                 Fascists    = Players.Where(p => p.Role != Role.Liberal).ToList(),
                 WinningTeam = CardType.Fascist,
                 Reason      = "Six fascit Cards Placed on Board"
             };
         }
         else if (CardsOnBoard.Where(c => c.CardType == CardType.Liberal).Count() == 5)
         {
             CurrentRound.RoundState = RoundState.End;
             GameResult = new GameResult()
             {
                 Fascists    = Players.Where(p => p.Role != Role.Liberal).ToList(),
                 WinningTeam = CardType.Fascist,
                 Reason      = "Six fascit Cards Placed on Board"
             };
         }
         else if (Players.Count == 9 || Players.Count == 10)
         {
             if (FascistCardsOnBoard == 1 && fascistCardPlacedNbre == 0)
             {
                 fascistCardPlacedNbre++;
                 CurrentRound.RoundState = RoundState.InvestigateMembership;
             }
             else if (FascistCardsOnBoard == 2 && fascistCardPlacedNbre == 1)
             {
                 fascistCardPlacedNbre++;
                 CurrentRound.RoundState = RoundState.InvestigateMembership;
             }
             else if (FascistCardsOnBoard == 3 && fascistCardPlacedNbre == 2)
             {
                 fascistCardPlacedNbre++;
                 CurrentRound.RoundState = RoundState.PickNextPresident;
             }
             else if (FascistCardsOnBoard == 4 && fascistCardPlacedNbre == 3)
             {
                 CurrentRound.RoundState = RoundState.KillMember;
             }
             else if (FascistCardsOnBoard == 5 && fascistCardPlacedNbre == 4)
             {
                 CurrentRound.RoundState = RoundState.KillMember;
             }
             else
             {
                 MoveToNextTurn();
             }
         }
         else if (Players.Count == 7 || Players.Count == 8)
         {
             if (FascistCardsOnBoard == 2 && fascistCardPlacedNbre == 0)
             {
                 fascistCardPlacedNbre++;
                 CurrentRound.RoundState = RoundState.InvestigateMembership;
             }
             else if (FascistCardsOnBoard == 3 && fascistCardPlacedNbre == 1)
             {
                 fascistCardPlacedNbre++;
                 CurrentRound.RoundState = RoundState.PickNextPresident;
             }
             else if (FascistCardsOnBoard == 4 && fascistCardPlacedNbre == 2)
             {
                 CurrentRound.RoundState = RoundState.KillMember;
             }
             else if (FascistCardsOnBoard == 5 && fascistCardPlacedNbre == 3)
             {
                 CurrentRound.RoundState = RoundState.KillMember;
             }
             else
             {
                 MoveToNextTurn();
             }
         }
         else
         {
             if (FascistCardsOnBoard == 3 && fascistCardPlacedNbre == 0)
             {
                 fascistCardPlacedNbre++;
                 CurrentRound.RoundState = RoundState.PeekNextCards;
                 CurrentRound.CardsInHand.Clear();
                 if (RemainingCards.Count < 3)
                 {
                     DiscardedCards.Shuffle();
                     RemainingCards.AddRange(DiscardedCards);
                     DiscardedCards.Clear();
                 }
                 CurrentRound.CardsInHand.Add(RemainingCards[0]);
                 CurrentRound.CardsInHand.Add(RemainingCards[1]);
                 CurrentRound.CardsInHand.Add(RemainingCards[2]);
             }
             else if (FascistCardsOnBoard == 4 && fascistCardPlacedNbre == 1)
             {
                 CurrentRound.RoundState = RoundState.KillMember;
             }
             else if (FascistCardsOnBoard == 5 && fascistCardPlacedNbre == 2)
             {
                 CurrentRound.RoundState = RoundState.KillMember;
             }
             else
             {
                 MoveToNextTurn();
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("ProceedAfterDiscard.ex: " + ex.Message);
     }
 }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
 public bool Discard(Card card)
 {
     return(DiscardedCards.Discard(card));
 }