ItemFilter.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <Array.h>
  3. #include <functional>
  4. #include <ReferenceCounter.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,
  24. ItemFilter* filterB,
  25. std::function<bool(bool, bool)> op);
  26. ~CombinedItemFilter();
  27. bool matchItem(const Item* zItem) const override;
  28. bool matchSourceSlot(ItemSlot* zSlot) const override;
  29. bool matchTargetSlot(ItemSlot* zSlot) const override;
  30. };
  31. class AnyItemFilter : public ItemFilter
  32. {
  33. public:
  34. AnyItemFilter();
  35. bool matchItem(const Item* zItem) const override;
  36. };
  37. class TypeItemFilter : public ItemFilter
  38. {
  39. private:
  40. const ItemType* zType;
  41. public:
  42. TypeItemFilter(const ItemType* zType);
  43. bool matchItem(const Item* zItem) const override;
  44. };
  45. class SpecificSlotFilter : public ItemFilter
  46. {
  47. private:
  48. int sourceSlotId;
  49. int targetSlotId;
  50. public:
  51. SpecificSlotFilter(int sourceSlotId, int targetSlotId);
  52. bool matchSourceSlot(ItemSlot* zSlot) const override;
  53. bool matchTargetSlot(ItemSlot* zSlot) const override;
  54. };
  55. class SourceSlotBlacklistFilter : public ItemFilter
  56. {
  57. private:
  58. Framework::Array<int> blackList;
  59. public:
  60. SourceSlotBlacklistFilter();
  61. void addBlackListSlotId(int id);
  62. bool matchSourceSlot(ItemSlot* zSlot) const override;
  63. bool matchTargetSlot(ItemSlot* zSlot) const override;
  64. };