ItemFilter.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. };
  27. class AnyItemFilter : public ItemFilter
  28. {
  29. public:
  30. AnyItemFilter();
  31. bool matchItem(const Item* zItem) const override;
  32. };
  33. class TypeItemFilter : public ItemFilter
  34. {
  35. private:
  36. const ItemType* zType;
  37. public:
  38. TypeItemFilter(const ItemType* zType);
  39. bool matchItem(const Item* zItem) const override;
  40. };
  41. class SpecificSlotFilter : public ItemFilter
  42. {
  43. private:
  44. int sourceSlotId;
  45. int targetSlotId;
  46. public:
  47. SpecificSlotFilter(int sourceSlotId, int targetSlotId);
  48. bool matchSourceSlot(ItemSlot* zSlot) const override;
  49. bool matchTargetSlot(ItemSlot* zSlot) const override;
  50. };
  51. class SourceSlotBlacklistFilter : public ItemFilter
  52. {
  53. private:
  54. Framework::Array<int> blackList;
  55. public:
  56. SourceSlotBlacklistFilter();
  57. void addBlackListSlotId(int id);
  58. bool matchSourceSlot(ItemSlot* zSlot) const override;
  59. bool matchTargetSlot(ItemSlot* zSlot) const override;
  60. };