9
3

Trade.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "../common/types.h"
  3. #include <map>
  4. class Item;
  5. class Entity;
  6. struct TradeItemInfo {
  7. Item* item;
  8. int32 quantity;
  9. };
  10. class Trade {
  11. public:
  12. Trade(Entity* trader1, Entity* trader2);
  13. ~Trade();
  14. int8 AddItemToTrade(Entity* character, Item* item, int8 quantity, int8 slot);
  15. void RemoveItemFromTrade(Entity* character, int8 slot);
  16. void AddCoinToTrade(Entity* character, int64 amount);
  17. void RemoveCoinFromTrade(Entity* character, int64 amount);
  18. Entity* GetTradee(Entity* character);
  19. bool SetTradeAccepted(Entity* character);
  20. bool HasAcceptedTrade(Entity* character);
  21. void CancelTrade(Entity* character);
  22. int8 CheckItem(Entity* trader, Item* item, bool other_is_bot);
  23. private:
  24. void Trader1ItemAdd(Item* item, int8 quantity, int8 slot);
  25. void Trader2ItemAdd(Item* item, int8 quantity, int8 slot);
  26. void CompleteTrade();
  27. void OpenTradeWindow();
  28. void SendTradePacket();
  29. void CalculateCoins(int64 val, int32& plat, int32& gold, int32& silver, int32& copper);
  30. int8 GetNextFreeSlot(Entity* character);
  31. Entity* trader1;
  32. map<int8, TradeItemInfo> trader1_items;
  33. int64 trader1_coins;
  34. bool trader1_accepted;
  35. Entity* trader2;
  36. map<int8, TradeItemInfo> trader2_items;
  37. int64 trader2_coins;
  38. bool trader2_accepted;
  39. };