ItemFilter.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. virtual Framework::Text getLogicUIML() const = 0;
  16. };
  17. class CombinedItemFilter : public ItemFilter
  18. {
  19. private:
  20. ItemFilter* filterA;
  21. ItemFilter* filterB;
  22. std::function<bool(bool, bool)> op;
  23. public:
  24. CombinedItemFilter(ItemFilter* filterA,
  25. ItemFilter* filterB,
  26. std::function<bool(bool, bool)> op);
  27. ~CombinedItemFilter();
  28. bool matchItem(const Item* zItem) const override;
  29. bool matchSourceSlot(ItemSlot* zSlot) const override;
  30. bool matchTargetSlot(ItemSlot* zSlot) const override;
  31. Framework::Text getLogicUIML() const override;
  32. };
  33. class AnyItemFilter : public ItemFilter
  34. {
  35. public:
  36. AnyItemFilter();
  37. bool matchItem(const Item* zItem) const override;
  38. Framework::Text getLogicUIML() const override;
  39. };
  40. class TypeItemFilter : public ItemFilter
  41. {
  42. private:
  43. const ItemType* zType;
  44. public:
  45. TypeItemFilter(const ItemType* zType);
  46. bool matchItem(const Item* zItem) const override;
  47. Framework::Text getLogicUIML() const override;
  48. };
  49. class SpecificSlotFilter : public ItemFilter
  50. {
  51. private:
  52. int sourceSlotId;
  53. int targetSlotId;
  54. public:
  55. SpecificSlotFilter(int sourceSlotId, int targetSlotId);
  56. bool matchSourceSlot(ItemSlot* zSlot) const override;
  57. bool matchTargetSlot(ItemSlot* zSlot) const override;
  58. Framework::Text getLogicUIML() const override;
  59. };
  60. class SourceSlotBlacklistFilter : public ItemFilter
  61. {
  62. private:
  63. Framework::Array<int> blackList;
  64. public:
  65. SourceSlotBlacklistFilter();
  66. void addBlackListSlotId(int id);
  67. bool matchSourceSlot(ItemSlot* zSlot) const override;
  68. bool matchTargetSlot(ItemSlot* zSlot) const override;
  69. Framework::Text getLogicUIML() const override;
  70. };
  71. class TargetSlotBlacklistFilter : public ItemFilter
  72. {
  73. private:
  74. Framework::Array<int> blackList;
  75. public:
  76. TargetSlotBlacklistFilter();
  77. void addBlackListSlotId(int id);
  78. bool matchSourceSlot(ItemSlot* zSlot) const override;
  79. bool matchTargetSlot(ItemSlot* zSlot) const override;
  80. Framework::Text getLogicUIML() const override;
  81. };