public static Dictionary <int, double> FusionPreview(List <ItemInfo> Items, List <ItemInfo> AppendItems, ItemInfo Formul, ref bool isBind) { List <int> list = new List <int>(); int MaxLevel = 0; int TotalRate = 0; Dictionary <int, double> Item_Rate = new Dictionary <int, double>(); Item_Rate.Clear(); foreach (ItemInfo p in Items) { list.Add(p.Template.FusionType); if (p.Template.Level > MaxLevel) { MaxLevel = p.Template.Level; } TotalRate += p.Template.FusionRate; if (p.IsBinds) { isBind = true; } } if (Formul.IsBinds) { isBind = true; } list.Add(Formul.TemplateID); foreach (ItemInfo p in AppendItems) { TotalRate += p.Template.FusionRate / 2; if (p.IsBinds) { isBind = true; } } list.Sort(); StringBuilder itemString = new StringBuilder(); foreach (int i in list) { itemString.Append(i); } string key = itemString.ToString(); FusionMgr.m_lock.AcquireReaderLock(-1); Dictionary <int, double> result; try { if (FusionMgr._fusions.ContainsKey(key)) { FusionInfo info = FusionMgr._fusions[key]; ItemTemplateInfo temp_0 = ItemMgr.GetGoodsbyFusionTypeandLevel(info.Reward, MaxLevel); ItemTemplateInfo temp_ = ItemMgr.GetGoodsbyFusionTypeandLevel(info.Reward, MaxLevel + 1); ItemTemplateInfo temp_2 = ItemMgr.GetGoodsbyFusionTypeandLevel(info.Reward, MaxLevel + 2); List <ItemTemplateInfo> temps = new List <ItemTemplateInfo>(); if (temp_2 != null) { temps.Add(temp_2); } if (temp_ != null) { temps.Add(temp_); } if (temp_0 != null) { temps.Add(temp_0); } ItemTemplateInfo tempMax = ( from s in temps where (double)TotalRate / (double)s.FusionNeedRate <= 1.1 orderby(double) TotalRate / (double)s.FusionNeedRate descending select s).FirstOrDefault <ItemTemplateInfo>(); ItemTemplateInfo tempMin = ( from s in temps where (double)TotalRate / (double)s.FusionNeedRate > 1.1 orderby(double) TotalRate / (double)s.FusionNeedRate select s).FirstOrDefault <ItemTemplateInfo>(); if (tempMax != null && tempMin == null) { Item_Rate.Add(tempMax.TemplateID, (double)(100 * TotalRate) / (double)tempMax.FusionNeedRate); } if (tempMax != null && tempMin != null) { double rateMax; double rateMin; if (tempMax.Level - tempMin.Level == 2) { rateMax = (double)(100 * TotalRate) * 0.6 / (double)tempMax.FusionNeedRate; rateMin = 100.0 - rateMax; } else { rateMax = (double)(100 * TotalRate) / (double)tempMax.FusionNeedRate; rateMin = 100.0 - rateMax; } Item_Rate.Add(tempMax.TemplateID, rateMax); if (rateMin > 0.0) { Item_Rate.Add(tempMin.TemplateID, rateMin); } } if (tempMax == null && tempMin != null) { Item_Rate.Add(tempMin.TemplateID, 100.0); } int[] templist = Item_Rate.Keys.ToArray <int>(); int[] array = templist; for (int j = 0; j < array.Length; j++) { int ID = array[j]; foreach (ItemInfo p in Items) { if (ID == p.Template.TemplateID) { if (Item_Rate.ContainsKey(ID)) { Item_Rate.Remove(ID); } } } } result = Item_Rate; return(result); } result = Item_Rate; return(result); } catch { } finally { FusionMgr.m_lock.ReleaseReaderLock(); } result = null; return(result); }
public static Dictionary <int, double> FusionPreview(List <ItemInfo> Items, List <ItemInfo> AppendItems, ref bool isBind) { List <int> list = new List <int>(); int num = 0; int TotalRate = 0; Dictionary <int, double> dictionary = new Dictionary <int, double>(); dictionary.Clear(); foreach (ItemInfo current in Items) { list.Add(current.Template.FusionType); if (current.Template.Level > num) { num = current.Template.Level; } TotalRate += current.Template.FusionRate; if (current.IsBinds) { isBind = true; } } foreach (ItemInfo current2 in AppendItems) { TotalRate += current2.Template.FusionRate / 2; if (current2.IsBinds) { isBind = true; } } list.Sort(); StringBuilder stringBuilder = new StringBuilder(); foreach (int current3 in list) { stringBuilder.Append(current3); } string key = stringBuilder.ToString(); FusionMgr.m_lock.AcquireReaderLock(15000); try { Dictionary <int, double> result; if (FusionMgr._fusions.ContainsKey(key)) { FusionInfo fusionInfo = FusionMgr._fusions[key]; ItemTemplateInfo goodsbyFusionTypeandLevel = ItemMgr.GetGoodsbyFusionTypeandLevel(fusionInfo.Reward, num); ItemTemplateInfo goodsbyFusionTypeandLevel2 = ItemMgr.GetGoodsbyFusionTypeandLevel(fusionInfo.Reward, num + 1); ItemTemplateInfo goodsbyFusionTypeandLevel3 = ItemMgr.GetGoodsbyFusionTypeandLevel(fusionInfo.Reward, num + 2); List <ItemTemplateInfo> list2 = new List <ItemTemplateInfo>(); if (goodsbyFusionTypeandLevel3 != null) { list2.Add(goodsbyFusionTypeandLevel3); } if (goodsbyFusionTypeandLevel2 != null) { list2.Add(goodsbyFusionTypeandLevel2); } if (goodsbyFusionTypeandLevel != null) { list2.Add(goodsbyFusionTypeandLevel); } ItemTemplateInfo itemTemplateInfo = ( from s in list2 where (double)TotalRate / (double)s.FusionNeedRate <= 1.1 orderby(double) TotalRate / (double)s.FusionNeedRate descending select s).FirstOrDefault <ItemTemplateInfo>(); ItemTemplateInfo itemTemplateInfo2 = ( from s in list2 where (double)TotalRate / (double)s.FusionNeedRate > 1.1 orderby(double) TotalRate / (double)s.FusionNeedRate select s).FirstOrDefault <ItemTemplateInfo>(); if (itemTemplateInfo != null && itemTemplateInfo2 == null) { dictionary.Add(itemTemplateInfo.TemplateID, (double)(100 * TotalRate) / (double)itemTemplateInfo.FusionNeedRate); } if (itemTemplateInfo != null && itemTemplateInfo2 != null) { double num2; double value; if (itemTemplateInfo.Level - itemTemplateInfo2.Level == 2) { num2 = (double)(100 * TotalRate) * 0.6 / (double)itemTemplateInfo.FusionNeedRate; value = 100.0 - num2; } else { num2 = (double)(100 * TotalRate) / (double)itemTemplateInfo.FusionNeedRate; value = 100.0 - num2; } dictionary.Add(itemTemplateInfo.TemplateID, num2); dictionary.Add(itemTemplateInfo2.TemplateID, value); } if (itemTemplateInfo == null && itemTemplateInfo2 != null) { dictionary.Add(itemTemplateInfo2.TemplateID, 100.0); } int[] array = dictionary.Keys.ToArray <int>(); int[] array2 = array; for (int i = 0; i < array2.Length; i++) { int num3 = array2[i]; foreach (ItemInfo current4 in Items) { if (num3 == current4.Template.TemplateID && dictionary.ContainsKey(num3)) { dictionary.Remove(num3); } } } result = dictionary; return(result); } result = dictionary; return(result); } catch { } finally { FusionMgr.m_lock.ReleaseReaderLock(); } return(null); }
public static ItemTemplateInfo Fusion(List <ItemInfo> Items, List <ItemInfo> AppendItems, ItemInfo Formul, ref bool isBind, ref bool result) { List <int> list = new List <int>(); int MaxLevel = 0; int TotalRate = 0; ItemTemplateInfo returnItem = null; foreach (ItemInfo p in Items) { list.Add(p.Template.FusionType); if (p.Template.Level > MaxLevel) { MaxLevel = p.Template.Level; } TotalRate += p.Template.FusionRate; if (p.IsBinds) { isBind = true; } } if (Formul.IsBinds) { isBind = true; } foreach (ItemInfo p in AppendItems) { TotalRate += p.Template.FusionRate / 2; if (p.IsBinds) { isBind = true; } } list.Add(Formul.TemplateID); list.Sort(); StringBuilder itemString = new StringBuilder(); foreach (int i in list) { itemString.Append(i); } string key = itemString.ToString(); FusionMgr.m_lock.AcquireReaderLock(-1); ItemTemplateInfo result2; try { if (FusionMgr._fusions.ContainsKey(key)) { FusionInfo info = FusionMgr._fusions[key]; ItemTemplateInfo temp_0 = ItemMgr.GetGoodsbyFusionTypeandLevel(info.Reward, MaxLevel); ItemTemplateInfo temp_ = ItemMgr.GetGoodsbyFusionTypeandLevel(info.Reward, MaxLevel + 1); ItemTemplateInfo temp_2 = ItemMgr.GetGoodsbyFusionTypeandLevel(info.Reward, MaxLevel + 2); List <ItemTemplateInfo> temps = new List <ItemTemplateInfo>(); if (temp_2 != null) { temps.Add(temp_2); } if (temp_ != null) { temps.Add(temp_); } if (temp_0 != null) { temps.Add(temp_0); } ItemTemplateInfo tempMax = ( from s in temps where (double)TotalRate / (double)s.FusionNeedRate <= 1.1 orderby(double) TotalRate / (double)s.FusionNeedRate descending select s).FirstOrDefault <ItemTemplateInfo>(); ItemTemplateInfo tempMin = ( from s in temps where (double)TotalRate / (double)s.FusionNeedRate > 1.1 orderby(double) TotalRate / (double)s.FusionNeedRate select s).FirstOrDefault <ItemTemplateInfo>(); if (tempMax != null && tempMin == null) { returnItem = tempMax; if ((double)(100 * TotalRate) / (double)tempMax.FusionNeedRate > (double)FusionMgr.random.Next(100)) { result = true; } } if (tempMax != null && tempMin != null) { if (tempMax.Level - tempMin.Level == 2) { double rateMax = (double)(100 * TotalRate) * 0.6 / (double)tempMax.FusionNeedRate; double rateMin = 100.0 - rateMax; } else { double rateMax = (double)(100 * TotalRate) / (double)tempMax.FusionNeedRate; double rateMin = 100.0 - rateMax; } if ((double)(100 * TotalRate) / (double)tempMax.FusionNeedRate > (double)FusionMgr.random.Next(100)) { returnItem = tempMax; result = true; } else { returnItem = tempMin; result = true; } } if (tempMax == null && tempMin != null) { returnItem = tempMin; result = true; } if (result) { foreach (ItemInfo p in Items) { if (p.Template.TemplateID == returnItem.TemplateID) { result = false; break; } } } result2 = returnItem; return(result2); } } catch { } finally { FusionMgr.m_lock.ReleaseReaderLock(); } result2 = null; return(result2); }
public static ItemTemplateInfo Fusion(List <ItemInfo> Items, List <ItemInfo> AppendItems, ref bool isBind, ref bool result) { List <int> list = new List <int>(); int num = 0; int TotalRate = 0; ItemTemplateInfo itemTemplateInfo = null; foreach (ItemInfo current in Items) { list.Add(current.Template.FusionType); if (current.Template.Level > num) { num = current.Template.Level; } TotalRate += current.Template.FusionRate; if (current.IsBinds) { isBind = true; } } foreach (ItemInfo current2 in AppendItems) { TotalRate += current2.Template.FusionRate / 2; if (current2.IsBinds) { isBind = true; } } list.Sort(); StringBuilder stringBuilder = new StringBuilder(); foreach (int current3 in list) { stringBuilder.Append(current3); } string key = stringBuilder.ToString(); FusionMgr.m_lock.AcquireReaderLock(15000); try { if (FusionMgr._fusions.ContainsKey(key)) { FusionInfo fusionInfo = FusionMgr._fusions[key]; ItemTemplateInfo goodsbyFusionTypeandLevel = ItemMgr.GetGoodsbyFusionTypeandLevel(fusionInfo.Reward, num); ItemTemplateInfo goodsbyFusionTypeandLevel2 = ItemMgr.GetGoodsbyFusionTypeandLevel(fusionInfo.Reward, num + 1); ItemTemplateInfo goodsbyFusionTypeandLevel3 = ItemMgr.GetGoodsbyFusionTypeandLevel(fusionInfo.Reward, num + 2); List <ItemTemplateInfo> list2 = new List <ItemTemplateInfo>(); if (goodsbyFusionTypeandLevel3 != null) { list2.Add(goodsbyFusionTypeandLevel3); } if (goodsbyFusionTypeandLevel2 != null) { list2.Add(goodsbyFusionTypeandLevel2); } if (goodsbyFusionTypeandLevel != null) { list2.Add(goodsbyFusionTypeandLevel); } ItemTemplateInfo itemTemplateInfo2 = ( from s in list2 where (double)TotalRate / (double)s.FusionNeedRate <= 1.1 orderby(double) TotalRate / (double)s.FusionNeedRate descending select s).FirstOrDefault <ItemTemplateInfo>(); ItemTemplateInfo itemTemplateInfo3 = ( from s in list2 where (double)TotalRate / (double)s.FusionNeedRate > 1.1 orderby(double) TotalRate / (double)s.FusionNeedRate select s).FirstOrDefault <ItemTemplateInfo>(); if (itemTemplateInfo2 != null && itemTemplateInfo3 == null) { itemTemplateInfo = itemTemplateInfo2; if ((double)(100 * TotalRate) / (double)itemTemplateInfo2.FusionNeedRate > (double)FusionMgr.rand.Next(100)) { result = true; } } if (itemTemplateInfo2 != null && itemTemplateInfo3 != null) { if (itemTemplateInfo2.Level - itemTemplateInfo3.Level == 2) { double num2 = (double)(100 * TotalRate) * 0.6 / (double)itemTemplateInfo2.FusionNeedRate; } else { double num2 = (double)(100 * TotalRate) / (double)itemTemplateInfo2.FusionNeedRate; } if ((double)(100 * TotalRate) / (double)itemTemplateInfo2.FusionNeedRate > (double)FusionMgr.rand.Next(100)) { itemTemplateInfo = itemTemplateInfo2; result = true; } else { itemTemplateInfo = itemTemplateInfo3; result = true; } } if (itemTemplateInfo2 == null && itemTemplateInfo3 != null) { itemTemplateInfo = itemTemplateInfo3; result = true; } if (result) { foreach (ItemInfo current4 in Items) { if (current4.Template.TemplateID == itemTemplateInfo.TemplateID) { result = false; break; } } } return(itemTemplateInfo); } } catch { } finally { FusionMgr.m_lock.ReleaseReaderLock(); } return(null); }