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.Values((ADoubleValueKeys)rule.Advanced[i].key) == rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 1:
                                if(item.Values((ADoubleValueKeys)rule.Advanced[i].key) != rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 2:
                                if(item.Values((ADoubleValueKeys)rule.Advanced[i].key) >= rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 3:
                                if(item.Values((ADoubleValueKeys)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.Values((ALongValueKeys)rule.Advanced[i].key) == rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 1:
                                if(item.Values((ALongValueKeys)rule.Advanced[i].key) != rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 2:
                                if(item.Values((ALongValueKeys)rule.Advanced[i].key) >= rule.Advanced[i].keyvalue) {tumbler[i] = true;}
                                break;
                            case 3:
                                if(item.Values((ALongValueKeys)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;
        }
Exemplo n.º 2
0
        private ItemRule CreateNewRule()
        {
            List<int> NumList = new List<int>();
               		foreach(ItemRule r in mSearchListHolder.ItemRulesHash)
               		{
               			NumList.Add(r.RuleNumber);
               		}

               		int NewRuleNumber = 0;
               		for(NewRuleNumber = 0; NewRuleNumber < NumList.Count; )
               		{
               			if(!NumList.Contains(NewRuleNumber)){break;}
               			else{NewRuleNumber++;}
               		}

               		ItemRule nRule = new ItemRule();
               		nRule.RuleNumber = NewRuleNumber;
               		return nRule;
        }
        private void btnRuleNew_Hit(object sender, EventArgs e)
        {
            try
            {

               		mSelectedRule = CreateNewRule();
               		mSelectedRule.RuleName = "New Rule " + mSelectedRule.RuleNumber;
               		mSearchListHolder.ItemRulesHash.Add(mSelectedRule);
               		SyncAndSaveRules();
               		_UpdateRulesTabs();
            }
            catch (Exception ex) { LogError(ex); }
        }
        private void btnRuleClone_Hit(object sender, EventArgs e)
        {
            try
            {

               		ItemRule nRule = CreateNewRule();
               		nRule.RuleName = "Cloned" + mSelectedRule.RuleName;
               		nRule.enabled = mSelectedRule.enabled;
               		nRule.RulePriority = mSelectedRule.RulePriority;
               		nRule.RuleAppliesTo = mSelectedRule.RuleAppliesTo;
               		nRule.RuleArcaneLore = mSelectedRule.RuleArcaneLore;
               		nRule.RuleWork = mSelectedRule.RuleWork;
               		nRule.RuleWieldLevel = mSelectedRule.RuleWieldLevel;
               		nRule.RuleWieldSkill = mSelectedRule.RuleWieldSkill;
               		nRule.RuleMastery = mSelectedRule.RuleMastery;
               		nRule.RuleDamageTypes = mSelectedRule.RuleDamageTypes;
               		nRule.GearScore = mSelectedRule.GearScore;
               		nRule.WieldRequirements = Serializer.DeepClone<List<WREV>>(mSelectedRule.WieldRequirements);
               		nRule.RuleSpellNumber = mSelectedRule.RuleSpellNumber;
               		nRule.RuleSlots = mSelectedRule.RuleSlots;
               		nRule.RuleArmorTypes = Serializer.DeepClone<List<int>>(mSelectedRule.RuleArmorTypes);
               		nRule.RuleArmorSet = Serializer.DeepClone<List<int>>(mSelectedRule.RuleArmorSet);
               		nRule.RuleSpells = Serializer.DeepClone<List<int>>(mSelectedRule.RuleSpells);
               		nRule.Palattes = Serializer.DeepClone<List<int>>(mSelectedRule.Palattes);
               		nRule.Advanced = Serializer.DeepClone<List<advsettings>>(mSelectedRule.Advanced);

                mSearchListHolder.ItemRulesHash.Add(nRule);
                mSelectedRule = nRule;

               		SyncAndSaveRules();
               		_UpdateRulesTabs();
            }
            catch (Exception ex) { LogError(ex); }
        }
        private void _UpdateRulesTabs()
        {
            try
            {

                int HoldRulesPosition = lstRules.ScrollPosition;
                if (mSearchListHolder.ItemRulesHash.Count == 0) {mSelectedRule = null; return; }
                if (mSelectedRule == null) { mSelectedRule = mSearchListHolder.ItemRulesHash.First(); }

                lstRules.ClearRows();

                foreach (ItemRule element in mSearchListHolder.ItemRulesHash.OrderByDescending(x => x.enabled).ThenBy(x => x.RuleName))
                {
                    HudList.HudListRowAccessor LstRulesHudListRow = new HudList.HudListRowAccessor();
                    LstRulesHudListRow = lstRules.AddRow();

                    ((HudCheckBox)LstRulesHudListRow[0]).Checked = element.enabled;
                    ((HudStaticText)LstRulesHudListRow[1]).Text = element.RulePriority.ToString();
                    ((HudStaticText)LstRulesHudListRow[2]).Text = element.RuleName;
                    ((HudPictureBox)LstRulesHudListRow[3]).Image = GearGraphics.RemoveCircle;
                    ((HudStaticText)LstRulesHudListRow[4]).Text = element.RuleNumber.ToString();

                    if(mSelectedRule.RuleNumber == element.RuleNumber)
                    {
                        ((HudStaticText)LstRulesHudListRow[1]).TextColor = Color.Gold;
                        ((HudStaticText)LstRulesHudListRow[2]).TextColor = Color.Gold;
                        ((HudStaticText)LstRulesHudListRow[4]).TextColor = Color.Gold;
                    }
                }

             	txtRuleName.Text = mSelectedRule.RuleName;
             	txtRulePriority.Text = mSelectedRule.RulePriority.ToString();
                chkRuleEnabled.Checked = mSelectedRule.enabled;
                txtGearScore.Text = mSelectedRule.GearScore.ToString();
                txtRuleMaxCraft.Text = mSelectedRule.RuleWork.ToString();
                txtRuleArcaneLore.Text = mSelectedRule.RuleArcaneLore.ToString();
                txtRuleWieldLevel.Text = mSelectedRule.RuleWieldLevel.ToString();
                txtRuleNumSpells.Text = mSelectedRule.RuleSpellNumber.ToString();

                chkRuleWeaponsa.Checked = false;
                chkRuleWeaponsb.Checked = false;
                chkRuleWeaponsc.Checked = false;
                chkRuleWeaponsd.Checked = false;
                txtRuleReqSkilla.Text = "-1";
                txtRuleReqSkillb.Text = "-1";
                txtRuleReqSkillc.Text = "-1";
                txtRuleReqSkilld.Text = "-1";

                if(mSelectedRule.WieldRequirements.Count > 0)
                {
                    chkRuleWeaponsa.Checked = mSelectedRule.WieldRequirements[0].WieldEnabled;
                    txtRuleReqSkilla.Text = mSelectedRule.WieldRequirements[0].WieldReqValue.ToString();
                }
                if(mSelectedRule.WieldRequirements.Count > 1)
                {
                    chkRuleWeaponsb.Checked = mSelectedRule.WieldRequirements[1].WieldEnabled;
                    txtRuleReqSkillb.Text = mSelectedRule.WieldRequirements[1].WieldReqValue.ToString();
                }
                if(mSelectedRule.WieldRequirements.Count > 2)
                {
                    chkRuleWeaponsc.Checked = mSelectedRule.WieldRequirements[2].WieldEnabled;
                    txtRuleReqSkillc.Text = mSelectedRule.WieldRequirements[2].WieldReqValue.ToString();
                }
               	if(mSelectedRule.WieldRequirements.Count > 3)
                {
                    chkRuleWeaponsd.Checked = mSelectedRule.WieldRequirements[3].WieldEnabled;
                    txtRuleReqSkilld.Text = mSelectedRule.WieldRequirements[3].WieldReqValue.ToString();
                }

                int HoldAppliesPosition = lstRuleApplies.ScrollPosition;
                _PopulateList(lstRuleApplies, tDataTable.AppliesToList, _ChangeAppliesToFlagToIntList(mSelectedRule.RuleAppliesTo));
                int HoldSlotsPosition = lstRuleSlots.ScrollPosition;
                _PopulateList(lstRuleSlots, tDataTable.SlotList, _ChangeSlotsFlagToIntList(mSelectedRule.RuleSlots));
                int HoldDamagePosition = lstDamageTypes.ScrollPosition;
                _PopulateList(lstDamageTypes, tDataTable.ElementalList, _ChangeDamageFlagToIntList(mSelectedRule.RuleDamageTypes));
                 int HoldSetPosition = lstRuleSets.ScrollPosition;
                _PopulateList(lstRuleSets, tDataTable.ArmorSetsList, mSelectedRule.RuleArmorSet);
                int HoldArmorPosition = lstRuleArmorTypes.ScrollPosition;
                _PopulateList(lstRuleArmorTypes, tDataTable.ArmorIndex, mSelectedRule.RuleArmorTypes);

                cboWeaponAppliesTo.Current = tDataTable.WeaponTypeList.FindIndex(x => x.ID == mSelectedRule.RuleWieldSkill);
                cboMasteryType.Current = mSelectedRule.RuleMastery;

                int HoldEnabledSpellsPostion = lstRuleSpellsEnabled.ScrollPosition;
                _UpdateSpellEnabledListBox();
                int HoldSpellListPosition = lstRuleSpells.ScrollPosition;
                _UpdateSpellListBox();

                lstRules.ScrollPosition = HoldRulesPosition;
                lstRuleApplies.ScrollPosition = HoldAppliesPosition;
                lstRuleSlots.ScrollPosition = HoldSlotsPosition;
                lstDamageTypes.ScrollPosition = HoldDamagePosition;
                lstRuleArmorTypes.ScrollPosition = HoldArmorPosition;
                lstRuleSets.ScrollPosition = HoldSetPosition;
                lstRuleSpellsEnabled.ScrollPosition = HoldEnabledSpellsPostion;
                lstRuleSpells.ScrollPosition = HoldSpellListPosition;

                _UpdateAdvancedRulesTab();

                txtPalette0.Text = String.Empty;
                txtPalette1.Text = String.Empty;
                txtPalette2.Text = String.Empty;
                txtPalette3.Text = String.Empty;
                txtPalette4.Text = String.Empty;
                txtPalette5.Text = String.Empty;

                if(mSelectedRule.Palattes.Count > 0)
                {
                    for(int i = 0; i < mSelectedRule.Palattes.Count; i++)
                    {
                        if(i == 0){txtPalette0.Text = mSelectedRule.Palattes[0].ToString();}
                        if(i == 1){txtPalette1.Text = mSelectedRule.Palattes[1].ToString();}
                        if(i == 2){txtPalette2.Text = mSelectedRule.Palattes[2].ToString();}
                        if(i == 3){txtPalette3.Text = mSelectedRule.Palattes[3].ToString();}
                        if(i == 4){txtPalette4.Text = mSelectedRule.Palattes[4].ToString();}
                        if(i == 5){txtPalette5.Text = mSelectedRule.Palattes[5].ToString();}
                    }
                }

            }catch (Exception ex) { LogError(ex); }
        }
        private void lstRules_Click(object sender, int row, int col)
        {
            try
            {
                HudList.HudListRowAccessor HudRow = lstRules[row];
                int RuleNumber = Convert.ToInt32(((HudStaticText)HudRow[4]).Text);
                mSelectedRule = mSearchListHolder.ItemRulesHash.Where(x => x.RuleNumber == RuleNumber).FirstOrDefault();

                if (col == 3)
                {
                    mSearchListHolder.ItemRulesHash.RemoveWhere(x => x.RuleNumber == RuleNumber);
                    mSelectedRule = mSearchListHolder.ItemRulesHash.FirstOrDefault();
                    SyncAndSaveRules();
                }
                else if (col == 0)
                {
                    mSelectedRule.enabled = ((HudCheckBox)HudRow[0]).Checked;
                    SyncAndSaveRules();
                }

                _UpdateRulesTabs();
            }
            catch (Exception ex) { LogError(ex); }
        }