Example #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jsonObject = JObject.Load(reader);

            if (Enum.TryParse <GambitConditionTypes>(jsonObject["GambitConditionType"].Value <string>(), out var parsedEnum))
            {
                GambitCondition condition;
                switch (parsedEnum)
                {
                case GambitConditionTypes.EnemyCastingSpell:
                    condition = new EnemyCastingSpellCondition();
                    break;

                case GambitConditionTypes.HasAura:
                    condition = new HasAuraCondition();
                    break;

                case GambitConditionTypes.HpPercentBelow:
                    condition = new HpPercentBelowCondition();
                    break;

                case GambitConditionTypes.HpPercentBetween:
                    condition = new HpPercentBetweenCondition();
                    break;

                case GambitConditionTypes.InInstance:
                    condition = new InInstanceCondition();
                    break;

                case GambitConditionTypes.NotInInstance:
                    condition = new NotInInstanceCondition();
                    break;

                case GambitConditionTypes.IsJob:
                    condition = new IsJobCondition();
                    break;

                case GambitConditionTypes.IsRole:
                    condition = new IsRoleCondition();
                    break;

                case GambitConditionTypes.TargetName:
                    condition = new TargetNameCondition();
                    break;

                case GambitConditionTypes.PlayerHasAura:
                    condition = new PlayerHasAuraCondition();
                    break;

                case GambitConditionTypes.LastSpell:
                    condition = new LastSpellCondition();
                    break;

                case GambitConditionTypes.EnemiesNearby:
                    condition = new EnemiesNearbyCondition();
                    break;

                case GambitConditionTypes.PlayerDoesNotHaveAura:
                    condition = new PlayerDoesNotHaveAuraCondition();
                    break;

                case GambitConditionTypes.DoesNotHaveAura:
                    condition = new DoesNotHaveAuraCondition();
                    break;

                case GambitConditionTypes.PlayerInCombat:
                    condition = new PlayerInCombatCondition();
                    break;

                case GambitConditionTypes.PlayerNotInCombat:
                    condition = new PlayerNotInCombatCondition();
                    break;

                case GambitConditionTypes.MonkChakra:
                    condition = new MonkChakraCondition();
                    break;

                case GambitConditionTypes.MonkGreasedLightning:
                    condition = new MonkGreasedLightningCondition();
                    break;

                case GambitConditionTypes.SpellOffCooldown:
                    condition = new SpellOffCooldownCondition();
                    break;

                case GambitConditionTypes.BardRepertoire:
                    condition = new BardRepertoireCondition();
                    break;

                case GambitConditionTypes.MachinistHeat:
                    condition = new MachinistHeatCondition();
                    break;

                case GambitConditionTypes.DragoonGaze:
                    condition = new DragoonGazeCondition();
                    break;

                case GambitConditionTypes.DragoonGaugeTimer:
                    condition = new DragoonGazeCondition();
                    break;

                case GambitConditionTypes.TargetIsBoss:
                    condition = new TargetIsBossCondition();
                    break;

                case GambitConditionTypes.NinjaHuton:
                    condition = new NinjaHutonCondition();
                    break;

                case GambitConditionTypes.NinjaNinki:
                    condition = new NinjaNinkiCondition();
                    break;

                case GambitConditionTypes.SamuraiSen:
                    condition = new SamuraiSenCondition();
                    break;

                case GambitConditionTypes.SamuraiKenki:
                    condition = new SamuraiKenkiCondition();
                    break;

                case GambitConditionTypes.HasPet:
                    condition = new HasPetCondition();
                    break;

                case GambitConditionTypes.CombatTime:
                    condition = new CombatTimeCondition();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                serializer.Populate(jsonObject.CreateReader(), condition);
                return(condition);
            }
            throw new InvalidCastException();
        }
        private static IGambitCondition ConditionFromString(string conditionString)
        {
            IGambitCondition condition;

            switch (conditionString)
            {
            case "EnemyCastingSpell":
                condition = new EnemyCastingSpellCondition {
                    SpellName = "Spell Name", TargetAnyone = true
                };
                break;

            case "HasAura":
                condition = new HasAuraCondition {
                    AuraName = "Aura Name"
                };
                break;

            case "SpellOffCooldown":
                condition = new SpellOffCooldownCondition {
                    SpellName = "The Spell's Name"
                };
                break;

            case "HpPercentBelow":
                condition = new HpPercentBelowCondition();
                break;

            case "HpPercentBetween":
                condition = new HpPercentBetweenCondition();
                break;

            case "MpPercent":
                condition = new MpPercentCondition {
                    MPPercentageValue = 50, Above = true, AboveOrEqual = false, Lower = false, LowerOrEqual = false
                };
                break;

            case "InInstance":
                condition = new InInstanceCondition();
                break;

            case "NotInInstance":
                condition = new NotInInstanceCondition();
                break;

            case "IsJob":
                condition = new IsJobCondition();
                break;

            case "IsRole":
                condition = new IsRoleCondition();
                break;

            case "PlayerHasAura":
                condition = new PlayerHasAuraCondition {
                    AuraName = "Aura Name"
                };
                break;

            case "TargetName":
                condition = new TargetNameCondition {
                    TargetName = "Target Name"
                };
                break;

            case "LastSpell":
                condition = new LastSpellCondition {
                    SpellName = "Spell Name"
                };
                break;

            case "EnemiesNearby":
                condition = new EnemiesNearbyCondition {
                    Count = 2, Range = 5, ByPlayer = false, ByTargetObject = true
                };
                break;

            case "PlayerDoesNotHaveAura":
                condition = new PlayerDoesNotHaveAuraCondition()
                {
                    AuraName = "Aura Name"
                };
                break;

            case "DoesNotHaveAura":
                condition = new DoesNotHaveAuraCondition()
                {
                    AuraName = "Aura Name"
                };
                break;

            case "PlayerInCombat":
                condition = new PlayerInCombatCondition();
                break;

            case "PlayerNotInCombat":
                condition = new PlayerNotInCombatCondition();
                break;

            case "MonkChakra":
                condition = new MonkChakraCondition();
                break;

            case "MonkGreasedLightning":
                condition = new MonkGreasedLightningCondition();
                break;

            case "BardRepertoire":
                condition = new BardRepertoireCondition();
                break;

            case "MachinistHeat":
                condition = new MachinistHeatCondition();
                break;

            case "DragoonGaze":
                condition = new DragoonGazeCondition();
                break;

            case "DragoonGaugeTimer":
                condition = new DragoonGaugeTimerCondition();
                break;

            case "SamuraiSen":
                condition = new SamuraiSenCondition();
                break;

            case "SamuraiKenki":
                condition = new SamuraiKenkiCondition();
                break;

            case "NinjaNinki":
                condition = new NinjaNinkiCondition();
                break;

            case "NinjaHuton":
                condition = new NinjaHutonCondition();
                break;

            case "TargetIsBoss":
                condition = new TargetIsBossCondition();
                break;

            case "HasPet":
                condition = new HasPetCondition();
                break;

            case "CombatTime":
                condition = new CombatTimeCondition();
                break;

            default:
                return(null);
            }

            return(condition);
        }