/// <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); }
/// <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; }
/// <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); }
/// <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); }