} // end CheckTurnOver

        /// <summary>
        /// Finds correct table and adds all the cards in the stack to the table
        /// </summary>
        /// <param name="played"></param>
        /// <param name="destination"></param>
        private static void AddToTable(Card[] played, Card destination)
        {
            //
            if ((tableau1.GetCount() != 0) && (tableau1.GetLastCardInPile() == destination))
            {
                for (int i = 0; i < played.Length; i++)
                {
                    tableau1.Add(played[i]);
                    tableCardsInPlay[1]++;
                }
            }
            else if ((tableau2.GetCount() != 0) && (tableau2.GetLastCardInPile() == destination))
            {
                for (int i = 0; i < played.Length; i++)
                {
                    tableau2.Add(played[i]);
                    tableCardsInPlay[2]++;
                }
            }
            else if ((tableau3.GetCount() != 0) && (tableau3.GetLastCardInPile() == destination))
            {
                for (int i = 0; i < played.Length; i++)
                {
                    tableau3.Add(played[i]);
                    tableCardsInPlay[3]++;
                }
            }
            else if ((tableau4.GetCount() != 0) && (tableau4.GetLastCardInPile() == destination))
            {
                for (int i = 0; i < played.Length; i++)
                {
                    tableau4.Add(played[i]);
                    tableCardsInPlay[4]++;
                }
            }
            else if ((tableau5.GetCount() != 0) && (tableau5.GetLastCardInPile() == destination))
            {
                for (int i = 0; i < played.Length; i++)
                {
                    tableau5.Add(played[i]);
                    tableCardsInPlay[5]++;
                }
            }
            else if ((tableau6.GetCount() != 0) && (tableau6.GetLastCardInPile() == destination))
            {
                for (int i = 0; i < played.Length; i++)
                {
                    tableau6.Add(played[i]);
                    tableCardsInPlay[6]++;
                }
            }
            else if ((tableau7.GetCount() != 0) && (tableau7.GetLastCardInPile() == destination))
            {
                for (int i = 0; i < played.Length; i++)
                {
                    tableau7.Add(played[i]);
                    tableCardsInPlay[7]++;
                }
            }
        }
Exemple #2
0
 public static CardPile<Card> GetEffectDeck(bool super)
 {
     CardPile<Card> deck = new CardPile<Card>();
     deck.Add(RandomWildDrawCard.GetDeckContents(super));
     deck.Add(SelfInflictedDrawThreeCard.GetDeckContents(super));
     deck.Add(SelfInflictedLoseThreeCard.GetDeckContents(super));
     deck.Add(QuestionCard.GetDeckContents(super));
     return deck;
 }
Exemple #3
0
    public void Setup()
    {
        // Shuffle deck
        List <CardDesc> shuffledDeck = new List <CardDesc>(playerDeck.cards);

        ShuffleDeck(shuffledDeck);

        deck.Add(shuffledDeck);

        hp     = GameMng.GetRules().maxHealth;
        energy = 0;

        UpdateStats();

        // Set me as active player, so I can draw cards
        activePlayer = true;

        for (int i = 0; i < GameMng.GetRules().startCardsOnHand; i++)
        {
            DrawCard(deck);
            // So we don't exceed the draw limit
            drawCount = 0;
        }

        activePlayer = false;
    }
        private static int[] tableCardsInPlay = new int[8]; //the amount if playable cards per table. index at 1 to allow index to match table number

        //Game Setup
        public static void SetUpGame()
        {
            drawPile      = new CardPile(true);
            discardPile   = new CardPile();
            suitPileOne   = new CardPile();
            suitPileTwo   = new CardPile();
            suitPileThree = new CardPile();
            suitPileFour  = new CardPile();

            drawPile.Shuffle();
            discardPile.Add(drawPile.DealOneCard());
            tableau1 = TableauInitialise(1);
            tableau2 = TableauInitialise(2);
            tableau3 = TableauInitialise(3);
            tableau4 = TableauInitialise(4);
            tableau5 = TableauInitialise(5);
            tableau6 = TableauInitialise(6);
            tableau7 = TableauInitialise(7);

            //sets up the cards in play array, with the index at 1
            tableCardsInPlay[0] = 0;
            for (int i = 1; i < tableCardsInPlay.Length; i++)
            {
                tableCardsInPlay[i] = 1;
            }
        }
Exemple #5
0
        }     // end DealStart

        /// <summary>
        /// Checks if clicked card is allowed to be played and play the card
        /// </summary>
        /// <param name="card"></param>
        /// <param name="hand"></param>
        /// <returns></returns>
        public static bool IsGoodClick(Card card, Suit suit)
        {
            Card discard = discardPile.GetLastCardInPile();

            // check if the clicked card has a playable suit, facevalue or is an eight
            if ((card.GetSuit() == suit) || (card.GetFaceValue() == discard.GetFaceValue()) ||
                (card.GetFaceValue() == FaceValue.Eight))
            {
                hands[1].Remove(card);
                discardPile.Add(card);
                return(true);
            }
            else
            {
                return(false);
            } // end if
        }     // end IsGoodClick
Exemple #6
0
        /// <summary>
        /// Draws a new card from the drawPile and adds it to the discardPile
        /// </summary>
        public static void DrawCard()
        {
            if (drawPile.GetCount() == 0)
            {
                ResetDrawPile();
            }

            discardPile.Add(drawPile.DealOneCard());
        }
        /// <summary>
        /// Initialise Tableau
        /// </summary>
        /// <param name="amountOfCards"></param>
        /// <returns></returns>
        //Sets a single table at the start of the game
        private static CardPile TableauInitialise(int amountOfCards)
        {
            CardPile tableau = new CardPile();

            for (int i = 0; i < amountOfCards; i++)
            {
                tableau.Add(drawPile.DealOneCard());
            }
            return(tableau);
        }
 /// <summary>
 /// Place a card in a Suit Pile
 /// </summary>
 /// <param name="played"></param>
 /// <param name="destination"></param>
 private static void SuitPlace(Card played, Card destination)
 {
     if ((suitPileOne.GetCount() != 0) && (suitPileOne.GetLastCardInPile().GetSuit() == destination.GetSuit()))
     {
         suitPileOne.Add(played);
     }
     else if ((suitPileTwo.GetCount() != 0) && (suitPileTwo.GetLastCardInPile().GetSuit() == destination.GetSuit()))
     {
         suitPileTwo.Add(played);
     }
     else if ((suitPileThree.GetCount() != 0) && (suitPileThree.GetLastCardInPile().GetSuit() == destination.GetSuit()))
     {
         suitPileThree.Add(played);
     }
     else if ((suitPileFour.GetCount() != 0) && (suitPileFour.GetLastCardInPile().GetSuit() == destination.GetSuit()))
     {
         suitPileFour.Add(played);
     }
 }
Exemple #9
0
 public Deck()
 {
     foreach (CardSuit cardSuit in Enum.GetValues(typeof(CardSuit)))
     {
         foreach (CardRank cardRank in Enum.GetValues(typeof(CardRank)))
         {
             CardPile.Add(new SpadesCard(Card.ToCardIndex(cardSuit, cardRank)));
         }
     }
 }
 //Method Draw_Card()
 //Draws the cards from the cardPile.
 public static bool Draw_Card()
 {
     if (drawPile.GetCount() == 0)
     {
         return(false);
     }
     else
     {
         discardPile.Add(drawPile.DealOneCard());
         return(true);
     }
 }
Exemple #11
0
 public void Move(CardPile newCardPile, bool checkForAutoComplete, bool addStepToHistory, bool increaseActionCounter)
 {
     CardPile.Remove(this);
     newCardPile.Add(this, addStepToHistory);
     if (checkForAutoComplete)
     {
         GameManager.Instance.CheckIfFinishedOrReadyForAutoComplete();
     }
     if (increaseActionCounter)
     {
         GameManager.Instance.ActionCounter++;
     }
 }
Exemple #12
0
        private static void Load(CardType t)
        {
            // Load from 'cah_[color].txt'
            string file = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) +
                Path.DirectorySeparatorChar + "cah_" + Enum.GetName(typeof(CardType), t).ToLower() + ".txt";

            if (!File.Exists(file)) throw new FileNotFoundException("Failed to get card list from '" + file + "'");
            CardPile<Card> pile = new CardPile<Card>();
            using (StreamReader f = new StreamReader(file)) {
                while (!f.EndOfStream) {
                    string l = f.ReadLine();
                    // Skip comments and empty strings
                    if (String.IsNullOrWhiteSpace(l) || l.StartsWith(";")) continue;
                    // Else use exactly what it has
                    else pile.Add(new Card(t, l));
                }
            }

            if (t == CardType.White) _white = pile;
            else _black = pile;
        }
Exemple #13
0
 public void AddCard(Card cardToAdd)
 {
     CardPile.Add(cardToAdd);
 }
Exemple #14
0
 public void AddCard(SpadesCard c)
 {
     CardPile.Add(c);
     OnPotAdd(new PileEventArgs(c));
 }
Exemple #15
0
 /*
  * Colors always evenly distributed
  *
  * UNO:
  * 2 each 0-9
  * 2 R
  * 2 S
  * 2 DT
  * 4 WILD
  * 4 WD4
  *
  * Super:
  * 3 0-9
  * 1 1337
  * 3 DT
  * 1 DF
  * 3 R
  * 3 S
  * 2 SX
  * 4 WILD
  * 4 WD4
  * 4 WMD3
  * 4 SWD4
  * 4 RWD4
  * 4 WTF
  * 8 !
  * 16 $
  * 4 DH
  * 1 ASDF (1/15 chance)
  *
  * Super effect:
  * 8 SID3
  * 4 RW/D
  * 4 3DIS
  * 4 ?
  */
 public static CardPile<Card> GetDrawDeck(bool super)
 {
     CardPile<Card> deck = new CardPile<Card>();
     deck.Add(AsdfCard.GetDeckContents(super));
     deck.Add(DollarCard.GetDeckContents(super));
     deck.Add(DrawFourCard.GetDeckContents(super));
     deck.Add(DrawHandCard.GetDeckContents(super));
     deck.Add(DrawTwoCard.GetDeckContents(super));
     deck.Add(ExclamationCard.GetDeckContents(super));
     deck.Add(NumberCard.GetDeckContents(super));
     deck.Add(ReverseCard.GetDeckContents(super));
     deck.Add(ReverseWildDrawFourCard.GetDeckContents(super));
     deck.Add(SkipCard.GetDeckContents(super));
     deck.Add(SkipXCard.GetDeckContents(super));
     deck.Add(SuperWildDrawFourCard.GetDeckContents(super));
     deck.Add(WildCard.GetDeckContents(super));
     deck.Add(WildDrawFourCard.GetDeckContents(super));
     deck.Add(WildMassDrawThreeCard.GetDeckContents(super));
     deck.Add(WtfCard.GetDeckContents(super));
     return deck;
 }
Exemple #16
0
    public void DrawCard(CardPile pile)
    {
        // Can't draw cards if we're not the active player
        if (!activePlayer)
        {
            return;
        }

        // Can't draw a card if we have one floating
        if (currentCard != null)
        {
            return;
        }

        // Check if pile has cards
        if (pile.GetCardCount() <= 0)
        {
            // Check if we can dump the graveyard back in the deck
            if (GameMng.GetRules().infiniteDeck)
            {
                var cards = graveyard.GetCards();
                graveyard.Clear();

                if (GameMng.GetRules().reshuffleInfinite)
                {
                    ShuffleDeck(cards);
                }

                pile.Add(cards);

                if (pile.GetCardCount() <= 0)
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }

        // Check if we can draw cards (cards in hand is less than maximum allowed)
        if (hand.GetCardCount() >= GameMng.GetRules().maxCardsInHand)
        {
            return;
        }

        // Check if we've already drawn enough cards this turn
        if (drawCount >= GameMng.GetRules().drawPerTurn)
        {
            return;
        }

        drawCount++;

        // Get the first card
        CardDesc card = pile.GetFirstCard();

        // Create the card itself and pop it on the hand
        var cardObject = GameMng.CreateCard(card);

        hand.Add(cardObject);
    }
 /// <summary>
 /// Reset draw pile when there is no card to draw
 /// </summary>
 public static void ResetDrawPile()
 {
     drawPile    = discardPile;
     discardPile = new CardPile();
     discardPile.Add(drawPile.DealOneCard());
 }
 /// <summary>
 /// Draw 1 card from Draw Table
 /// </summary>
 public static void DrawCard()
 {
     discardPile.Add(drawPile.DealOneCard());
 }
Exemple #19
0
 public void SendToGraveyard(CardDesc card)
 {
     graveyard.Add(card);
 }