CardData.cs 854 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. [Serializable]
  3. public class CardData
  4. {
  5. public CardData(CardData.Suit suit, CardData.Rank rank)
  6. {
  7. this.m_Suit = suit;
  8. this.m_Rank = rank;
  9. }
  10. public CardData.Suit CardSuit
  11. {
  12. get
  13. {
  14. return this.m_Suit;
  15. }
  16. }
  17. public CardData.Rank CardRank
  18. {
  19. get
  20. {
  21. return this.m_Rank;
  22. }
  23. }
  24. public int GetValue()
  25. {
  26. if (this.m_Rank < CardData.Rank.Jack)
  27. {
  28. return (int)(this.m_Rank + 1);
  29. }
  30. return 10;
  31. }
  32. public string GetAssetName()
  33. {
  34. return this.m_Rank.ToString().ToLower() + this.m_Suit.ToString().ToLower();
  35. }
  36. private const int m_MaxCardValue = 10;
  37. private CardData.Suit m_Suit;
  38. private CardData.Rank m_Rank;
  39. public enum Suit
  40. {
  41. Hearts,
  42. Diamonds,
  43. Spades,
  44. Clubs
  45. }
  46. public enum Rank
  47. {
  48. Ace,
  49. Two,
  50. Three,
  51. Four,
  52. Five,
  53. Six,
  54. Seven,
  55. Eight,
  56. Nine,
  57. Ten,
  58. Jack,
  59. Queen,
  60. King
  61. }
  62. }