예제 #1
0
 public void ReturnBattlefields(List <Card> BattleCards, List <Card> OpponentBattleCards)
 {
     foreach (Card c in BattleCards)
     {
         c.FaceUP = false;
         Deck.Add(c);
     }
     foreach (Card c in OpponentBattleCards)
     {
         c.FaceUP = false;
         OpponentDeck.Add(c);
     }
 }
예제 #2
0
        private void TakeSpoils(bool playerWon, int column, bool playerAttack, bool opponentAttack, List <Card> BattleCards, List <Card> OpponentBattleCards, int aceCount)
        {
            if (playerWon)
            {
                foreach (Card c in BattleCards)
                {
                    c.FaceUP = false;
                    Deck.Add(c);
                }
                foreach (Card c in OpponentBattleCards)
                {
                    c.FaceUP = false;
                    Deck.Add(c);
                }
                BattleCards.Clear();
                OpponentBattleCards.Clear();
                if (Pot.Count > 0)
                {
                    foreach (Card c in Pot)
                    {
                        c.FaceUP = false;
                        Deck.Add(c);
                    }
                    if (BattlefieldLayout.Contains(Pot[0]))
                    {
                        BattlefieldLayout[PotColumn]       = null;
                        BattlefieldLayout[PotColumn + 3]   = null;
                        OpponentBattlefield[PotColumn]     = null;
                        OpponentBattlefield[PotColumn + 3] = null;
                    }
                    Pot.Clear();
                }

                BattlefieldLayout[column]       = null;
                BattlefieldLayout[column + 3]   = null;
                OpponentBattlefield[column]     = null;
                OpponentBattlefield[column + 3] = null;

                Reinforcement         = null;
                OpponentReinforcement = null;

                OnPropertyChanged("BattleFieldLayout");
                OnPropertyChanged("OpponentBattlefield");
                int spoils = 0;
                spoils += (playerAttack ? 1 : 0) + (opponentAttack ? 1 : 0);

                if (aceCount > 0)
                {
                    Log    += $"Additional {aceCount} spoils for Aces\n";
                    spoils += aceCount;
                }

                if (playerAttack)
                {
                    for (int i = 0; i < spoils; i++)
                    {
                        if (OpponentDeck.Count > 0)
                        {
                            Deck.Add(OpponentDeck[0]);
                            Log += $"Oppenent lost {OpponentDeck[0].GetValueStringLog()} as a spoil\n";
                            OpponentDeck.RemoveAt(0);
                        }
                    }
                }
            }
            else
            {
                foreach (Card c in BattleCards)
                {
                    c.FaceUP = false;
                    OpponentDeck.Add(c);
                }
                foreach (Card c in OpponentBattleCards)
                {
                    c.FaceUP = false;
                    OpponentDeck.Add(c);
                }
                BattleCards.Clear();
                OpponentBattleCards.Clear();
                if (Pot.Count > 0)
                {
                    foreach (Card c in Pot)
                    {
                        c.FaceUP = false;
                        OpponentDeck.Add(c);
                    }
                    if (BattlefieldLayout.Contains(Pot[0]))
                    {
                        BattlefieldLayout[PotColumn]       = null;
                        BattlefieldLayout[PotColumn + 3]   = null;
                        OpponentBattlefield[PotColumn]     = null;
                        OpponentBattlefield[PotColumn + 3] = null;
                    }
                    Pot.Clear();
                }
                BattlefieldLayout[column]       = null;
                BattlefieldLayout[column + 3]   = null;
                OpponentBattlefield[column]     = null;
                OpponentBattlefield[column + 3] = null;
                Reinforcement         = null;
                OpponentReinforcement = null;

                //OnPropertyChanged("Reinforcement");
                //OnPropertyChanged("OpponentReinforcement");

                OnPropertyChanged("BattlefieldLayout");
                OnPropertyChanged("OpponentBattlefield");
                int spoils = 0;
                spoils += (playerAttack ? 1 : 0) + (opponentAttack ? 1 : 0);

                if (aceCount > 0)
                {
                    Log    += $"Additional {aceCount} spoils for Aces\n";
                    spoils += aceCount;
                }

                if (opponentAttack)
                {
                    for (int i = 0; i < spoils; i++)
                    {
                        if (Deck.Count > 0)
                        {
                            OpponentDeck.Add(Deck[0]);
                            Log += $"You lost {Deck[0].GetValueStringLog()} as a spoil\n";
                            Deck.RemoveAt(0);
                        }
                    }
                }
            }
            OnPropertyChanged("DeckCount");
            OnPropertyChanged("OpponentDeckCount");
        }
예제 #3
0
        public void DealCards()
        {
            List <Card> AllCards = new List <Card>();

            CardSuit[]  Suits = (CardSuit[])Enum.GetValues(typeof(CardSuit));
            CardValue[] Vals  = (CardValue[])Enum.GetValues(typeof(CardValue));

            Deck.Clear();
            OpponentDeck.Clear();
            Casualties.Clear();

            //create cards
            foreach (var suit in Suits)
            {
                foreach (var v in Vals)
                {
                    Card c = new Card();
                    c.Suit   = suit;
                    c.Value  = v;
                    c.FaceUP = false;

                    if (c.Value != CardValue.Joker)
                    {
                        AllCards.Add(c);
                    }
                }
            }

            //Add 2 Jokers
            Card c3 = new Card();

            c3.Value  = CardValue.Joker;
            c3.FaceUP = false;

            Card c2 = new Card();

            c2.Value  = CardValue.Joker;
            c2.FaceUP = false;

            AllCards.Add(c3);
            AllCards.Add(c2);

            //Shuffle the deck
            int n = AllCards.Count;

            while (n > 1)
            {
                n--;
                int  k = rng.Next(n + 1);
                Card c = AllCards[k];
                AllCards[k] = AllCards[n];
                AllCards[n] = c;
            }

            //Deal
            int i = 0;

            foreach (Card c in AllCards)
            {
                if (i % 2 == 0)
                {
                    Deck.Add(c);
                }
                else
                {
                    OpponentDeck.Add(c);
                }

                i++;
            }

            Log += "Cards have been dealt.\n";
        }