Exemplo n.º 1
0
        /// <summary>
        /// This method 'draws' a card by randomlytaking from the drawPile
        /// It will also regenerate a new deck of cards if the drawPile is empty
        /// </summary>
        /// <returns>A randomly drawn card from the drawPile</returns>
        /// <see cref = 'UnoModel.ReShuffleDraw()'/>
        public UnoCard DrawCard()
        {
            if (drawPile.Count == 0)
            {
                ReShuffleDraw();
            }
            Random  rnd      = new Random();
            int     index    = rnd.Next(drawPile.Count);
            UnoCard toReturn = drawPile[index];

            drawPile.RemoveAt(index);
            return(toReturn);
        }
Exemplo n.º 2
0
 /// <summary>
 /// This 'Plays' a card by assigning the given card to the discard card
 /// </summary>
 /// <param name="card">The card to 'Play'</param>
 public void PlayCard(UnoCard card)
 {
     discardCard = card;
 }
Exemplo n.º 3
0
 /// <summary>
 /// This is an OverLoad of PlayCard() which takes a hand to remove the card from
 /// </summary>
 /// <param name="card">The card to 'Play'</param>
 /// <param name="hand">The hand to rid the card of</param>
 public void PlayCard(UnoCard card, List <UnoCard> hand)
 {
     discardCard = card;
     hand.Remove(card);
 }
Exemplo n.º 4
0
 /// <summary>
 /// This adds the card to the given hand/list
 /// </summary>
 /// <param name="card">The card to add</param>
 /// <param name="hand">The hand to add the card to</param>
 public void AddCard(UnoCard card, List <UnoCard> hand)
 {
     hand.Add(card);
 }