123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- #pragma once
- #include <Array.h>
- #include <functional>
- #include <ReferenceCounter.h>
- #include <TypeRegistry.h>
- class Item;
- class ItemType;
- class ItemSlot;
- class ItemFilter : public virtual Framework::ReferenceCounter
- {
- public:
- ItemFilter();
- virtual bool matchItem(const Item* zItem) const;
- virtual bool matchSourceSlot(ItemSlot* zSlot) const;
- virtual bool matchTargetSlot(ItemSlot* zSlot) const;
- virtual Framework::Text getLogicUIML() const = 0;
- };
- class CombinedItemFilter : public ItemFilter
- {
- private:
- Framework::RCArray<ItemFilter> filters;
- std::function<bool(bool, bool)> op;
- public:
- CombinedItemFilter();
- CombinedItemFilter(Framework::RCArray<ItemFilter> filters,
- std::function<bool(bool, bool)> op);
- bool matchItem(const Item* zItem) const override;
- bool matchSourceSlot(ItemSlot* zSlot) const override;
- bool matchTargetSlot(ItemSlot* zSlot) const override;
- Framework::Text getLogicUIML() const override;
- void addFilter(ItemFilter* filter);
- const Framework::RCArray<ItemFilter>& getFilters() const;
- void setOp(std::function<bool(bool, bool)> op);
- std::function<bool(bool, bool)> getOp() const;
- };
- class CombinedItemFilterFactory
- : public SubTypeFactory<ItemFilter, CombinedItemFilter>
- {
- public:
- CombinedItemFilterFactory();
- CombinedItemFilter* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(CombinedItemFilter* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(CombinedItemFilter* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
- class AnyItemFilter : public ItemFilter
- {
- public:
- AnyItemFilter();
- bool matchItem(const Item* zItem) const override;
- Framework::Text getLogicUIML() const override;
- };
- class AnyItemFilterFactory : public SubTypeFactory<ItemFilter, AnyItemFilter>
- {
- public:
- AnyItemFilterFactory();
- AnyItemFilter* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(AnyItemFilter* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(AnyItemFilter* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
- class TypeItemFilter : public ItemFilter
- {
- private:
- const ItemType* type;
- public:
- TypeItemFilter();
- bool matchItem(const Item* zItem) const override;
- Framework::Text getLogicUIML() const override;
- void setType(const ItemType* type);
- const ItemType* zType() const;
- };
- class TypeItemFilterFactory : public SubTypeFactory<ItemFilter, TypeItemFilter>
- {
- public:
- TypeItemFilterFactory();
- TypeItemFilter* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(TypeItemFilter* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(TypeItemFilter* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
- class SpecificSlotFilter : public ItemFilter
- {
- private:
- int sourceSlotId;
- int targetSlotId;
- public:
- SpecificSlotFilter(int sourceSlotId, int targetSlotId);
- bool matchSourceSlot(ItemSlot* zSlot) const override;
- bool matchTargetSlot(ItemSlot* zSlot) const override;
- Framework::Text getLogicUIML() const override;
- };
- class SourceSlotBlacklistFilter : public ItemFilter
- {
- private:
- Framework::Array<int> blackList;
- public:
- SourceSlotBlacklistFilter();
- void addBlackListSlotId(int id);
- bool matchSourceSlot(ItemSlot* zSlot) const override;
- bool matchTargetSlot(ItemSlot* zSlot) const override;
- Framework::Text getLogicUIML() const override;
- };
- class TargetSlotBlacklistFilter : public ItemFilter
- {
- private:
- Framework::Array<int> blackList;
- public:
- TargetSlotBlacklistFilter();
- void addBlackListSlotId(int id);
- bool matchSourceSlot(ItemSlot* zSlot) const override;
- bool matchTargetSlot(ItemSlot* zSlot) const override;
- Framework::Text getLogicUIML() const override;
- };
- class GroupItemFilter : public ItemFilter
- {
- private:
- Framework::RCArray<Framework::Text> groups;
- public:
- GroupItemFilter();
- bool matchItem(const Item* zItem) const override;
- Framework::Text getLogicUIML() const override;
- void addGroup(const Framework::Text group);
- const Framework::RCArray<Framework::Text>& getGroups() const;
- };
- class GroupItemFilterFactory
- : public SubTypeFactory<ItemFilter, GroupItemFilter>
- {
- public:
- GroupItemFilterFactory();
- GroupItemFilter* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(GroupItemFilter* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(GroupItemFilter* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
|