Exemplo n.º 1
0
 /// <summary>
 /// Adds the specified card to the hand
 /// </summary>
 /// <param name="card">The card to add to the hand. The card will be added
 /// as the last card of the hand.</param>
 internal void Add(TraditionalCard card)
 {
     cards.Add(card);
     if (ReceivedCard != null)
     {
         ReceivedCard(this, new CardEventArgs() { Card = card });
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Deals the first card from the collection to a specified hand.
        /// </summary>
        /// <param name="destinationHand">The destination hand.</param>
        /// <returns>The card that was moved to the hand.</returns>
        public TraditionalCard DealCardToHand(Hand destinationHand)
        {
            TraditionalCard firstCard = cards[0];

            firstCard.MoveToHand(destinationHand);

            return(firstCard);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the name of a card asset.
 /// </summary>
 /// <param name="card">The card type for which to get the asset name.</param>
 /// <returns>The card's asset name.</returns>
 public static string GetCardAssetName(TraditionalCard card)
 {
     return string.Format("{0}{1}",
         ((card.Value | CardValue.FirstJoker) == 
             CardValue.FirstJoker ||
         (card.Value | CardValue.SecondJoker) == 
         CardValue.SecondJoker) ?
             "" : card.Type.ToString(), card.Value);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the name of a card asset.
 /// </summary>
 /// <param name="card">The card type for which to get the asset name.</param>
 /// <returns>The card's asset name.</returns>
 public static string GetCardAssetName(TraditionalCard card)
 {
     return(string.Format("{0}{1}",
                          ((card.Value | CardValue.FirstJoker) ==
                           CardValue.FirstJoker ||
                           (card.Value | CardValue.SecondJoker) ==
                           CardValue.SecondJoker) ?
                          "" : card.Type.ToString(), card.Value));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the animated game component associated with a specified card.
        /// </summary>
        /// <param name="card">The card for which to get the animation
        /// component.</param>
        /// <returns>The card's animation component, or null if such a card cannot
        /// be found in the hand.</returns>
        public AnimatedCardsGameComponent GetCardGameComponent(TraditionalCard card)
        {
            int location = GetCardLocationInHand(card);

            if (location == -1)
            {
                return(null);
            }

            return(heldAnimatedCards[location]);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Finds the index of a specified card in the hand.
 /// </summary>
 /// <param name="card">The card to locate.</param>
 /// <returns>The card's index inside the hand, or -1 if it cannot be
 /// found.</returns>
 public int GetCardLocationInHand(TraditionalCard card)
 {
     for (int animationIndex = 0; animationIndex < heldAnimatedCards.Count; animationIndex++)
     {
         if (heldAnimatedCards[animationIndex].Card == card)
         {
             return(animationIndex);
         }
     }
     return(-1);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Adds the specified card to the hand
 /// </summary>
 /// <param name="card">The card to add to the hand. The card will be added
 /// as the last card of the hand.</param>
 internal void Add(TraditionalCard card)
 {
     cards.Add(card);
     if (ReceivedCard != null)
     {
         ReceivedCard(this, new CardEventArgs()
         {
             Card = card
         });
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Shuffles the cards in the packet by randomly changing card placement.
        /// </summary>
        public void Shuffle()
        {
            Random random = new Random();
            List <TraditionalCard> shuffledDeck = new List <TraditionalCard>();

            while (cards.Count > 0)
            {
                TraditionalCard card = cards[random.Next(0, cards.Count)];
                cards.Remove(card);
                shuffledDeck.Add(card);
            }

            cards = shuffledDeck;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Returns a card's value in the scope of the game.
        /// </summary>
        /// <param name="card">The card for which to return the value.</param>
        /// <returns>The card's value.</returns>
        public virtual int CardValue(TraditionalCard card)
        {
            switch (card.Value)
            {
            case CardsFramework.CardValue.Ace:
                return(1);

            case CardsFramework.CardValue.Two:
                return(2);

            case CardsFramework.CardValue.Three:
                return(3);

            case CardsFramework.CardValue.Four:
                return(4);

            case CardsFramework.CardValue.Five:
                return(5);

            case CardsFramework.CardValue.Six:
                return(6);

            case CardsFramework.CardValue.Seven:
                return(7);

            case CardsFramework.CardValue.Eight:
                return(8);

            case CardsFramework.CardValue.Nine:
                return(9);

            case CardsFramework.CardValue.Ten:
                return(10);

            case CardsFramework.CardValue.Jack:
                return(11);

            case CardsFramework.CardValue.Queen:
                return(12);

            case CardsFramework.CardValue.King:
                return(13);

            default:
                throw new ArgumentException("Ambigous card value");
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Removes the specified card from the packet. The first matching card
        /// will be removed.
        /// </summary>
        /// <param name="card">The card to remove.</param>
        /// <returns>The card that was removed from the collection.</returns>
        /// <remarks>
        /// Please note that removing a card from a packet may only be performed internally by
        /// other card-framework classes to maintain the principle that a card may only be held
        /// by one <see cref="CardPacket"/> only at any given time.
        /// </remarks>
        internal TraditionalCard Remove(TraditionalCard card)
        {
            if (cards.Contains(card))
            {
                cards.Remove(card);

                if (LostCard != null)
                {
                    LostCard(this, new CardEventArgs()
                    {
                        Card = card
                    });
                }

                return(card);
            }
            return(null);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Removes the specified card from the packet. The first matching card
        /// will be removed.
        /// </summary>
        /// <param name="card">The card to remove.</param>
        /// <returns>The card that was removed from the collection.</returns>
        /// <remarks>
        /// Please note that removing a card from a packet may only be performed internally by
        /// other card-framework classes to maintain the principle that a card may only be held
        /// by one <see cref="CardPacket"/> only at any given time.
        /// </remarks>
        internal TraditionalCard Remove(TraditionalCard card)
        {
            if (cards.Contains(card))
            {
                cards.Remove(card);

                if (LostCard != null)
                {
                    LostCard(this, new CardEventArgs() { Card = card });
                }

                return card;
            }
            return null;
        }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 /// <param name="card">The card associated with the animation component.</param>
 /// <param name="cardGame">The associated game.</param>
 public AnimatedCardsGameComponent(TraditionalCard card, CardsGame cardGame)
     : base(cardGame, null)
 {
     Card = card;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Returns a card's value in the scope of the game.
 /// </summary>
 /// <param name="card">The card for which to return the value.</param>
 /// <returns>The card's value.</returns>        
 public virtual int CardValue(TraditionalCard card)
 {
     switch (card.Value)
     {
         case CardsFramework.CardValue.Ace:
             return 1;
         case CardsFramework.CardValue.Two:
             return 2;
         case CardsFramework.CardValue.Three:
             return 3;
         case CardsFramework.CardValue.Four:
             return 4;
         case CardsFramework.CardValue.Five:
             return 5;
         case CardsFramework.CardValue.Six:
             return 6;
         case CardsFramework.CardValue.Seven:
             return 7;
         case CardsFramework.CardValue.Eight:
             return 8;
         case CardsFramework.CardValue.Nine:
             return 9;
         case CardsFramework.CardValue.Ten:
             return 10;
         case CardsFramework.CardValue.Jack:
             return 11;
         case CardsFramework.CardValue.Queen:
             return 12;
         case CardsFramework.CardValue.King:
             return 13;
         default:
             throw new ArgumentException("Ambigous card value");
     }
 }
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 /// <param name="card">The card associated with the animation component.</param>
 /// <param name="cardGame">The associated game.</param>
 public AnimatedCardsGameComponent(TraditionalCard card, CardsGame cardGame)
     : base(cardGame, null)
 {
     Card = card;
 }
        /// <summary>
        /// Gets the animated game component associated with a specified card.
        /// </summary>
        /// <param name="card">The card for which to get the animation 
        /// component.</param>
        /// <returns>The card's animation component, or null if such a card cannot
        /// be found in the hand.</returns>
        public AnimatedCardsGameComponent GetCardGameComponent(TraditionalCard card)
        {
            int location = GetCardLocationInHand(card);
            if (location == -1)
                return null;

            return heldAnimatedCards[location];
        }
 /// <summary>
 /// Finds the index of a specified card in the hand.
 /// </summary>
 /// <param name="card">The card to locate.</param>
 /// <returns>The card's index inside the hand, or -1 if it cannot be
 /// found.</returns>
 public int GetCardLocationInHand(TraditionalCard card)
 {
     for (int animationIndex = 0; animationIndex < heldAnimatedCards.Count; animationIndex++)
     {
         if (heldAnimatedCards[animationIndex].Card == card)
         {
             return animationIndex;
         }
     }
     return -1;
 }