private List<int> InspectorPickSalvage(WorldObject SalvageBag) { try { SalvageRule sr = new SalvageRule(); //Find an applicable material rule. List<SalvageRule> materialrules = (from allrules in SalvageRulesList where (allrules.material == SalvageBag.Values(LongValueKey.Material)) && (SalvageBag.Values(DoubleValueKey.SalvageWorkmanship) >= allrules.minwork) && (SalvageBag.Values(DoubleValueKey.SalvageWorkmanship) <= (allrules.maxwork +0.99)) select allrules).ToList(); if(materialrules.Count > 0){sr = materialrules.First();} else { sr.material = SalvageBag.Values(LongValueKey.Material); sr.minwork = 1; sr.maxwork = 10; sr.ruleid = "Default Rule"; } List<WorldObject> PartialBags = Core.WorldFilter.GetInventory().Where(x => x.ObjectClass == ObjectClass.Salvage && x.Id != SalvageBag.Id && x.Values(LongValueKey.Material) == sr.material && x.Values(LongValueKey.UsesRemaining) < 100 && x.Values(DoubleValueKey.SalvageWorkmanship) >= sr.minwork && x.Values(DoubleValueKey.SalvageWorkmanship) <= (sr.maxwork + 0.99) ).ToList(); //Why work if you don't have to. if(PartialBags.Count == 0) {return new List<int>();} List<int> CombineBagsList = new List<int>(); CombineBagsList.Add(SalvageBag.Id); int salvagesum = SalvageBag.Values(LongValueKey.UsesRemaining); foreach(WorldObject salvbag in PartialBags) { if(salvagesum < 100) { if(salvagesum + salvbag.Values(LongValueKey.UsesRemaining) < 125) { CombineBagsList.Add(salvbag.Id); salvagesum += salvbag.Values(LongValueKey.UsesRemaining); } } if(salvagesum >= 100) {break;} } return CombineBagsList; }catch(Exception ex){LogError(ex); return new List<int>();} }
private void FillSalvageRules() { try { string[] SplitString; SalvageMatDictionary.Clear(); foreach(Salvage salv in mSearchListHolder.SalvageHash.Where(x => x.Checked)) { SalvageMatDictionary.Add(salv.SalvageMaterial, new HashSet<SalvageRule>()); SplitString = salv.CombineString.Split(','); if(SplitString.Count() == 1) { SalvageRule sr = new SalvageRule(); if(SplitString[0].Contains("-")) { string[] splstr = SplitString[0].Split('-'); Double.TryParse(splstr[0], out sr.minwork); Double.TryParse(splstr[1], out sr.maxwork); sr.ruleid = tDataTable.MaterialIndex[salv.SalvageMaterial].name + " " + sr.minwork.ToString("N0") + "-" + sr.maxwork.ToString("N0"); SalvageMatDictionary[salv.SalvageMaterial].Add(sr); } else { Double.TryParse(SplitString[0], out sr.minwork); sr.maxwork = 10; sr.ruleid = tDataTable.MaterialIndex[salv.SalvageMaterial].name + " " + sr.minwork.ToString("N0") + "-" + sr.maxwork.ToString("N0"); SalvageMatDictionary[salv.SalvageMaterial].Add(sr); } } else { foreach(string salvstring in SplitString) { SalvageRule sr = new SalvageRule(); if(salvstring.Contains("-")) { string[] splstr = salvstring.Split('-'); Double.TryParse(splstr[0], out sr.minwork); Double.TryParse(splstr[1], out sr.maxwork); sr.ruleid = tDataTable.MaterialIndex[salv.SalvageMaterial].name + " " + sr.minwork.ToString("N0") + "-" + sr.maxwork.ToString("N0"); SalvageMatDictionary[salv.SalvageMaterial].Add(sr); } else { Double.TryParse(salvstring, out sr.minwork); sr.maxwork = sr.minwork; sr.ruleid = tDataTable.MaterialIndex[salv.SalvageMaterial].name + " " + sr.minwork.ToString("N0") + "-" + sr.maxwork.ToString("N0"); SalvageMatDictionary[salv.SalvageMaterial].Add(sr); } } } } }catch(Exception ex){LogError(ex);} }
private void FillSalvageRules() { try { SalvageRulesList.Clear(); var EnabledSalvage = from salv in mSalvageList where salv.Element("checked").Value == "true" select salv; foreach(var XSalv in EnabledSalvage) { splitstring = XSalv.Element("combine").Value.Split(','); if(splitstring.Count() == 1) { SalvageRule sr = new SalvageRule(); Int32.TryParse(XSalv.Element("intvalue").Value, out sr.material); if(splitstring[0].Contains("-")) { splstr = splitstring[0].Split('-'); bool success0 = Double.TryParse(splstr[0], out sr.minwork); bool success1 = Double.TryParse(splstr[1], out sr.maxwork); sr.ruleid = MaterialIndex[sr.material].name + " " + sr.minwork.ToString("N0") + "-" + sr.maxwork.ToString("N0"); if(success0 && success1) {SalvageRulesList.Add(sr);} } else { bool success0 = Double.TryParse(splitstring[0], out sr.minwork); sr.maxwork = 10; sr.ruleid = MaterialIndex[sr.material].name + " " + sr.minwork.ToString("N0") + "-" + sr.maxwork.ToString("N0"); if(success0) {SalvageRulesList.Add(sr);} } } else { foreach(string salvstring in splitstring) { SalvageRule sr = new SalvageRule(); Int32.TryParse(XSalv.Element("intvalue").Value, out sr.material); if(salvstring.Contains("-")) { string[] splstr = salvstring.Split('-'); bool success0 = Double.TryParse(splstr[0], out sr.minwork); bool success1 = Double.TryParse(splstr[1], out sr.maxwork); sr.ruleid = MaterialIndex[sr.material].name + " " + sr.minwork.ToString("N0") + "-" + sr.maxwork.ToString("N0"); if(success0 && success1) {SalvageRulesList.Add(sr);} } else { bool success = Double.TryParse(salvstring, out sr.minwork); sr.maxwork = sr.minwork; sr.ruleid = MaterialIndex[sr.material].name + " " + sr.minwork.ToString("N0") + "-" + sr.maxwork.ToString("N0"); if(success) {SalvageRulesList.Add(sr);} } } } } } catch{} }