Hand.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //-----------------------------------------------------------------------------
  2. // Hand.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. namespace CardsFramework
  11. {
  12. /// <summary>
  13. /// Represents a hand of cards held by a player, dealer or the game table
  14. /// </summary>
  15. /// <remarks>
  16. /// A <see cref="Hand"/> is a type of <see cref="CardPacket"/> that may also
  17. /// receive <see cref="Card"/> items, as well as loose them.
  18. /// Therefore, it may receive <see cref="Card"/> items from any
  19. /// <see cref="CardPacket"/> or from another <see cref="Hand"/>.
  20. /// </remarks>
  21. public class Hand : CardPacket
  22. {
  23. /// <summary>
  24. /// An event which triggers when a card is added to the hand.
  25. /// </summary>
  26. public event EventHandler<CardEventArgs> ReceivedCard;
  27. /// <summary>
  28. /// Adds the specified card to the hand
  29. /// </summary>
  30. /// <param name="card">The card to add to the hand. The card will be added
  31. /// as the last card of the hand.</param>
  32. internal void Add(TraditionalCard card)
  33. {
  34. cards.Add(card);
  35. if (ReceivedCard != null)
  36. {
  37. ReceivedCard(this, new CardEventArgs() { Card = card });
  38. }
  39. }
  40. /// <summary>
  41. /// Adds the specified cards to the hand
  42. /// </summary>
  43. /// <param name="cards">The cards to add to the hand. The cards are added
  44. /// as the last cards of the hand.</param>
  45. internal void Add(IEnumerable<TraditionalCard> cards)
  46. {
  47. this.cards.AddRange(cards);
  48. }
  49. }
  50. }