/// <summary> /// 定时保存 /// </summary> public static void Save() { int online = LoginMgr.GetOnlineCount();//在线人数 object[] info = { _gameType, _serverId, DateTime.Now, online, RegCount }; //lock (m_LogServer) //{ // m_LogServer.Rows.Add(info); //} RegCount = 0; int interval = SaveRecordSecond; using (ItemRecordBussiness db = new ItemRecordBussiness()) { db.LogServerDb(m_LogServer); } }
public static void Save() { if (LogMgr._syncStop != null) { object syncStop; Monitor.Enter(syncStop = LogMgr._syncStop); try { using (ItemRecordBussiness itemRecordBussiness = new ItemRecordBussiness()) { LogMgr.SaveLogItem(itemRecordBussiness); LogMgr.SaveLogMoney(itemRecordBussiness); LogMgr.SaveLogFight(itemRecordBussiness); } } finally { Monitor.Exit(syncStop); } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { GSPacketIn gSPacketIn = new GSPacketIn(58, client.Player.PlayerCharacter.ID); StringBuilder stringBuilder = new StringBuilder(); int pRICE_COMPOSE_GOLD = GameProperties.PRICE_COMPOSE_GOLD; if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(0); } if (client.Player.PlayerCharacter.Gold < pRICE_COMPOSE_GOLD) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemComposeHandler.NoMoney", new object[0])); return(0); } int num = -1; int num2 = -1; bool flag = false; bool flag2 = packet.ReadBoolean(); ItemInfo itemAt = client.Player.StoreBag.GetItemAt(1); ItemInfo itemAt2 = client.Player.StoreBag.GetItemAt(2); ItemInfo itemInfo = null; ItemInfo itemInfo2 = null; string beginProperty = null; string text = null; using (ItemRecordBussiness itemRecordBussiness = new ItemRecordBussiness()) { itemRecordBussiness.PropertyString(itemAt, ref beginProperty); } if (itemAt != null && itemAt2 != null && itemAt.Template.CanCompose && (itemAt.Template.CategoryID < 10 || (itemAt2.Template.CategoryID == 11 && itemAt2.Template.Property1 == 1))) { flag = (flag || itemAt.IsBinds); flag = (flag || itemAt2.IsBinds); stringBuilder.Append(string.Concat(new object[] { itemAt.ItemID, ":", itemAt.TemplateID, ",", itemAt2.ItemID, ":", itemAt2.TemplateID, "," })); bool flag3 = false; byte b = 1; double num3 = ItemComposeHandler.composeRate[itemAt2.Template.Quality - 1] * 100.0; if (client.Player.StoreBag.GetItemAt(0) != null) { itemInfo = client.Player.StoreBag.GetItemAt(0); if (itemInfo != null && itemInfo.Template.CategoryID == 11 && itemInfo.Template.Property1 == 3) { flag = (flag || itemInfo.IsBinds); object obj = text; text = string.Concat(new object[] { obj, "|", itemInfo.ItemID, ":", itemInfo.Template.Name, "|", itemAt2.ItemID, ":", itemAt2.Template.Name }); stringBuilder.Append(string.Concat(new object[] { itemInfo.ItemID, ":", itemInfo.TemplateID, "," })); num3 += num3 * (double)itemInfo.Template.Property2 / 100.0; } } else { num3 += num3 * 1.0 / 100.0; } if (num2 != -1) { itemInfo2 = client.Player.PropBag.GetItemAt(num2); if (itemInfo2 != null && itemInfo2.Template.CategoryID == 11 && itemInfo2.Template.Property1 == 7) { flag = (flag || itemInfo2.IsBinds); stringBuilder.Append(string.Concat(new object[] { itemInfo2.ItemID, ":", itemInfo2.TemplateID, "," })); object obj2 = text; text = string.Concat(new object[] { obj2, ",", itemInfo2.ItemID, ":", itemInfo2.Template.Name }); } else { itemInfo2 = null; } } if (flag2) { ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); 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); } num3 *= 1.0 + 0.1 * (double)consortiaInfo.SmithLevel; } } num3 = Math.Floor(num3 * 10.0) / 10.0; int num4 = ItemComposeHandler.random.Next(100); switch (itemAt2.Template.Property3) { case 1: if (itemAt2.Template.Property4 > itemAt.AttackCompose) { flag3 = true; if (num3 > (double)num4) { b = 0; itemAt.AttackCompose = itemAt2.Template.Property4; } } break; case 2: if (itemAt2.Template.Property4 > itemAt.DefendCompose) { flag3 = true; if (num3 > (double)num4) { b = 0; itemAt.DefendCompose = itemAt2.Template.Property4; } } break; case 3: if (itemAt2.Template.Property4 > itemAt.AgilityCompose) { flag3 = true; if (num3 > (double)num4) { b = 0; itemAt.AgilityCompose = itemAt2.Template.Property4; } } break; case 4: if (itemAt2.Template.Property4 > itemAt.LuckCompose) { flag3 = true; if (num3 > (double)num4) { b = 0; itemAt.LuckCompose = itemAt2.Template.Property4; } } break; } if (flag3) { itemAt.IsBinds = flag; if (b != 0) { stringBuilder.Append("false!"); flag3 = false; } else { stringBuilder.Append("true!"); flag3 = true; client.Player.OnItemCompose(itemAt2.TemplateID); } LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Compose, beginProperty, itemAt, text, Convert.ToInt32(flag3)); client.Player.StoreBag.RemoveTemplate(itemAt2.TemplateID, 1); if (itemInfo != null) { client.Player.StoreBag.RemoveTemplate(itemInfo.TemplateID, 1); } if (itemInfo2 != null) { client.Player.RemoveItem(itemInfo2); } client.Player.RemoveGold(pRICE_COMPOSE_GOLD); client.Player.StoreBag.UpdateItem(itemAt); gSPacketIn.WriteByte(b); client.Out.SendTCP(gSPacketIn); if (num < 31) { client.Player.MainBag.UpdatePlayerProperties(); } } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.NoLevel", new object[0])); } } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.Fail", new object[0])); } return(0); }
public static int countConnect = 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(); int mustGold = GameProperties.PRICE_COMPOSE_GOLD; if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked")); return(0); } if (client.Player.PlayerCharacter.Gold < mustGold) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemComposeHandler.NoMoney")); return(0); } int itemPlace = -1; int godPlace = -1; bool isBinds = false; bool consortia = packet.ReadBoolean(); ItemInfo item = client.Player.StoreBag2.GetItemAt(1); ItemInfo stone = client.Player.StoreBag2.GetItemAt(2); ItemInfo luck = null; ItemInfo god = null; string BeginProperty = null; string AddItem = null; using (ItemRecordBussiness db = new ItemRecordBussiness()) { db.PropertyString(item, ref BeginProperty); } if (item != null && stone != null && item.Template.CanCompose && (item.Template.CategoryID < 10 || stone.Template.CategoryID == 11 && stone.Template.Property1 == 1)) { isBinds = isBinds ? true : item.IsBinds; isBinds = isBinds ? true : stone.IsBinds; str.Append(item.ItemID + ":" + item.TemplateID + "," + stone.ItemID + ":" + stone.TemplateID + ","); ThreadSafeRandom random = new ThreadSafeRandom(); bool result = false; byte isSuccess = 1; //bool isGod = false; double probability = composeRate[(stone.Template.Quality - 1)] * 100;//stone.Template.Property2; if (client.Player.StoreBag2.GetItemAt(0) != null) { luck = client.Player.StoreBag2.GetItemAt(0); if (luck != null && luck.Template.CategoryID == 11 && luck.Template.Property1 == 3) { isBinds = isBinds ? true : luck.IsBinds; AddItem += "|" + luck.ItemID + ":" + luck.Template.Name + "|" + stone.ItemID + ":" + stone.Template.Name; str.Append(luck.ItemID + ":" + luck.TemplateID + ","); probability += probability * luck.Template.Property2 / 100; } } else { probability += probability * 1 / 100; } if (godPlace != -1) { god = client.Player.PropBag.GetItemAt(godPlace); if (god != null && god.Template.CategoryID == 11 && god.Template.Property1 == 7) { isBinds = isBinds ? true : god.IsBinds; //isGod = true; str.Append(god.ItemID + ":" + god.TemplateID + ","); AddItem += "," + god.ItemID + ":" + god.Template.Name; } else { god = null; } } //判断是公会铁匠铺还是铁匠铺 if (consortia) { ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID); //这里添加公会权限限制的判断 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); } else { probability *= (1 + 0.1 * info.SmithLevel); } } } probability = Math.Floor(probability * 10) / 10; //client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Probability: " + probability.ToString())); int rand = random.Next(100); switch (stone.Template.Property3) { case 1: if (stone.Template.Property4 > item.AttackCompose) { result = true; if (probability > rand) { isSuccess = 0; item.AttackCompose = stone.Template.Property4; } } break; case 2: if (stone.Template.Property4 > item.DefendCompose) { result = true; if (probability > rand) { isSuccess = 0; item.DefendCompose = stone.Template.Property4; } } break; case 3: if (stone.Template.Property4 > item.AgilityCompose) { result = true; if (probability > rand) { isSuccess = 0; item.AgilityCompose = stone.Template.Property4; } } break; case 4: if (stone.Template.Property4 > item.LuckCompose) { result = true; if (probability > rand) { isSuccess = 0; item.LuckCompose = stone.Template.Property4; } } break; } if (result) { item.IsBinds = isBinds; if (isSuccess != 0) { str.Append("false!"); result = false; } else { str.Append("true!"); result = true; client.Player.OnItemCompose(stone.TemplateID); } LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Compose, BeginProperty, item, AddItem, Convert.ToInt32(result)); client.Player.RemoveItem(stone); client.Player.SaveIntoDatabase();//保存到数据库 if (luck != null) { client.Player.RemoveItem(luck); } if (god != null) { client.Player.RemoveItem(god); } client.Player.RemoveGold(mustGold); client.Player.StoreBag2.ClearBag(); client.Player.StoreBag2.AddItemTo(item, 1); //client.Player.StoreBag2.UpdateItem(item); pkg.WriteByte(isSuccess); client.Out.SendTCP(pkg); if (itemPlace < 31) { client.Player.MainBag.UpdatePlayerProperties(); } } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.NoLevel")); } } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.Fail")); } return(0); }
/// <summary> /// 熔炼步骤 /// 第一步:检查四个熔炼类型与熔炼物品&是否有二级密码 /// 第二步:检验数据是否合乎熔炼规则 /// 第三步:生成预览或生成物品 /// </summary> /// <param name="client"></param> /// <param name="packet"></param> /// <returns></returns> /// public int HandlePacket(GameClient client, GSPacketIn packet) { StringBuilder str = new StringBuilder(); //第一步:传入操作类型、与四个石头 int opertionType = packet.ReadByte(); int count = packet.ReadInt(); int MinValid = int.MaxValue; //默认最短有效时间 List <ItemInfo> items = new List <ItemInfo>(); List <ItemInfo> appendItems = new List <ItemInfo>(); List <eBageType> bagTypes = new List <eBageType>(); if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked")); return(1); } for (int i = 0; i < count; i++) { eBageType bagType = (eBageType)packet.ReadByte(); int place = packet.ReadInt(); ItemInfo info = client.Player.GetItemAt(bagType, place); if (info != null) { //str.Append(info.ItemID + ":" + info.TemplateID + ","); //items.Add(info); //bagTypes.Add(bagType); if (!items.Contains(info)) { str.Append(info.ItemID + ":" + info.TemplateID + ","); items.Add(info); bagTypes.Add(bagType); if (info.ValidDate < MinValid && info.ValidDate != 0) { MinValid = info.ValidDate; } } else { client.Out.SendMessage(eMessageType.Normal, "Bad Input"); return(1); } } } if (MinValid == int.MaxValue) { MinValid = 0; items.Clear(); } //第二步:传入熔炼公式与背包类型 eBageType bagformul = (eBageType)packet.ReadByte(); int placeformul = packet.ReadInt(); var storeBag2 = client.Player.StoreBag2; ItemInfo formul = storeBag2.GetItemAt(0);; ItemInfo tempitem = null; string beginProperty = null; string AddItem = ""; for (int i = 1; i <= 4; i++) { items.Add(storeBag2.GetItemAt(i)); } using (ItemRecordBussiness db = new ItemRecordBussiness()) { foreach (ItemInfo item in items) { db.FusionItem(item, ref beginProperty); } } if (items.Count != 4 || formul == null) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.ItemNotEnough")); return(0); } //第三步:附加物品个数+(背包类型与附加物品位置) int appendCount = packet.ReadInt(); List <eBageType> bagTypesAppend = new List <eBageType>(); for (int i = 0; i < appendCount; i++) { eBageType bagType = (eBageType)packet.ReadByte(); int place = packet.ReadInt(); ItemInfo info = client.Player.GetItemAt(bagType, place); if (info != null) { if (!items.Contains(info) && !appendItems.Contains(info)) { str.Append(info.ItemID + ":" + info.TemplateID + ","); appendItems.Add(info); bagTypesAppend.Add(bagType); AddItem += info.ItemID + ":" + info.Template.Name + "," + info.IsBinds + "|"; } else { client.Out.SendMessage(eMessageType.Normal, "Bad Input"); return(1); } } } //结束:预览或熔炼 if (0 == opertionType) //预览模式 { bool isBind = false; Dictionary <int, double> previewItemList = FusionMgr.FusionPreview(items, appendItems, formul, ref isBind); if (previewItemList != null) { if (previewItemList.Count != 0) { client.Out.SendFusionPreview(client.Player, previewItemList, isBind, MinValid); } } } else //生成熔炼物品 { storeBag2.ClearBag(); int mustGold = (count + appendCount) * 400; if (client.Player.PlayerCharacter.Gold < mustGold) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemFusionHandler.NoMoney")); return(0); } bool isBind = false; bool result = false; ItemTemplateInfo rewardItem = FusionMgr.Fusion(items, appendItems, formul, ref isBind, ref result); if (rewardItem != null) { client.Player.RemoveGold(mustGold); for (int i = 0; i < items.Count; i++) { items[i].Count--; client.Player.UpdateItem(items[i]); } formul.Count--; client.Player.UpdateItem(formul); for (int i = 0; i < appendItems.Count; i++) { appendItems[i].Count--; client.Player.UpdateItem(appendItems[i]); } if (result) { str.Append(rewardItem.TemplateID + ","); ItemInfo item = ItemInfo.CreateFromTemplate(rewardItem, 1, (int)ItemAddType.Fusion); if (item == null) { return(0); } tempitem = item; item.IsBinds = isBind; item.ValidDate = MinValid; client.Player.OnItemFusion(item.Template.FusionType); //熔炼成功 client.Out.SendFusionResult(client.Player, result); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.Succeed1") + item.Template.Name); //系统广播 if (((item.TemplateID >= 8300) && (item.TemplateID <= 8999)) || ((item.TemplateID >= 9300) && (item.TemplateID <= 9999)) || ((item.TemplateID >= 14300) && (item.TemplateID <= 14999))) { string msg = LanguageMgr.GetTranslation("ItemFusionHandler.Notice", client.Player.PlayerCharacter.NickName, item.Template.Name); //client.Out.SendSystemNotice(msg); 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); } } if (!client.Player.AddTemplate(item, item.Template.BagType, item.Count)) { str.Append("NoPlace"); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(item.GetBagName()) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace")); } } else { str.Append("false"); client.Out.SendFusionResult(client.Player, result); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.Failed")); } LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Fusion, beginProperty, tempitem, AddItem, Convert.ToInt32(result)); client.Player.SaveIntoDatabase();//保存到数据库 } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.NoCondition")); } } return(0); }
public static int countConnect = 0; public int HandlePacket(GameClient client, GSPacketIn packet) { if (countConnect >= 3000) { client.Disconnect(); return(0); } GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); int ItemBagType = packet.ReadInt(); int ItemPlace = packet.ReadInt(); int HoleNum = packet.ReadInt(); int GemBagType = packet.ReadInt(); int GemPlace = packet.ReadInt(); ItemInfo Item = client.Player.GetItemAt((eBageType)ItemBagType, ItemPlace); ItemInfo Gem = client.Player.GetItemAt((eBageType)GemBagType, GemPlace); string BeginProperty = null; string AddItem = ""; using (ItemRecordBussiness db = new ItemRecordBussiness()) { db.PropertyString(Item, ref BeginProperty); } int Glod = 2000; if (Item == null || Gem == null || Gem.Template.Property1 != 31) { return(0); } if (client.Player.PlayerCharacter.Gold > Glod) { string[] Hole = Item.Template.Hole.Split('|'); if (HoleNum > 0 && HoleNum < 7) { client.Player.RemoveGold(Glod); bool result = false; switch (HoleNum) { case 1: if (Item.Hole1 >= 0) { string[] str = Hole[0].Split(','); if (Convert.ToInt32(str[1]) == Gem.Template.Property2) { Item.Hole1 = Gem.TemplateID; AddItem += "," + Gem.ItemID + "," + Gem.Template.Name; result = true; } } break; case 2: if (Item.Hole2 >= 0) { string[] str = Hole[1].Split(','); if (Convert.ToInt32(str[1]) == Gem.Template.Property2) { Item.Hole2 = Gem.TemplateID; AddItem += "," + Gem.ItemID + "," + Gem.Template.Name; result = true; } } break; case 3: if (Item.Hole3 >= 0) { string[] str = Hole[2].Split(','); if (Convert.ToInt32(str[1]) == Gem.Template.Property2) { Item.Hole3 = Gem.TemplateID; AddItem += "," + Gem.ItemID + "," + Gem.Template.Name; result = true; } } break; case 4: if (Item.Hole4 >= 0) { string[] str = Hole[3].Split(','); if (Convert.ToInt32(str[1]) == Gem.Template.Property2) { Item.Hole4 = Gem.TemplateID; AddItem += "," + Gem.ItemID + "," + Gem.Template.Name; result = true; } } break; case 5: if (Item.Hole5 >= 0) { string[] str = Hole[4].Split(','); if (Convert.ToInt32(str[1]) == Gem.Template.Property2) { Item.Hole5 = Gem.TemplateID; AddItem += "," + Gem.ItemID + "," + Gem.Template.Name; result = true; } } break; case 6: if (Item.Hole6 >= 0) { string[] str = Hole[5].Split(','); if (Convert.ToInt32(str[1]) == Gem.Template.Property2) { Item.Hole6 = Gem.TemplateID; AddItem += "," + Gem.ItemID + "," + Gem.Template.Name; result = true; } } break; } if (result) { client.Player.StoreBag2.MoveToStore(client.Player.StoreBag2, 0, client.Player.MainBag.FindFirstEmptySlot(32), client.Player.MainBag, 9); pkg.WriteInt(0); Gem.Count--; client.Player.UpdateItem(Gem); client.Player.UpdateItem(Item); //client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemInlayHandle.Success", Gem.Template.Name)); } LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Insert, BeginProperty, Item, AddItem, Convert.ToInt32(result)); } else { pkg.WriteByte(1); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemInlayHandle.NoPlace")); } client.Player.SendTCP(pkg); client.Player.SaveIntoDatabase();//保存到数据库 } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserBuyItemHandler.NoMoney")); } return(0); }
//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 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); }