TTCardInfo.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Microsoft.Xna.Framework;
  2. namespace OpenVIII
  3. {
  4. public class TTCardInfo
  5. {
  6. #region Fields
  7. private const byte mask = 0x7F;
  8. #endregion Fields
  9. #region Constructors
  10. public TTCardInfo()
  11. {
  12. Unlocked = false;
  13. Qty = 0;
  14. Location = 0;
  15. }
  16. public TTCardInfo(byte raw,byte location = 0)
  17. {
  18. Unlocked = ((raw >> 7) != 0);
  19. Qty = (byte)MathHelper.Clamp(raw & mask, 0, 100);
  20. Location = location;
  21. }
  22. public TTCardInfo(bool unlocked, byte qty, byte location = 0)
  23. {
  24. Unlocked = unlocked;
  25. Qty = (byte)MathHelper.Clamp(qty & mask, 0, 100);
  26. Location = location;
  27. }
  28. #endregion Constructors
  29. #region Properties
  30. /// <summary>
  31. /// Location is really for the last 33 cards that are unique. It's set to which npc has the card.
  32. /// </summary>
  33. public byte Location { get; set; }
  34. /// <summary>
  35. /// The last 33 cards only have 1 copy. Rest can have up to 100.
  36. /// </summary>
  37. public byte Qty { get; set; }
  38. /// <summary>
  39. /// Unlocked is 1st bit of qty. If set the menu will show the card info. Else the game thinks
  40. /// you don't know about the card.
  41. /// </summary>
  42. public bool Unlocked { get; set; }
  43. #endregion Properties
  44. #region Methods
  45. /// <summary>
  46. /// Create a copy of this object.
  47. /// </summary>
  48. /// <returns></returns>
  49. public TTCardInfo Clone() => (TTCardInfo)MemberwiseClone();
  50. #endregion Methods
  51. }
  52. }