123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #pragma once
- #include <ReferenceCounter.h>
- #include <Text.h>
- #include "Item.h"
- class ItemModifier : public virtual Framework::ReferenceCounter
- {
- public:
- ItemModifier();
- virtual void applyOn(Item* zItem) = 0;
- };
- class ConsumeItemModifier : public ItemModifier
- {
- public:
- ConsumeItemModifier();
- void applyOn(Item* zItem) override;
- };
- class ConsumeItemModifierFactory
- : public SubTypeFactory<ItemModifier, ConsumeItemModifier>
- {
- public:
- ConsumeItemModifierFactory();
- ConsumeItemModifier* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(ConsumeItemModifier* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(ConsumeItemModifier* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
- class DoNothingModifier : public ItemModifier
- {
- public:
- DoNothingModifier();
- void applyOn(Item* zItem) override;
- };
- class DoNothingModifierFactory
- : public SubTypeFactory<ItemModifier, DoNothingModifier>
- {
- public:
- DoNothingModifierFactory();
- DoNothingModifier* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(DoNothingModifier* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(DoNothingModifier* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
- class AttributeItemModifier : public ItemModifier
- {
- private:
- Framework::RCArray<Framework::Text> attributes;
- Framework::RCArray<Framework::JSON::JSONValue> values;
- public:
- AttributeItemModifier();
- void applyOn(Item* zItem) override;
- void addAttribute(Framework::Text name, Framework::JSON::JSONValue* value);
- const Framework::RCArray<Framework::Text>& getAttributes() const;
- const Framework::RCArray<Framework::JSON::JSONValue>& getValues() const;
- };
- class AttributeItemModifierFactory
- : public SubTypeFactory<ItemModifier, AttributeItemModifier>
- {
- public:
- AttributeItemModifierFactory();
- AttributeItemModifier* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(AttributeItemModifier* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(AttributeItemModifier* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
- class CombinedItemModifier : public ItemModifier
- {
- Framework::RCArray<ItemModifier> modifiers;
- public:
- CombinedItemModifier();
- void applyOn(Item* zItem) override;
- void addModifier(ItemModifier* zModifier);
- const Framework::RCArray<ItemModifier>& getModifiers() const;
- };
- class CombinedItemModifierFactory
- : public SubTypeFactory<ItemModifier, CombinedItemModifier>
- {
- public:
- CombinedItemModifierFactory();
- CombinedItemModifier* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(CombinedItemModifier* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(CombinedItemModifier* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
|