ItemFilter.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <ReferenceCounter.h>
  3. #include <functional>
  4. #include <Array.h>
  5. class Item;
  6. class ItemType;
  7. class ItemSlot;
  8. class ItemFilter : public virtual Framework::ReferenceCounter
  9. {
  10. public:
  11. ItemFilter();
  12. virtual bool matchItem(const Item* zItem) const;
  13. virtual bool matchSourceSlot(ItemSlot* zSlot) const;
  14. virtual bool matchTargetSlot(ItemSlot* zSlot) const;
  15. };
  16. class CombinedItemFilter : public ItemFilter
  17. {
  18. private:
  19. ItemFilter* filterA;
  20. ItemFilter* filterB;
  21. std::function<bool(bool, bool)> op;
  22. public:
  23. CombinedItemFilter(ItemFilter* filterA, ItemFilter* filterB, std::function<bool(bool, bool)> op);
  24. ~CombinedItemFilter();
  25. bool matchItem(const Item* zItem) const override;
  26. bool matchSourceSlot(ItemSlot* zSlot) const override;
  27. bool matchTargetSlot(ItemSlot* zSlot) const override;
  28. };
  29. class AnyItemFilter : public ItemFilter
  30. {
  31. public:
  32. AnyItemFilter();
  33. bool matchItem(const Item* zItem) const override;
  34. };
  35. class TypeItemFilter : public ItemFilter
  36. {
  37. private:
  38. const ItemType* zType;
  39. public:
  40. TypeItemFilter(const ItemType* zType);
  41. bool matchItem(const Item* zItem) const override;
  42. };
  43. class SpecificSlotFilter : public ItemFilter
  44. {
  45. private:
  46. int sourceSlotId;
  47. int targetSlotId;
  48. public:
  49. SpecificSlotFilter(int sourceSlotId, int targetSlotId);
  50. bool matchSourceSlot(ItemSlot* zSlot) const override;
  51. bool matchTargetSlot(ItemSlot* zSlot) const override;
  52. };
  53. class SourceSlotBlacklistFilter : public ItemFilter
  54. {
  55. private:
  56. Framework::Array<int> blackList;
  57. public:
  58. SourceSlotBlacklistFilter();
  59. void addBlackListSlotId(int id);
  60. bool matchSourceSlot(ItemSlot* zSlot) const override;
  61. bool matchTargetSlot(ItemSlot* zSlot) const override;
  62. };