Esempio n. 1
0
        private bool MatchAdvanced(ItemRule rule, LootObject item)
        {
            bool result = false;
            bool[] tumbler = {false,false,false,false,false};
            List<int> ands = new List<int>();

            try
            {
                for(int i = 0; i < rule.Advanced.Count; i ++)
                {
                    if(rule.Advanced[i].keylink == 1) {ands.Add(i);}

                    if(rule.Advanced[i].keytype == 0)
                    {
                        switch(rule.Advanced[i].keycompare)
                        {
                            case 0:
                                if(item.DValue((DoubleValueKey)rule.Advanced[i].key) == rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 1:
                                if(item.DValue((DoubleValueKey)rule.Advanced[i].key) != rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 2:
                                if(item.DValue((DoubleValueKey)rule.Advanced[i].key) >= rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 3:
                                if(item.DValue((DoubleValueKey)rule.Advanced[i].key) <= rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                        }
                    }
                    else if(rule.Advanced[i].keytype == 1)
                    {
                        switch(rule.Advanced[i].keycompare)
                        {
                            case 0:
                                if(item.LValue((LongValueKey)rule.Advanced[i].key) == rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 1:
                                if(item.LValue((LongValueKey)rule.Advanced[i].key) != rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 2:
                                if(item.LValue((LongValueKey)rule.Advanced[i].key) >= rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 3:
                                if(item.LValue((LongValueKey)rule.Advanced[i].key) <= rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                        }
                    }
                }

                switch(rule.Advanced.Count)
                {
                    case 1:  //2 ^ 0 == 1
                        if(tumbler[0]) {result = true;}
                        break;
                    case 2:  //2 ^ 1 == 2
                        if(rule.Advanced[0].keylink == 1)
                        {
                            if(tumbler[0] && tumbler[1]) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 2)
                        {
                            if(tumbler[0] || tumbler[1]) {result = true;}
                        }
                        break;
                    case 3:  //2 ^ 2 == 4
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 1)
                        {
                            if(tumbler[0] && tumbler[1] && tumbler[2]) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 2)
                        {
                            if((tumbler[0] && tumbler[1]) || tumbler[2]) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 1)
                        {
                            if(tumbler[0] || (tumbler[1] && tumbler[2])) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 2)
                        {
                            if(tumbler[0] || tumbler[1] || tumbler[2]) {result = true;}
                        }
                        break;
                    case 4:  //2 ^ 3 == 8
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 1)
                        {
                            if(tumbler[0] && tumbler[1] && tumbler[2] && tumbler[3]) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 2)
                        {
                            if((tumbler[0] && tumbler[1] && tumbler[2]) || tumbler[3]) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 1)
                        {
                            if((tumbler[0] && tumbler[1]) || (tumbler[2] && tumbler[3])) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 1)
                        {
                            if(tumbler[0] || (tumbler[1] && tumbler[2] && tumbler[3])) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 2)
                        {
                            if((tumbler[0] && tumbler[1]) || tumbler[2] || tumbler[3]) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 1)
                        {
                            if(tumbler[0] || tumbler[1] || (tumbler[2] && tumbler[3])) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 2)
                        {
                            if(tumbler[0] || tumbler[1] || tumbler[2] || tumbler[3]) {result = true;}
                        }
                        else if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 2)
                        {
                            if(tumbler[0] || (tumbler[1] && tumbler[2]) || tumbler[3]) {result = true;}
                        }
                        break;
                    case 5:  //2 ^ 4 == 16
                        // 0 Or
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 1 && rule.Advanced[3].keylink == 1)
                        {
                            if(tumbler[0] && tumbler[1] && tumbler[2] && tumbler[3] && tumbler[4]) {result = true;}
                        }

                        // 1 Or
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 1 && rule.Advanced[3].keylink == 2)
                        {
                            if((tumbler[0] && tumbler[1] && tumbler[2] && tumbler[3]) || tumbler[4]) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 2 && rule.Advanced[3].keylink == 1)
                        {
                            if((tumbler[0] && tumbler[1] && tumbler[2]) || (tumbler[3] && tumbler[4])) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 1 && rule.Advanced[3].keylink == 1)
                        {
                            if((tumbler[0] && tumbler[1]) || (tumbler[2] && tumbler[3] && tumbler[4])) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 1 && rule.Advanced[3].keylink == 1)
                        {
                            if(tumbler[0] || (tumbler[1] && tumbler[2] && tumbler[3] && tumbler[4])) {result = true;}
                        }

                        // 2 Or
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 2 && rule.Advanced[3].keylink == 2)
                        {
                            if((tumbler[0] && tumbler[1] && tumbler[2]) || tumbler[3] || tumbler[4]) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 2 && rule.Advanced[3].keylink == 1)
                        {
                            if((tumbler[0] && tumbler[1]) || tumbler[2] || (tumbler[3] && tumbler[4])) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 1 && rule.Advanced[3].keylink == 1)
                        {
                            if(tumbler[0] || tumbler[1] || (tumbler[2] && tumbler[3] && tumbler[4])) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 1 && rule.Advanced[3].keylink == 2)
                        {
                            if((tumbler[0] && tumbler[1]) || (tumbler[2] && tumbler[3]) || tumbler[4]) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 2 && rule.Advanced[3].keylink == 1)
                        {
                            if(tumbler[0] || (tumbler[1] && tumbler[2]) || (tumbler[3] && tumbler[4])) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 1 && rule.Advanced[3].keylink == 2)
                        {
                            if(tumbler[0] || (tumbler[1] && tumbler[2] && tumbler[3]) ||  tumbler[4]) {result = true;}
                        }

                        // 3 Or
                        if(rule.Advanced[0].keylink == 1 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 2 && rule.Advanced[3].keylink == 2)
                        {
                            if((tumbler[0] && tumbler[1]) || tumbler[2] || tumbler[3] || tumbler[4]) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 1 && rule.Advanced[2].keylink == 2 && rule.Advanced[3].keylink == 2)
                        {
                            if(tumbler[0] || (tumbler[1] && tumbler[2]) || tumbler[3] || tumbler[4]) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 2 && rule.Advanced[3].keylink == 1)
                        {
                            if(tumbler[0] || tumbler[1] || tumbler[2] || (tumbler[3] && tumbler[4])) {result = true;}
                        }
                        if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 1 && rule.Advanced[3].keylink == 2)
                        {
                            if(tumbler[0] || tumbler[1] || (tumbler[2] && tumbler[3]) || tumbler[4]) {result = true;}
                        }

                        // 4 Or
                        if(rule.Advanced[0].keylink == 2 && rule.Advanced[1].keylink == 2 && rule.Advanced[2].keylink == 2 && rule.Advanced[3].keylink == 2)
                        {
                            if(tumbler[0] || tumbler[1] || tumbler[2] || tumbler[3] || tumbler[4]) {result = true;}
                        }

                        break;
                }
            }catch(Exception ex){LogError(ex);}
            return result;
        }
Esempio n. 2
0
        // Item Tracker ID functions begin here
        private void CheckSalvageItem(ref LootObject IOItemSalvage)
        {
            try
            {
                LootObject IoItemSalvageMirror = IOItemSalvage;

                if(IOItemSalvage.DValue(DoubleValueKey.SalvageWorkmanship) > 0)
                {
                    var salvagerulecheck = from allrules in SalvageRulesList
                        where (allrules.material == IoItemSalvageMirror.LValue(LongValueKey.Material)) &&
                                                (IoItemSalvageMirror.DValue(DoubleValueKey.SalvageWorkmanship) >= allrules.minwork) &&
                                                (IoItemSalvageMirror.DValue(DoubleValueKey.SalvageWorkmanship) <= (allrules.maxwork +0.99))
                                        select allrules;

                    if(salvagerulecheck.Count() > 0)
                    {
                        IOItemSalvage.IOR = IOResult.salvage;
                        IOItemSalvage.rulename = salvagerulecheck.First().ruleid;
                    }
                }

                if(IOItemSalvage.Aetheriacheck && GISettings.AutoDessicate)
                {
                    IOItemSalvage.IOR = IOResult.dessicate;
                }
            }catch(Exception ex){LogError(ex);}
        }