techitem.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #ifndef _TECHITEM_H_
  2. #define _TECHITEM_H_
  3. class CTechItem;
  4. class CCivTechItem;
  5. class CTechItemList : public FList<CTechItem>
  6. {
  7. public:
  8. BOOL CopyTo(CTechItemList * pDest);
  9. CTechItem * Find(ObjectType ot, ObjectID id);
  10. CTechItem * Remove(ObjectType ot, ObjectID id);
  11. CTechItem * RemoveNth(DWORD n);
  12. } ;
  13. typedef struct _PURCHASE_DATA
  14. {
  15. CTechItemList TechItemList;
  16. CTechItemList CanBuyList;
  17. CTechItemList BoughtList;
  18. TechTreeBitMask ttbmCurrent;
  19. DWORD dwLastCanBuyLength;
  20. } PURCHASE_DATA, *PPURCHASE_DATA;
  21. #define TECH_ITEM_NAME_LENGTH 64
  22. class CTechItem
  23. {
  24. protected:
  25. CHAR mszName[TECH_ITEM_NAME_LENGTH + 4];
  26. ObjectType mObjectType;
  27. ObjectID mObjectID;
  28. TechTreeBitMask mttbmRequired;
  29. TechTreeBitMask mttbmEffect;
  30. CTechItem * mpOriginal;
  31. BOOL mfEverBought;
  32. public:
  33. //
  34. // Hack to get the lists to work.
  35. //
  36. CTechItem * mpNext;
  37. public:
  38. CTechItem();
  39. CTechItem(CTechItem * pOriginal);
  40. //
  41. // Readers and writers.
  42. //
  43. CHAR * GetName() { return(mszName); }
  44. ObjectType GetObjectType() { return(mObjectType); }
  45. ObjectID GetObjectID() { return(mObjectID); }
  46. VOID SetName(CHAR * szName) { strcpy(mszName, szName); }
  47. VOID SetObjectType(ObjectType ot) { mObjectType = ot; }
  48. VOID SetObjectID(ObjectID id) { mObjectID = id; }
  49. VOID SetRequiredBitMask(TechTreeBitMask ttbm)
  50. { mttbmRequired = ttbm; }
  51. VOID SetEffectBitMask(TechTreeBitMask ttbm)
  52. { mttbmEffect = ttbm; }
  53. CTechItem * GetOriginal() { return(mpOriginal); }
  54. BOOL WasEverBought() { return(mfEverBought); }
  55. //
  56. // Our own unique methods.
  57. //
  58. CHAR * GetObjectTypeName();
  59. VOID SetWasBought(BOOL fBought);
  60. virtual CTechItem * Clone();
  61. virtual BOOL CanPurchase(PURCHASE_DATA * pPurchaseData);
  62. virtual VOID Purchase(PURCHASE_DATA * pPurchaseData);
  63. } ;
  64. class CCivTechItem : public CTechItem
  65. {
  66. protected:
  67. StationID mStartingStationID;
  68. DroneTypeID mConstructionDroneID;
  69. ShipID mEjectPodShipID;
  70. public:
  71. CCivTechItem();
  72. //
  73. // Readers and writers.
  74. //
  75. VOID SetStartingStationID(StationID id) { mStartingStationID = id; }
  76. VOID SetConstructionDroneID(DroneTypeID id)
  77. { mConstructionDroneID = id; }
  78. VOID SetEjectPodShipID(ShipID id)
  79. { mEjectPodShipID = id; }
  80. //
  81. // Our own unique methods.
  82. //
  83. virtual VOID Purchase(PURCHASE_DATA * pPurchaseData);
  84. } ;
  85. class CDroneTechItem : public CTechItem
  86. {
  87. protected:
  88. ObjectID mHullID;
  89. public:
  90. CDroneTechItem();
  91. CDroneTechItem(CDroneTechItem * pOriginal);
  92. //
  93. // Readers and writers.
  94. //
  95. ObjectID GetHullID() { return(mHullID); }
  96. VOID SetHullID(ObjectID id) { mHullID = id; }
  97. //
  98. // Our own unique methods.
  99. //
  100. virtual CTechItem * Clone();
  101. virtual VOID Purchase(PURCHASE_DATA * pPurchaseData);
  102. } ;
  103. #define MAX_UPGRADES_TO_STATION 10
  104. class CStationTechItem : public CTechItem
  105. {
  106. protected:
  107. TechTreeBitMask mttbmLocal;
  108. StationID mUpgradeStationID;
  109. //TechTreeBitMask mttbmUpgradeFrom;
  110. //TechTreeBitMask mttbmUpgrade[MAX_UPGRADES_TO_STATION];
  111. //DWORD mcUpgrades;
  112. public:
  113. CStationTechItem();
  114. CStationTechItem(CStationTechItem * pOriginal);
  115. //
  116. // Readers and writers.
  117. //
  118. VOID SetLocalBitMask(TechTreeBitMask ttbm)
  119. { mttbmLocal = ttbm; }
  120. //VOID SetUpgradeStationID(StationID stationID)
  121. // { mUpgradeStationID = stationID; }
  122. //VOID SetUpgradeFromBitMask(TechTreeBitMask ttbm)
  123. // { mttbmUpgradeFrom = ttbm; }
  124. //VOID AddUpgradeBitmask(TechTreeBitMask ttbm);
  125. //
  126. // Our own unique methods.
  127. //
  128. virtual CTechItem * Clone();
  129. virtual BOOL CanPurchase(PURCHASE_DATA * pPurchaseData);
  130. virtual VOID Purchase(PURCHASE_DATA * pPurchaseData);
  131. } ;
  132. #endif