ItemFilter.h 2.7 KB

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