示例#1
0
        /// <summary>
        /// Draws a card from the hand
        /// </summary>
        /// <param name="index">The index location where to draw the card from</param>
        public kbPlayingCard DrawFrom(int index)
        {
            kbPlayingCard pc = m_Cards[index];

            m_Cards.RemoveAt(index);
            return(pc);
        }
示例#2
0
        /// <summary>
        /// Draws a card from the top of the hand
        /// </summary>
        public kbPlayingCard DrawFromTop()
        {
            kbPlayingCard pc = m_Cards.First();

            m_Cards.RemoveAt(0);
            return(pc);
        }
示例#3
0
        /// <summary>
        /// Draws a card from the bottom of the hand
        /// </summary>
        public kbPlayingCard DrawFromBottom()
        {
            kbPlayingCard pc = m_Cards.Last();

            m_Cards.RemoveAt(m_Cards.Count - 1);
            return(pc);
        }
示例#4
0
        /// <summary>
        /// Shuffles the hand, by going through the cards one by one and swapping it with a random location
        /// </summary>
        public void Shuffle()
        {
            int nCardsInDeck = m_Cards.Count;

            for (int i = 0; i < nCardsInDeck; i++)
            {
                int iSwap = (int)(m_Rand.NextDouble() * nCardsInDeck);

                kbPlayingCard swap = m_Cards[i];
                m_Cards[i]     = m_Cards[iSwap];
                m_Cards[iSwap] = swap;
            }
        }
示例#5
0
 /// <summary>
 /// Gets the index of a particular card.  Returns -1 if the card isn't in the deck.
 /// </summary>
 public int GetIndexOf(kbPlayingCard pc)
 {
     return m_Cards.FindIndex(w => w.suit == pc.suit && w.rank == pc.rank);
 }
示例#6
0
 /// <summary>
 /// Check to see if hand contains a certain card
 /// </summary>
 public bool Contains(kbPlayingCard pc)
 {
     return m_Cards.Any(w => w.suit == pc.suit && w.rank == pc.rank);
 }
示例#7
0
 /// <summary>
 /// Adds card to the top of the hand.
 /// </summary>
 public void AddToTop(kbPlayingCard pc)
 {
     m_Cards.Insert(0, pc);
 }
示例#8
0
 /// <summary>
 /// Adds card to the bottom of the hand
 /// </summary>
 public void AddToBottom(kbPlayingCard pc)
 {
     m_Cards.Add(pc);
 }
示例#9
0
 /// <summary>
 /// Adds card to the hand
 /// </summary>
 /// <param name="pc">Card to Add</param>
 /// <param name="index">Index location where to add the card.</param>
 public void AddTo(kbPlayingCard pc, int index)
 {
     m_Cards.Insert(index, pc);
 }
示例#10
0
 /// <summary>
 /// Gets the index of a particular card.  Returns -1 if the card isn't in the deck.
 /// </summary>
 public int GetIndexOf(kbPlayingCard pc)
 {
     return(m_Cards.FindIndex(w => w.suit == pc.suit && w.rank == pc.rank));
 }
示例#11
0
 /// <summary>
 /// Check to see if hand contains a certain card
 /// </summary>
 public bool Contains(kbPlayingCard pc)
 {
     return(m_Cards.Any(w => w.suit == pc.suit && w.rank == pc.rank));
 }
示例#12
0
 /// <summary>
 /// Adds card to the hand
 /// </summary>
 /// <param name="pc">Card to Add</param>
 /// <param name="index">Index location where to add the card.</param>
 public void AddTo(kbPlayingCard pc, int index)
 {
     m_Cards.Insert(index, pc);
 }
示例#13
0
 /// <summary>
 /// Adds card to the top of the hand.
 /// </summary>
 public void AddToTop(kbPlayingCard pc)
 {
     m_Cards.Insert(0, pc);
 }
示例#14
0
 /// <summary>
 /// Adds card to the bottom of the hand
 /// </summary>
 public void AddToBottom(kbPlayingCard pc)
 {
     m_Cards.Add(pc);
 }