private static bool LoadStrengthen(Dictionary <int, StrengthenInfo> strengthen, Dictionary <int, StrengthenInfo> RefineryStrengthen) { using (ProduceBussiness db = new ProduceBussiness()) { StrengthenInfo[] infos = db.GetAllStrengthen(); StrengthenGoodsInfo[] StrengthGoodInfos = db.GetAllStrengthenGoodsInfo(); StrengthenInfo[] array = infos; for (int i = 0; i < array.Length; i++) { StrengthenInfo info = array[i]; if (!strengthen.ContainsKey(info.StrengthenLevel)) { strengthen.Add(info.StrengthenLevel, info); } } StrengthenGoodsInfo[] array2 = StrengthGoodInfos; for (int i = 0; i < array2.Length; i++) { StrengthenGoodsInfo info2 = array2[i]; if (!StrengthenMgr.Strengthens_Goods.ContainsKey(info2.ID)) { StrengthenMgr.Strengthens_Goods.Add(info2.ID, info2); } } } return(true); }
public StrengthenGoodsInfo[] GetAllStrengthenGoodsInfo() { List <StrengthenGoodsInfo> infos = new List <StrengthenGoodsInfo>(); SqlDataReader reader = null; try { db.GetReader(ref reader, "SP_Item_StrengthenGoodsInfo_All"); while (reader.Read()) { StrengthenGoodsInfo info = new StrengthenGoodsInfo(); info.ID = (int)reader["ID"]; info.Level = (int)reader["Level"]; info.CurrentEquip = (int)reader["CurrentEquip"]; info.GainEquip = (int)reader["GainEquip"]; infos.Add(info); } } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("GetAllStrengthenGoodsInfo", e); } } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } return(infos.ToArray()); }
private static bool LoadStrengthen(Dictionary <int, StrengthenInfo> strengthen, Dictionary <int, StrengthenInfo> RefineryStrengthen, Dictionary <int, StrengThenExpInfo> StrengthenExp, Dictionary <int, StrengthenGoodsInfo> StrengthensGoods) { using (ProduceBussiness produceBussiness = new ProduceBussiness()) { StrengthenInfo[] allStrengthen = produceBussiness.GetAllStrengthen(); StrengthenInfo[] allRefineryStrengthen = produceBussiness.GetAllRefineryStrengthen(); StrengThenExpInfo[] allStrengThenExp = produceBussiness.GetAllStrengThenExp(); StrengthenGoodsInfo[] allStrengthenGoodsInfo = produceBussiness.GetAllStrengthenGoodsInfo(); StrengthenInfo[] array = allStrengthen; for (int i = 0; i < array.Length; i++) { StrengthenInfo strengthenInfo = array[i]; if (!strengthen.ContainsKey(strengthenInfo.StrengthenLevel)) { strengthen.Add(strengthenInfo.StrengthenLevel, strengthenInfo); } } StrengthenInfo[] array2 = allRefineryStrengthen; for (int j = 0; j < array2.Length; j++) { StrengthenInfo strengthenInfo2 = array2[j]; if (!RefineryStrengthen.ContainsKey(strengthenInfo2.StrengthenLevel)) { RefineryStrengthen.Add(strengthenInfo2.StrengthenLevel, strengthenInfo2); } } StrengThenExpInfo[] array3 = allStrengThenExp; for (int k = 0; k < array3.Length; k++) { StrengThenExpInfo strengThenExpInfo = array3[k]; if (!StrengthenExp.ContainsKey(strengThenExpInfo.Lv)) { StrengthenExp.Add(strengThenExpInfo.Lv, strengThenExpInfo); } } StrengthenGoodsInfo[] array4 = allStrengthenGoodsInfo; for (int l = 0; l < array4.Length; l++) { StrengthenGoodsInfo strengthenGoodsInfo = array4[l]; if (!StrengthensGoods.ContainsKey(strengthenGoodsInfo.ID)) { StrengthensGoods.Add(strengthenGoodsInfo.ID, strengthenGoodsInfo); } } } return(true); }
public static StrengthenGoodsInfo FindStrengthenFailGoodsInfo(int level, int templateid) { StrengthenMgr.m_lock.AcquireReaderLock(-1); StrengthenGoodsInfo result; try { List <StrengthenGoodsInfo> list = new List <StrengthenGoodsInfo>(); foreach (int i in StrengthenMgr.Strengthens_Goods.Keys) { if (StrengthenMgr.Strengthens_Goods[i].Level == level && templateid == StrengthenMgr.Strengthens_Goods[i].GainEquip && (level == 10 || level == 12 || level == 14)) { list.Add(StrengthenMgr.Strengthens_Goods[i]); } } StrengthenGoodsInfo max = null; foreach (StrengthenGoodsInfo info in list) { if (max == null) { max = info; } else { if (info.CurrentEquip > max.CurrentEquip) { max = info; } } } result = max; return(result); } catch { } finally { StrengthenMgr.m_lock.ReleaseReaderLock(); } result = null; return(result); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int pRICE_STRENGHTN_GOLD = AppConfig.AppSettings["StrengthenGold"].ConvertToInt(1000); bool flag = player.PlayerCharacter.Gold < pRICE_STRENGHTN_GOLD; int num; int result; if (flag) { player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoMoney", new object[0])); num = 0; } else { GSPacketIn gSPacketIn = packet.Clone(); gSPacketIn.ClearContext(); ItemInfo itemInfo = player.HideBag.GetItemAt(5); bool flag2 = itemInfo != null && itemInfo.Template.CanStrengthen && itemInfo.Count == 1; if (flag2) { StrengthenInfo strengthenInfo = StrengthenMgr.FindStrengthenInfo(itemInfo.StrengthenLevel + 1); bool flag3 = strengthenInfo == null; if (flag3) { bool flag4 = itemInfo.StrengthenLevel == 9 || itemInfo.StrengthenLevel == 15; if (flag4) { player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.FullStrengthLevel", new object[0])); } else { player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoStrength", new object[0])); } num = 0; result = num; return(result); } bool flag5 = itemInfo.IsBinds; bool flag6 = packet.ReadBoolean(); StringBuilder stringBuilder = new StringBuilder(); string propertyString = itemInfo.GetPropertyString(); double num2 = 0.0; bool flag7 = false; ItemInfo itemInfo2 = player.HideBag.GetItemAt(3); bool flag8 = itemInfo2 != null && itemInfo2.Template.CategoryID == 11 && itemInfo2.Template.Property1 == 7; if (flag8) { flag5 |= itemInfo2.IsBinds; stringBuilder.Append(itemInfo2.ToShortString()); flag7 = true; } else { itemInfo2 = null; } bool flag9 = false; List <ItemInfo> list = new List <ItemInfo>(); ItemInfo itemAt = player.HideBag.GetItemAt(0); bool flag10 = itemAt != null && itemAt.Template.CategoryID == 11 && (itemAt.Template.Property1 == 2 || itemAt.Template.Property1 == 35) && !list.Contains(itemAt); if (flag10) { bool flag11 = itemInfo.StrengthenLevel >= 15 && itemAt.Template.Property8 == 2; if (flag11) { player.Out.SendMessage(0, "不能使用[" + itemAt.Template.Name + "]来强化此装备."); num = 1; result = num; return(result); } flag5 |= itemAt.IsBinds; flag9 |= (itemAt.Template.Property1 == 35 && itemAt.Template.CategoryID == 11); num2 += (double)itemAt.Template.Property2; stringBuilder.Append(itemAt.ToShortString()); list.Add(itemAt); } ItemInfo itemAt2 = player.HideBag.GetItemAt(1); bool flag12 = itemAt2 != null && itemAt2.Template.CategoryID == 11 && (itemAt2.Template.Property1 == 2 || itemAt2.Template.Property1 == 35) && !list.Contains(itemAt2); if (flag12) { bool flag13 = itemInfo.StrengthenLevel >= 15 && itemAt2.Template.Property8 == 2; if (flag13) { player.Out.SendMessage(0, "不能使用[" + itemAt2.Template.Name + "]来强化此装备."); num = 1; result = num; return(result); } flag5 |= itemAt2.IsBinds; flag9 |= (itemAt2.Template.Property1 == 35 && itemAt2.Template.CategoryID == 11); num2 += (double)itemAt2.Template.Property2; stringBuilder.Append(itemAt2.ToShortString()); list.Add(itemAt2); } ItemInfo itemAt3 = player.HideBag.GetItemAt(2); bool flag14 = itemAt3 != null && itemAt3.Template.CategoryID == 11 && (itemAt3.Template.Property1 == 2 || itemAt3.Template.Property1 == 35) && !list.Contains(itemAt3); if (flag14) { bool flag15 = itemInfo.StrengthenLevel >= 15 && itemAt3.Template.Property8 == 2; if (flag15) { player.Out.SendMessage(0, "不能使用[" + itemAt3.Template.Name + "]来强化此装备."); num = 1; result = num; return(result); } flag5 |= itemAt3.IsBinds; flag9 |= (itemAt3.Template.Property1 == 35 && itemAt3.Template.CategoryID == 11); num2 += (double)itemAt3.Template.Property2; stringBuilder.Append(itemAt3.ToShortString()); list.Add(itemAt3); } ItemInfo itemInfo3 = player.HideBag.GetItemAt(4); bool flag16 = itemInfo3 != null && itemInfo3.Template.CategoryID == 11 && itemInfo3.Template.Property1 == 3; if (flag16) { flag5 |= itemInfo3.IsBinds; num2 *= (double)(itemInfo3.Template.Property2 + 100); stringBuilder.Append(itemInfo3.ToShortString()); } else { num2 *= 100.0; itemInfo3 = null; } bool flag17 = false; ConsortiaInfo consortiaInfo = null; bool flag18 = flag6; if (flag18) { consortiaInfo = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID); bool flag19 = consortiaInfo == null; if (flag19) { player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail", new object[0])); } else { using (ConsortiaBussiness consortiaBussiness = new ConsortiaBussiness()) { ConsortiaEquipControlInfo consortiaEuqipRiches = consortiaBussiness.GetConsortiaEuqipRiches(player.PlayerCharacter.ConsortiaID, 0, 2); bool flag20 = player.PlayerCharacter.Riches < consortiaEuqipRiches.Riches; if (flag20) { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission", new object[0])); num = 1; result = num; return(result); } flag17 = true; } } } bool flag21 = list.Count >= 1; if (flag21) { StrengthenGoodsInfo strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(itemInfo.StrengthenLevel + 1, itemInfo.TemplateID); ItemInfo itemInfo4 = null; bool flag22 = strengthenGoodsInfo != null; if (flag22) { itemInfo4 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip), 1, 116); bool flag23 = itemInfo4 == null; if (flag23) { num = 0; result = num; return(result); } } string text = null; player.HideBag.BeginChanges(); try { num2 /= (double)strengthenInfo.Rock; int num3; for (int i = 0; i < list.Count; i = num3 + 1) { player.HideBag.RemoveCountFromStack(list[i], 1, (eItemRemoveType)5); num3 = i; } bool flag24 = itemInfo3 != null; if (flag24) { player.HideBag.RemoveCountFromStack(itemInfo3, 1, (eItemRemoveType)5); } bool flag25 = itemInfo2 != null; if (flag25) { player.HideBag.RemoveCountFromStack(itemInfo2, 1, (eItemRemoveType)5); } bool flag26 = flag17; if (flag26) { num2 *= 1.0 + 0.1 * (double)consortiaInfo.SmithLevel; } itemInfo.IsBinds = flag5; int num4 = 1; bool flag27 = num2 > (double)ItemStrengthenHandler.random.Next(10000); if (flag27) { num4 = 0; bool flag28 = strengthenGoodsInfo != null && itemInfo4 != null; if (flag28) { StrengthenMgr.InheritProperty(itemInfo, itemInfo4); itemInfo4.StrengthenLevel = (itemInfo.StrengthenLevel + 1); player.HideBag.RemoveItem(itemInfo, (eItemRemoveType)5); player.HideBag.AddItemTo(itemInfo4, 5); text = string.Format("temp_place_{0}", itemInfo.ItemID); itemInfo = itemInfo4; bool flag29 = itemInfo.ItemID == 0; if (flag29) { using (PlayerBussiness playerBussiness = new PlayerBussiness()) { playerBussiness.AddGoods(itemInfo); } } } else { ItemInfo itemInfo5 = itemInfo; num3 = itemInfo5.StrengthenLevel; itemInfo5.StrengthenLevel = (num3 + 1); } player.OnItemStrengthen(itemInfo.Template.CategoryID, itemInfo.StrengthenLevel); bool flag30 = itemInfo.StrengthenLevel >= 7; if (flag30) { string translation = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", new object[] { player.PlayerCharacter.NickName, itemInfo.StrengthenLevel }); GSPacketIn packet2 = WorldMgr.SendSysNotice(translation, itemInfo, player); GameServer.Instance.LoginServer.SendPacket(packet2); } } else { num4 = 1; bool flag31 = !flag7; if (flag31) { StrengthenGoodsInfo strengthenGoodsInfo2 = StrengthenMgr.FindStrengthenFailGoodsInfo(itemInfo.StrengthenLevel, itemInfo.TemplateID); itemInfo.StrengthenLevel = ((itemInfo.StrengthenLevel == 0) ? 0 : (itemInfo.StrengthenLevel - 1)); bool flag32 = strengthenGoodsInfo2 != null; if (flag32) { ItemInfo itemInfo6 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(strengthenGoodsInfo2.CurrentEquip), 1, 116); bool flag33 = itemInfo6 == null; if (flag33) { num = 0; result = num; return(result); } StrengthenMgr.InheritProperty(itemInfo, itemInfo6); itemInfo6.StrengthenLevel = (itemInfo.StrengthenLevel); player.HideBag.RemoveItem(itemInfo, (eItemRemoveType)5); player.HideBag.AddItemTo(itemInfo6, 5); } } } player.HideBag.UpdateItem(itemInfo); gSPacketIn.WriteByte((byte)num4); gSPacketIn.WriteBoolean(itemInfo.IsOpenHole); player.RemoveGold(pRICE_STRENGHTN_GOLD); //LogMgr.LogItemAdd(player.PlayerCharacter.ID, 1, propertyString, itemInfo, stringBuilder.ToString(), (num4 == 1) ? 0 : 1); } finally { player.HideBag.CommitChanges(); player.Out.SendTCP(gSPacketIn); } player.SaveIntoDatabase(); bool flag34 = text != null && player.TempProperties.ContainsKey(text); if (flag34) { int num5 = (int)player.TempProperties[text]; player.TempProperties.Remove(text); text = string.Format("temp_place_{0}", itemInfo.ItemID); player.TempProperties.Add(text, num5); } } else { player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1", new object[0]) + 1 + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2", new object[0])); } } else { player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.Success", new object[0])); } num = 0; } result = num; return(result); }
//private static readonly double[] rateItems = new double[] { 0.75, 3, 12, 48, 240, 768 }; //public static int countConnect = 0; public int HandlePacket(GameClient client, GSPacketIn packet) { //if (countConnect >= 3000) //{ // client.Disconnect(); // return 0; //} StringBuilder str = new StringBuilder(); bool isBinds = false; bool consortia = packet.ReadBoolean(); bool MultiSelected = packet.ReadBoolean(); GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); List <ItemInfo> stones = new List <ItemInfo>(); ItemInfo stone = client.Player.StoreBag2.GetItemAt(0); ItemInfo item = client.Player.StoreBag2.GetItemAt(1); //ItemInfo luck = null; //ItemInfo god = null; string BeginProperty = null; string AddItem = ""; using (ItemRecordBussiness db = new ItemRecordBussiness()) { db.PropertyString(item, ref BeginProperty); } if (item != null && item.Template.CanStrengthen && item.Template.CategoryID < 18 && item.Count == 1) { isBinds = isBinds ? true : item.IsBinds; str.Append(item.ItemID + ":" + item.TemplateID + ","); double exp1 = 0; double exp2 = 0; double exp3 = 0; double totalExp = 0; if (stone != null && stone.Template.CategoryID == 11 && (stone.Template.Property1 == 2 || stone.Template.Property1 == 35)) { isBinds = isBinds ? true : stone.IsBinds; AddItem += "," + stone.ItemID.ToString() + ":" + stone.Template.Name; stones.Add(stone); exp1 += stone.Template.Property2; } bool ConsortiaRate = false; ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); //判断是公会铁匠铺还是铁匠铺?? if (consortia) { ConsortiaBussiness csbs = new ConsortiaBussiness(); ConsortiaEquipControlInfo cecInfo = csbs.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2); if (info == null) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail")); } else { if (client.Player.PlayerCharacter.Riches < cecInfo.Riches) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission")); return(1); } ConsortiaRate = true; } } if (ConsortiaRate) { //ConsortiaRateManager.instance.getConsortiaStrengthenEx(PlayerManager.Instance.Self.consortiaInfo.SmithLevel) //"ConsortiaStrengthenEx" Value="10|20|30|40|50|60|70|80|90|100" List <double> ConsortiaStrengthenEx = new List <double> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }; exp2 = ConsortiaStrengthenEx[info.SmithLevel - 1] / 100 * exp1; } if (client.Player.PlayerCharacter.VIPExpireDay >= DateTime.Now) { //_loc_4 = VipController.instance.getVIPStrengthenEx(PlayerManager.Instance.Self.VIPLevel) //"VIPStrengthenEx" Value="25|25|25|35|35|50|50|50|50|50|50|50" List <double> VIPStrengthenEx = new List <double> { 25, 25, 25, 35, 35, 50, 50, 50, 50, 50, 50, 50 }; exp3 = VIPStrengthenEx[client.Player.PlayerCharacter.VIPLevel - 1] / 100 * exp1; } totalExp += Math.Floor(exp1 + exp2 + exp3); str.Append("true"); List <int> StrengThenExp = new List <int> { 0, 10, 50, 150, 350, 700, 1500, 2300, 3300, 4500, 6000, 7500, 9000 }; //Console.WriteLine("-------Total: " + stone.Count.ToString() + "| Inject: " + MultiSelected); if (MultiSelected)// && stone.Count > 1) { //for (int i = 0; i < stone.Count; i++) //{ item.StrengthenExp += (int)totalExp * stone.Count; client.Player.StoreBag2.RemoveTemplate(stone.TemplateID, stone.Count); //} } else { item.StrengthenExp += (int)totalExp; client.Player.StoreBag2.RemoveTemplate(stone.TemplateID, 1); } if (item.StrengthenExp >= StrengThenExp[item.StrengthenLevel + 1]) { //for (int a = StrengThenExp[item.StrengthenLevel]; a < item.StrengthenExp; a++) int a = StrengThenExp[item.StrengthenLevel]; do { if (item.StrengthenLevel < 13) { if (item.StrengthenExp >= StrengThenExp[item.StrengthenLevel + 1]) { item.StrengthenLevel++; item.StrengthenExp -= StrengThenExp[item.StrengthenLevel]; a = StrengThenExp[item.StrengthenLevel]; } else { break; } } }while (item.StrengthenExp > a); if (item.StrengthenLevel == 12 && (item.StrengthenExp / totalExp) > 0) { stone.Count = (int)Math.Floor(item.StrengthenExp / totalExp); client.Player.StoreBag2.AddItemTo(stone, 0); client.Player.StoreBag2.UpdateItem(stone); //if (item.StrengthenLevel == 12) item.StrengthenExp = 0; } pkg.WriteByte(1); StrengthenGoodsInfo strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(item.StrengthenLevel, item.TemplateID); if (strengthenGoodsInfo != null && item.Template.CategoryID == 7) { ItemTemplateInfo Temp = Bussiness.Managers.ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip); if (Temp != null) { ItemInfo newItem = ItemInfo.CreateFromTemplate(Temp, 1, (int)ItemAddType.Strengthen); newItem.StrengthenLevel = item.StrengthenLevel; newItem.StrengthenExp = item.StrengthenExp; ItemInfo.OpenHole(ref newItem); StrengthenMgr.InheritProperty(item, ref newItem); client.Player.StoreBag2.RemoveItemAt(1); client.Player.StoreBag2.AddItemTo(newItem, 1); //client.Player.StoreBag2.UpdateItem(newItem); item = newItem; if ((item.StrengthenLevel == 3 || item.StrengthenLevel == 6 || item.StrengthenLevel == 9 || item.StrengthenLevel == 12) && item.Template.CategoryID != 17) { pkg.WriteBoolean(true); } else { pkg.WriteBoolean(false); } } } else { ItemInfo.OpenHole(ref item); //client.Player.StoreBag2.AddItemTo(item, 1); if ((item.StrengthenLevel == 3 || item.StrengthenLevel == 6 || item.StrengthenLevel == 9 || item.StrengthenLevel == 12) && item.Template.CategoryID != 17) { pkg.WriteBoolean(true); } else { pkg.WriteBoolean(false); } } //系统广播 if (item.StrengthenLevel >= 7) { string msg = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", client.Player.PlayerCharacter.NickName, item.Template.Name, item.StrengthenLevel); GSPacketIn sys_notice = WorldMgr.SendSysNotice(msg); GameServer.Instance.LoginServer.SendPacket(sys_notice); } } else { pkg.WriteByte(1); pkg.WriteBoolean(false); } client.Player.StoreBag2.UpdateItem(item); client.Player.OnItemStrengthen(item.Template.CategoryID, item.StrengthenLevel); //任务<强化> LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, BeginProperty, item, AddItem, 1); //强化日志 //client.Player.SaveIntoDatabase();//保存到数据库 client.Out.SendTCP(pkg); str.Append(item.StrengthenLevel); //client.Player.BeginChanges(); //client.Player.CommitChanges(); } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1") + stone.Template.Name + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2")); } if (item.Place < 31) { client.Player.MainBag.UpdatePlayerProperties(); } return(0); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); StringBuilder str = new StringBuilder(); int mustGold = 10000; ItemInfo fromItem = player.HideBag.GetItemAt(0); ItemInfo toItem = player.HideBag.GetItemAt(1); int result; if (fromItem.StrengthenLevel < toItem.StrengthenLevel) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTransferHandler.NoCondition1", new object[0])); result = 0; } else { if (fromItem != null && toItem != null && fromItem.Template.CategoryID == toItem.Template.CategoryID && fromItem.Template.CategoryID < 10 && toItem.Count == 1 && fromItem.Count == 1 && fromItem.IsValidItem() && toItem.IsValidItem()) { if (fromItem.StrengthenLevel == 0 && fromItem.DefendCompose == 0 && fromItem.LuckCompose == 0 && fromItem.AgilityCompose == 0 && fromItem.AttackCompose == 0) { result = 1; return(result); } if (player.PlayerCharacter.Gold < mustGold) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nogold", new object[0])); result = 1; return(result); } player.BeginChanges(); player.MainBag.BeginChanges(); try { player.RemoveGold(mustGold); str.Append(string.Concat(new object[] { fromItem.ItemID, ":", fromItem.TemplateID, "," })); str.Append(fromItem.StrengthenLevel + ","); str.Append(fromItem.AttackCompose + ","); str.Append(fromItem.DefendCompose + ","); str.Append(fromItem.LuckCompose + ","); str.Append(fromItem.AgilityCompose + ","); StrengthenGoodsInfo newGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(fromItem.StrengthenLevel, toItem.TemplateID); ItemInfo toNewItem = null; if (newGoodsInfo != null) { toNewItem = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(newGoodsInfo.GainEquip), 1, 115); if (toNewItem == null) { result = 0; return(result); } } StrengthenGoodsInfo oldGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(fromItem.TemplateID); ItemInfo fromOldItem = null; if (oldGoodsInfo != null) { fromOldItem = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(oldGoodsInfo.OrginEquip), 1, 115); if (fromOldItem == null) { result = 0; return(result); } } if (toNewItem != null) { StrengthenMgr.InheritProperty(toItem, toNewItem); toNewItem.StrengthenLevel = fromItem.StrengthenLevel; toNewItem.AttackCompose = fromItem.AttackCompose; toNewItem.DefendCompose = fromItem.DefendCompose; toNewItem.LuckCompose = fromItem.LuckCompose; toNewItem.AgilityCompose = fromItem.AgilityCompose; toNewItem.ValidDate = toItem.ValidDate; toNewItem.IsBinds = true; player.HideBag.RemoveItem(toItem, eItemRemoveType.ItemTransfer); player.HideBag.AddItemTo(toNewItem, 1); toItem = toNewItem; } else { toItem.StrengthenLevel = fromItem.StrengthenLevel; toItem.AttackCompose = fromItem.AttackCompose; toItem.DefendCompose = fromItem.DefendCompose; toItem.LuckCompose = fromItem.LuckCompose; toItem.AgilityCompose = fromItem.AgilityCompose; toItem.IsBinds = true; } if (fromOldItem != null) { fromItem.StrengthenLevel = 0; fromItem.AttackCompose = 0; fromItem.DefendCompose = 0; fromItem.LuckCompose = 0; fromItem.AgilityCompose = 0; StrengthenMgr.InheritProperty(fromItem, fromOldItem); fromOldItem.ValidDate = fromItem.ValidDate; player.HideBag.RemoveItem(fromItem, eItemRemoveType.ItemTransfer); player.HideBag.AddItemTo(fromOldItem, 0); fromOldItem.IsBinds = true; fromItem = fromOldItem; } else { fromItem.StrengthenLevel = 0; fromItem.AttackCompose = 0; fromItem.DefendCompose = 0; fromItem.LuckCompose = 0; fromItem.AgilityCompose = 0; fromItem.IsBinds = true; } player.HideBag.UpdateItem(fromItem); player.HideBag.UpdateItem(toItem); str.Append(string.Concat(new object[] { toItem.ItemID, ":", toItem.TemplateID, "," })); str.Append(toItem.StrengthenLevel + ","); str.Append(toItem.AttackCompose + ","); str.Append(toItem.DefendCompose + ","); str.Append(toItem.LuckCompose + ","); str.Append(toItem.AgilityCompose); pkg.WriteByte(0); player.Out.SendTCP(pkg); //LogMgr.LogItemAdd(player.PlayerCharacter.ID, LogItemType.Move, str.ToString(), toItem, null, 1); } finally { player.CommitChanges(); player.MainBag.CommitChanges(); } } else { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTransferHandler.NoCondition", new object[0])); } result = 0; } return(result); }
public int HandlePacket(GameClient client, GSPacketIn packet) { StringBuilder stringBuilder = new StringBuilder(); bool flag = false; bool flag2 = packet.ReadBoolean(); bool flag3 = packet.ReadBoolean(); GSPacketIn gSPacketIn = new GSPacketIn(59, client.Player.PlayerCharacter.ID); ItemInfo itemAt = client.Player.StoreBag.GetItemAt(0); ItemInfo itemInfo = client.Player.StoreBag.GetItemAt(1); int num = 1; string beginProperty = null; string text = ""; using (ItemRecordBussiness itemRecordBussiness = new ItemRecordBussiness()) { itemRecordBussiness.PropertyString(itemInfo, ref beginProperty); } if (itemInfo != null && itemInfo.Template.CanStrengthen && itemInfo.Template.CategoryID < 18 && itemInfo.Count == 1) { flag = (flag || itemInfo.IsBinds); stringBuilder.Append(string.Concat(new object[] { itemInfo.ItemID, ":", itemInfo.TemplateID, "," })); double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; int strengthenExp = itemInfo.StrengthenExp; int strengthenLevel = itemInfo.StrengthenLevel; if (strengthenLevel >= 12) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("Level đã đạt cấp độ cao nhất, không thể cường hóa!", new object[0])); return(0); } bool flag4 = false; ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); if (flag2) { ConsortiaBussiness consortiaBussiness = new ConsortiaBussiness(); ConsortiaEquipControlInfo consortiaEuqipRiches = consortiaBussiness.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2); if (consortiaInfo == null) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail", new object[0])); } else { if (client.Player.PlayerCharacter.Riches < consortiaEuqipRiches.Riches) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission", new object[0])); return(1); } flag4 = true; } } if (itemAt != null && itemAt.Template.CategoryID == 11 && (itemAt.Template.Property1 == 2 || itemAt.Template.Property1 == 35)) { flag = (flag || itemAt.IsBinds); string text2 = text; text = string.Concat(new string[] { text2, ",", itemAt.ItemID.ToString(), ":", itemAt.Template.Name }); int num5 = (itemAt.Template.Property2 < 10) ? 10 : itemAt.Template.Property2; if (flag4) { int smithLevel = consortiaInfo.SmithLevel; double num6 = (double)GameProperties.ConsortiaStrengExp(smithLevel - 1); num3 = num6 * (double)num5 / 100.0; } if (client.Player.PlayerCharacter.VIPExpireDay.Date >= DateTime.Now.Date) { int vIPLevel = client.Player.PlayerCharacter.VIPLevel; double num7 = (double)GameProperties.VIPStrengthenExp(vIPLevel - 1); num4 = num7 * (double)num5 / 100.0; } num5 += (int)num3 + (int)num4; if (flag3) { int needExp = StrengthenMgr.getNeedExp(strengthenExp, strengthenLevel); num = this.CalculatorCount(needExp, num5); if (num > itemAt.Count) { num = itemAt.Count; } num2 += (double)(num5 * num); } else { num2 += (double)num5; } } stringBuilder.Append("true"); int num8 = (int)num2 + strengthenExp; if (StrengthenMgr.canUpLv(num8, strengthenLevel)) { itemInfo.StrengthenLevel++; itemInfo.StrengthenExp = num8 - StrengthenMgr.FindStrengthenExpInfo(strengthenLevel + 1).Exp; gSPacketIn.WriteByte(1); StrengthenGoodsInfo strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(itemInfo.StrengthenLevel, itemInfo.TemplateID); if (strengthenGoodsInfo != null && itemInfo.Template.CategoryID == 7 && strengthenGoodsInfo.GainEquip > itemInfo.TemplateID) { ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip); if (itemTemplateInfo != null) { ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 116); itemInfo2.StrengthenLevel = itemInfo.StrengthenLevel; itemInfo2.StrengthenExp = itemInfo.StrengthenExp; StrengthenMgr.InheritProperty(itemInfo, ref itemInfo2); client.Player.StoreBag.RemoveItemAt(1); client.Player.StoreBag.AddItemTo(itemInfo2, 1); itemInfo = itemInfo2; } } if (itemInfo.StrengthenLevel == 10 || itemInfo.StrengthenLevel == 12) { string translation = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", new object[] { client.Player.PlayerCharacter.NickName, itemInfo.Template.Name, itemInfo.StrengthenLevel }); client.Player.SendAllMessage(translation); } } else { itemInfo.StrengthenExp = num8; } client.Player.StoreBag.RemoveTemplate(itemAt.TemplateID, num); client.Player.StoreBag.UpdateItem(itemInfo); client.Player.OnItemStrengthen(itemInfo.Template.CategoryID, itemInfo.StrengthenLevel); LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, beginProperty, itemInfo, text, 1); gSPacketIn.WriteBoolean(false); client.Out.SendTCP(gSPacketIn); stringBuilder.Append(itemInfo.StrengthenLevel); } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1", new object[0]) + itemAt.Template.Name + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2", new object[0])); } if (itemInfo.Place < 31) { client.Player.MainBag.UpdatePlayerProperties(); } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (countConnect >= 3000) { client.Disconnect(); return(0); } GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); StringBuilder str = new StringBuilder(); bool isBinds = false; int mustGold = GameProperties.PRICE_STRENGHTN_GOLD; if (client.Player.PlayerCharacter.Gold < mustGold) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoMoney")); return(0); } int luckPlace = 0; int godPlace = 0; //int itemPlace = client.Player.TempBag.GetItemAt(0).ItemID ; //int luckPlace = packet.ReadInt(); //int godPlace = packet.ReadInt(); //int stone1Place = packet.ReadInt(); //int stone2Place = packet.ReadInt(); //int stone3Place = packet.ReadInt(); bool consortia = packet.ReadBoolean(); List <ItemInfo> stones = new List <ItemInfo>(); ItemInfo item = client.Player.StoreBag2.GetItemAt(5); ItemInfo luck = null; ItemInfo god = null; string BeginProperty = null; string AddItem = ""; using (ItemRecordBussiness db = new ItemRecordBussiness()) { db.PropertyString(item, ref BeginProperty); } if (item != null && item.Template.CanStrengthen && item.Template.CategoryID < 18 && item.Count == 1) { isBinds = isBinds ? true : item.IsBinds; str.Append(item.ItemID + ":" + item.TemplateID + ","); ThreadSafeRandom random = new ThreadSafeRandom(); int result = 1; double probability = 0; bool isGod = false; StrengthenInfo strengthenInfo; StrengthenGoodsInfo strengthenGoodsInfo = null; if (item.Template.RefineryLevel > 0) { strengthenInfo = StrengthenMgr.FindRefineryStrengthenInfo(item.StrengthenLevel + 1); } else { strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(item.StrengthenLevel, item.TemplateID); strengthenInfo = StrengthenMgr.FindStrengthenInfo(item.StrengthenLevel + 1); } if (strengthenInfo == null) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoStrength")); return(0); } if (client.Player.StoreBag2.GetItemAt(3) != null) { god = client.Player.StoreBag2.GetItemAt(3); AddItem += "," + god.ItemID.ToString() + ":" + god.Template.Name; if (god != null && god.Template.CategoryID == 11 && god.Template.Property1 == 7) { isBinds = isBinds ? true : god.IsBinds; str.Append(god.ItemID + ":" + god.TemplateID + ","); isGod = true; } else { god = null; } } ItemInfo stone1 = client.Player.StoreBag2.GetItemAt(0); if (stone1 != null && stone1.Template.CategoryID == 11 && (stone1.Template.Property1 == 2 || stone1.Template.Property1 == 35) && !stones.Contains(stone1)) { isBinds = isBinds ? true : stone1.IsBinds; AddItem += "," + stone1.ItemID.ToString() + ":" + stone1.Template.Name; stones.Add(stone1); probability += stone1.Template.Property2; } ItemInfo stone2 = client.Player.StoreBag2.GetItemAt(1); if (stone2 != null && stone2.Template.CategoryID == 11 && (stone2.Template.Property1 == 2 || stone2.Template.Property1 == 35) && !stones.Contains(stone2)) { isBinds = isBinds ? true : stone2.IsBinds; AddItem += "," + stone2.ItemID.ToString() + ":" + stone2.Template.Name; stones.Add(stone2); probability += stone2.Template.Property2; } ItemInfo stone3 = client.Player.StoreBag2.GetItemAt(2); if (stone3 != null && stone3.Template.CategoryID == 11 && (stone3.Template.Property1 == 2 || stone3.Template.Property1 == 35) && !stones.Contains(stone3)) { isBinds = isBinds ? true : stone3.IsBinds; AddItem += "," + stone3.ItemID + ":" + stone3.Template.Name; stones.Add(stone3); probability += stone3.Template.Property2; } bool RefineryStrengthen = false; foreach (ItemInfo stoneinfo in stones) { if (stoneinfo.Template.Property1 == 35 && stoneinfo.Template.CategoryID == 11) { RefineryStrengthen = true; } else { RefineryStrengthen = false; } } //if (!RefineryStrengthen && item.Template.RefineryLevel > 0) //{ // client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.StoneMatch")); // return 1; //} if (client.Player.StoreBag2.GetItemAt(4) != null) { luck = client.Player.StoreBag2.GetItemAt(4); AddItem += "," + luck.ItemID.ToString() + ":" + luck.Template.Name; if (luck != null && luck.Template.CategoryID == 11 && luck.Template.Property1 == 3) { isBinds = isBinds ? true : luck.IsBinds; str.Append(luck.ItemID + ":" + luck.TemplateID + ","); probability = probability * (luck.Template.Property2 + 100); } else { probability *= 100; luck = null; } } else { probability *= 100; } bool CanUpdate = false; ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); //判断是公会铁匠铺还是铁匠铺?? if (consortia) { ConsortiaBussiness csbs = new ConsortiaBussiness(); ConsortiaEquipControlInfo cecInfo = csbs.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2); if (info == null) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail")); } else { if (client.Player.PlayerCharacter.Riches < cecInfo.Riches) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission")); return(1); } CanUpdate = true; } } if (stones.Count >= 1) { probability = probability / strengthenInfo.Rock; for (int i = 0; i < stones.Count; i++) { str.Append(stones[i].ItemID + ":" + stones[i].TemplateID + ","); AbstractInventory bg = client.Player.GetItemInventory(stones[i].Template); stones[i].Count--; bg.UpdateItem(stones[i]); } if (luck != null) { AbstractInventory bg = client.Player.GetItemInventory(luck.Template); bg.RemoveItem(luck); } if (god != null) { AbstractInventory bg = client.Player.GetItemInventory(god.Template); bg.RemoveItem(god); } if (CanUpdate) { probability *= (1 + 0.1 * info.SmithLevel); } item.IsBinds = isBinds; client.Player.StoreBag2.ClearBag(); if (probability > random.Next(10000)) { str.Append("true"); pkg.WriteByte(0); if (strengthenGoodsInfo != null) { ItemTemplateInfo Temp = Bussiness.Managers.ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip); if (Temp != null) { ItemInfo Item = ItemInfo.CreateFromTemplate(Temp, 1, (int)ItemAddType.Strengthen); Item.StrengthenLevel = item.StrengthenLevel + 1; ItemInfo.OpenHole(ref Item); StrengthenMgr.InheritProperty(item, ref Item); client.Player.RemoveItem(item); client.Player.AddTemplate(Item, Item.Template.BagType, Item.Count); item = Item; pkg.WriteBoolean(false); } } else { pkg.WriteBoolean(true); item.StrengthenLevel++; ItemInfo.OpenHole(ref item); //client.Player.MainBag.AddItem(item); client.Player.StoreBag2.AddItemTo(item, 5); } client.Player.OnItemStrengthen(item.Template.CategoryID, item.StrengthenLevel); //任务<强化> LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, BeginProperty, item, AddItem, 1); //强化日志 client.Player.SaveIntoDatabase(); //保存到数据库 //系统广播 if (item.StrengthenLevel >= 7) { string msg = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", client.Player.PlayerCharacter.NickName, item.Template.Name, item.StrengthenLevel); GSPacketIn pkg1 = new GSPacketIn((byte)ePackageType.SYS_NOTICE); pkg1.WriteInt(1); pkg1.WriteString(msg); GameServer.Instance.LoginServer.SendPacket(pkg1); GamePlayer[] players = Game.Server.Managers.WorldMgr.GetAllPlayers(); foreach (GamePlayer p in players) { p.Out.SendTCP(pkg1); } } } else { str.Append("false"); pkg.WriteByte(1); pkg.WriteBoolean(false); if (isGod == false) { if (item.Template.Level == 3) { item.StrengthenLevel = item.StrengthenLevel == 0 ? 0 : item.StrengthenLevel - 1; // client.Player.MainBag.AddItem(item); client.Player.StoreBag2.AddItemTo(item, 5); } else { item.Count--; // client.Player.MainBag.AddItem(item); client.Player.StoreBag2.AddItemTo(item, 5); } } else { //client.Player.MainBag.AddItem(item); client.Player.StoreBag2.AddItemTo(item, 5); } LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, BeginProperty, item, AddItem, 0); client.Player.SaveIntoDatabase();//保存到数据库 } client.Out.SendTCP(pkg); str.Append(item.StrengthenLevel); client.Player.BeginChanges(); client.Player.RemoveGold(mustGold); client.Player.CommitChanges(); } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1") + result + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2")); } if (item.Place < 31) { client.Player.MainBag.UpdatePlayerProperties(); } } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Success")); } return(0); }