/// <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); }
/// <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); }
/// <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); }
/// <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; } }
/// <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); }
/// <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); }
/// <summary> /// Adds card to the top of the hand. /// </summary> public void AddToTop(kbPlayingCard pc) { m_Cards.Insert(0, pc); }
/// <summary> /// Adds card to the bottom of the hand /// </summary> public void AddToBottom(kbPlayingCard pc) { m_Cards.Add(pc); }
/// <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); }
/// <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)); }
/// <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)); }