Ejemplo n.º 1
0
        private static bool ProcessCommand(BaseFilter newFilter, string command)
        {
            command = command.Trim();
            if (command.Contains(PARAMETER_AFFINITYACTIVE))
            {
                var affinityActiveCommand = new AffinityActiveFilter {
                    BAffinityActive = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(affinityActiveCommand);
                return(true);
            }
            if (command.Contains(PARAMETER_IGNOREAFFINITY))
            {
                var affinityIgnoreCommand = new AffinityIgnoreFilter {
                    BAffinityIgnore = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(affinityIgnoreCommand);
                return(true);
            }
            if (command.Contains(PARAMETER_IDENTIFIED))
            {
                var identCommand = new IdentifiedItemFilter {
                    BIdentified = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(identCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISCORRUPTED))
            {
                var corruptedCommand = new CorruptedItemFilter {
                    BCorrupted = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(corruptedCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISELDER))
            {
                var elderCommand = new ElderItemFiler {
                    isElder = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(elderCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISSHAPER))
            {
                var shaperCommand = new ShaperItemFilter {
                    isShaper = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(shaperCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISCRUSADER))
            {
                var crusaderCommand = new CrusaderItemFilter {
                    isCrusader = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(crusaderCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISHUNTER))
            {
                var hunterCommand = new HunterItemFilter {
                    isHunter = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(hunterCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISREDEEMER))
            {
                var redeemerCommand = new RedeemerItemFilter {
                    isRedeemer = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(redeemerCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISWARLORD))
            {
                var warordCommand = new WarlordItemFilter {
                    isWarlord = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(warordCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISINFLUENCED))
            {
                var influencedCommand = new AnyInfluenceItemFilter {
                    isInfluenced = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(influencedCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISBLIGHTEDMAP))
            {
                var blightedMapCommand = new BlightedMapFilter {
                    isBlightMap = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(blightedMapCommand);
                return(true);
            }

            if (command.Contains(PARAMETER_ISELDERGUARDIANMAP))
            {
                var elderGuardianMapCommand = new ElderGuardianMapFilter
                {
                    isElderGuardianMap = command[0] != SYMBOL_NOT
                };
                newFilter.Filters.Add(elderGuardianMapCommand);
                return(true);
            }

            string parameter;
            string operation;
            string value;

            if (!ParseCommand(command, out parameter, out operation, out value))
            {
                DebugWindow.LogMsg($"Unknown operation: {command}", 5, Color.Red);
                return(false);
            }

            var stringComp = new FilterParameterCompare {
                CompareString = value
            };

            switch (parameter.ToLower())
            {
            case PARAMETER_CLASSNAME:
                stringComp.StringParameter = data => data.ClassName;
                break;

            case PARAMETER_BASENAME:
                stringComp.StringParameter = data => data.BaseName;
                break;

            case PARAMETER_NAME:
                stringComp.StringParameter = data => data.Name;
                break;

            case PARAMETER_PATH:
                stringComp.StringParameter = data => data.Path;
                break;

            case PARAMETER_DESCRIPTION:
                stringComp.StringParameter = data => data.Description;
                break;

            case PARAMETER_RARITY:
                stringComp.StringParameter = data => data.Rarity.ToString();
                break;

            case PARAMETER_QUALITY:
                stringComp.IntParameter    = data => data.ItemQuality;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.ItemQuality.ToString();
                break;

            case PARAMETER_MapTier:
                stringComp.IntParameter    = data => data.MapTier;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.MapTier.ToString();
                break;

            case PARAMETER_ILVL:
                stringComp.IntParameter    = data => data.ItemLevel;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.ItemLevel.ToString();
                break;

            case PARAMETER_NUMBER_OF_SOCKETS:
                stringComp.IntParameter    = data => data.NumberOfSockets;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.NumberOfSockets.ToString();
                break;

            case PARAMETER_LARGEST_LINK_SIZE:
                stringComp.IntParameter    = data => data.LargestLinkSize;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.LargestLinkSize.ToString();
                break;

            case PARAMETER_VEILED:
                stringComp.IntParameter    = data => data.Veiled;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.Veiled.ToString();
                break;

            case PARAMETER_FRACTUREDMODS:
                stringComp.IntParameter    = data => data.Fractured;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.Fractured.ToString();
                break;

            case PARAMETER_DELIRIUMREWARDSAMOUNT:
                stringComp.IntParameter    = data => data.DeliriumStacks;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.DeliriumStacks.ToString();
                break;

            case PARAMETER_SKILLGEMLEVEL:
                stringComp.IntParameter    = data => data.SkillGemLevel;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.SkillGemLevel.ToString();
                break;

            case PARAMETER_METAMORPHREWARDSAMOUNT:
                stringComp.IntParameter    = data => data.MetamorphSampleRewardsAmount;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.MetamorphSampleRewardsAmount.ToString();
                break;

            case PARAMETER_METAMORPHGOODREWARDSAMOUNT:
                stringComp.IntParameter    = data => data.MetamorphSampleGoodRewardsAmount;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.MetamorphSampleGoodRewardsAmount.ToString();
                break;

            case PARAMETER_METAMORPHBADREWARDSAMOUNT:
                stringComp.IntParameter    = data => data.MetamorphSampleBadRewardsAmount;
                stringComp.CompareInt      = int.Parse(value);
                stringComp.StringParameter = data => data.MetamorphSampleBadRewardsAmount.ToString();
                break;

            default:
                DebugWindow.LogMsg($"Filter parser: Parameter is not defined in code: {parameter}", 10);
                return(false);
            }

            switch (operation.ToLower())
            {
            case OPERATION_EQUALITY:
                stringComp.CompDeleg = data => stringComp.StringParameter(data).Equals(stringComp.CompareString);
                break;

            case OPERATION_NONEQUALITY:
                stringComp.CompDeleg = data => !stringComp.StringParameter(data).Equals(stringComp.CompareString);
                break;

            case OPERATION_CONTAINS:
                stringComp.CompDeleg = data => stringComp.StringParameter(data).Contains(stringComp.CompareString);
                break;

            case OPERATION_NOTCONTAINS:
                stringComp.CompDeleg = data => !stringComp.StringParameter(data).Contains(stringComp.CompareString);
                break;

            case OPERATION_BIGGER:
                if (stringComp.IntParameter == null)
                {
                    DebugWindow.LogMsg(
                        $"Filter parser error: Can't compare string parameter with {OPERATION_BIGGER} (numerical) operation. Statement: {command}",
                        10);

                    return(false);
                }

                stringComp.CompDeleg = data => stringComp.IntParameter(data) > stringComp.CompareInt;
                break;

            case OPERATION_LESS:
                if (stringComp.IntParameter == null)
                {
                    DebugWindow.LogMsg(
                        $"Filter parser error: Can't compare string parameter with {OPERATION_LESS} (numerical) operation. Statement: {command}",
                        10);

                    return(false);
                }

                stringComp.CompDeleg = data => stringComp.IntParameter(data) < stringComp.CompareInt;
                break;

            case OPERATION_LESSEQUAL:
                if (stringComp.IntParameter == null)
                {
                    DebugWindow.LogMsg(
                        $"Filter parser error: Can't compare string parameter with {OPERATION_LESSEQUAL} (numerical) operation. Statement: {command}",
                        10);

                    return(false);
                }

                stringComp.CompDeleg = data => stringComp.IntParameter(data) <= stringComp.CompareInt;
                break;

            case OPERATION_BIGGERQUAL:
                if (stringComp.IntParameter == null)
                {
                    DebugWindow.LogMsg(
                        $"Filter parser error: Can't compare string parameter with {OPERATION_BIGGERQUAL} (numerical) operation. Statement: {command}",
                        10);

                    return(false);
                }

                stringComp.CompDeleg = data => stringComp.IntParameter(data) >= stringComp.CompareInt;
                break;

            default:
                DebugWindow.LogMsg($"Filter parser: Operation is not defined in code: {operation}", 10);
                return(false);
            }

            newFilter.Filters.Add(stringComp);
            return(true);
        }
Ejemplo n.º 2
0
        private static bool ProcessCommand(BaseFilter newFilter, string command)
        {
            command = command.Trim();

            if (command.Contains(PARAMETER_IDENTIFIED))
            {
                var identCommand = new IdentifiedItemFilter {BIdentified = command[0] != SYMBOL_NOT};
                newFilter.Filters.Add(identCommand);
                return true;
            }

            if (command.Contains(PARAMETER_ISCORRUPTED))
            {
                var corruptedCommand = new CorruptedItemFilter { BCorrupted = command[0] != SYMBOL_NOT };
                newFilter.Filters.Add(corruptedCommand);
                return true;
            }

            if (command.Contains(PARAMETER_ISELDER))
            {
                var elderCommand = new ElderItemFiler {isElder = command[0] != SYMBOL_NOT};
                newFilter.Filters.Add(elderCommand);
                return true;
            }

            if (command.Contains(PARAMETER_ISSHAPER))
            {
                var shaperCommand = new ShaperItemFilter {isShaper = command[0] != SYMBOL_NOT};
                newFilter.Filters.Add(shaperCommand);
                return true;
            }

            if (command.Contains(PARAMETER_ISCRUSADER))
            {
                var crusaderCommand = new CrusaderItemFilter { isCrusader = command[0] != SYMBOL_NOT };
                newFilter.Filters.Add(crusaderCommand);
                return true;
            }

            if (command.Contains(PARAMETER_ISHUNTER))
            {
                var hunterCommand = new HunterItemFilter { isHunter = command[0] != SYMBOL_NOT };
                newFilter.Filters.Add(hunterCommand);
                return true;
            }

            if (command.Contains(PARAMETER_ISREDEEMER))
            {
                var redeemerCommand = new RedeemerItemFilter { isRedeemer = command[0] != SYMBOL_NOT };
                newFilter.Filters.Add(redeemerCommand);
                return true;
            }

            if (command.Contains(PARAMETER_ISWARLORD))
            {
                var warordCommand = new WarlordItemFilter { isWarlord = command[0] != SYMBOL_NOT };
                newFilter.Filters.Add(warordCommand);
                return true;
            }

            if (command.Contains(PARAMETER_ISINFLUENCED))
            {
                var influencedCommand = new AnyInfluenceItemFilter { isInfluenced = command[0] != SYMBOL_NOT };
                newFilter.Filters.Add(influencedCommand);
                return true;
            }

            if (command.Contains(PARAMETER_ISBLIGHTEDMAP))
            {
                var blightedMapCommand = new BlightedMapFilter { isBlightMap = command[0] != SYMBOL_NOT };
                newFilter.Filters.Add(blightedMapCommand);
                return true;
            }
            if (command.Contains(PARAMETER_ISELDERGUARDIANMAP))
            {
                var elderGuardianMapCommand = new ElderGuardianMapFilter { isElderGuardianMap = command[0] != SYMBOL_NOT };
                newFilter.Filters.Add(elderGuardianMapCommand);
                return true;
            }
            /*
            if (command.Contains(PARAMETER_ISSYNTHESISED))
            {
                var synthesisedCommand = new SynthesisedItemFilter { IsSynthesised = command[0] != SYMBOL_NOT };
                newFilter.Filters.Add(synthesisedCommand);
                return true;
            }*/

            string parameter;
            string operation;
            string value;

            if (!ParseCommand(command, out parameter, out operation, out value))
            {
                DebugWindow.LogMsg("Filter parser: Can't parse filter part: " + command, 5);
                return false;
            }

            var stringComp = new FilterParameterCompare {CompareString = value};

            switch (parameter.ToLower())
            {
                case PARAMETER_CLASSNAME:
                    stringComp.StringParameter = data => data.ClassName;
                    break;
                case PARAMETER_BASENAME:
                    stringComp.StringParameter = data => data.BaseName;
                    break;
                case PARAMETER_NAME:
                    stringComp.StringParameter = data => data.Name;
                    break;
                case PARAMETER_PATH:
                    stringComp.StringParameter = data => data.Path;
                    break;
                case PARAMETER_DESCRIPTION:
                    stringComp.StringParameter = data => data.Description;
                    break;
                    /*
                case PARAMETER_CLUSTERJEWELBASE:
                    stringComp.StringParameter = data => data.ClusterJewelBase;
                    break;*/
                case PARAMETER_RARITY:
                    stringComp.StringParameter = data => data.Rarity.ToString();
                    break;
                case PARAMETER_QUALITY:
                    stringComp.IntParameter = data => data.ItemQuality;
                    stringComp.CompareInt = int.Parse(value);
                    stringComp.StringParameter = data => data.ItemQuality.ToString();
                    break;
                case PARAMETER_MapTier:
                    stringComp.IntParameter = data => data.MapTier;
                    stringComp.CompareInt = int.Parse(value);
                    stringComp.StringParameter = data => data.MapTier.ToString();
                    break;
                case PARAMETER_ILVL:
                    stringComp.IntParameter = data => data.ItemLevel;
                    stringComp.CompareInt = int.Parse(value);
                    stringComp.StringParameter = data => data.ItemLevel.ToString();
                    break;
                case PARAMETER_NUMBER_OF_SOCKETS:
                    stringComp.IntParameter = data => data.NumberOfSockets;
                    stringComp.CompareInt = int.Parse(value);
                    stringComp.StringParameter = data => data.NumberOfSockets.ToString();
                    break;   
                case PARAMETER_LARGEST_LINK_SIZE:
                    stringComp.IntParameter = data => data.LargestLinkSize;
                    stringComp.CompareInt = int.Parse(value);
                    stringComp.StringParameter = data => data.LargestLinkSize.ToString();
                    break;
                case PARAMETER_VEILED:
                    stringComp.IntParameter = data => data.Veiled;
                    stringComp.CompareInt = int.Parse(value);
                    stringComp.StringParameter = data => data.Veiled.ToString();
                    break;
                case PARAMETER_FRACTUREDMODS:
                    stringComp.IntParameter = data => data.Fractured;
                    stringComp.CompareInt = int.Parse(value);
                    stringComp.StringParameter = data => data.Fractured.ToString();
                    break;
                    /*
                case PARAMTER_CLUSTERJEWELPASSIVES:
                    stringComp.IntParameter = data => data.ClusterJewelpassives;
                    stringComp.CompareInt = int.Parse(value);
                    stringComp.StringParameter = data => data.ClusterJewelpassives.ToString();
                    break;*/


                default:
                    DebugWindow.LogMsg($"Filter parser: Parameter is not defined in code: {parameter}", 10);
                    return false;
            }

            switch (operation.ToLower())
            {
                case OPERATION_EQUALITY:
                    stringComp.CompDeleg = data => stringComp.StringParameter(data).Equals(stringComp.CompareString);
                    break;
                case OPERATION_NONEQUALITY:
                    stringComp.CompDeleg = data => !stringComp.StringParameter(data).Equals(stringComp.CompareString);
                    break;
                case OPERATION_CONTAINS:
                    stringComp.CompDeleg = data => stringComp.StringParameter(data).Contains(stringComp.CompareString);
                    break;
                case OPERATION_NOTCONTAINS:
                    stringComp.CompDeleg = data => !stringComp.StringParameter(data).Contains(stringComp.CompareString);
                    break;

                case OPERATION_BIGGER:
                    if (stringComp.IntParameter == null)
                    {
                        DebugWindow.LogMsg(
                            $"Filter parser error: Can't compare string parameter with {OPERATION_BIGGER} (numerical) operation. Statement: {command}",
                            10);

                        return false;
                    }

                    stringComp.CompDeleg = data => stringComp.IntParameter(data) > stringComp.CompareInt;
                    break;
                case OPERATION_LESS:
                    if (stringComp.IntParameter == null)
                    {
                        DebugWindow.LogMsg(
                            $"Filter parser error: Can't compare string parameter with {OPERATION_LESS} (numerical) operation. Statement: {command}",
                            10);

                        return false;
                    }

                    stringComp.CompDeleg = data => stringComp.IntParameter(data) < stringComp.CompareInt;
                    break;
                case OPERATION_LESSEQUAL:
                    if (stringComp.IntParameter == null)
                    {
                        DebugWindow.LogMsg(
                            $"Filter parser error: Can't compare string parameter with {OPERATION_LESSEQUAL} (numerical) operation. Statement: {command}",
                            10);

                        return false;
                    }

                    stringComp.CompDeleg = data => stringComp.IntParameter(data) <= stringComp.CompareInt;
                    break;

                case OPERATION_BIGGERQUAL:
                    if (stringComp.IntParameter == null)
                    {
                        DebugWindow.LogMsg(
                            $"Filter parser error: Can't compare string parameter with {OPERATION_BIGGERQUAL} (numerical) operation. Statement: {command}",
                            10);

                        return false;
                    }

                    stringComp.CompDeleg = data => stringComp.IntParameter(data) >= stringComp.CompareInt;
                    break;

                default:
                    DebugWindow.LogMsg($"Filter parser: Operation is not defined in code: {operation}", 10);
                    return false;
            }

            newFilter.Filters.Add(stringComp);
            return true;
        }