public int HandlePacket(GameClient client, GSPacketIn packet) { GSPacketIn gSPacketIn = new GSPacketIn(110, client.Player.PlayerCharacter.ID); bool flag = false; int num = packet.ReadInt(); int num2 = packet.ReadInt(); List <ItemInfo> list = new List <ItemInfo>(); new List <ItemInfo>(); List <eBageType> list2 = new List <eBageType>(); StringBuilder stringBuilder = new StringBuilder(); int num3 = 25; if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.locked", new object[0])); return(1); } for (int i = 0; i < num2; i++) { eBageType eBageType = (eBageType)packet.ReadInt(); int place = packet.ReadInt(); ItemInfo itemAt = client.Player.GetItemAt(eBageType, place); if (itemAt != null) { if (list.Contains(itemAt)) { client.Out.SendMessage(eMessageType.Normal, "Bad Input"); return(1); } if (itemAt.IsBinds) { flag = true; } stringBuilder.Append(string.Concat(new object[] { itemAt.ItemID, ":", itemAt.TemplateID, "," })); list.Add(itemAt); list2.Add(eBageType); } } eBageType bagType = (eBageType)packet.ReadInt(); int place2 = packet.ReadInt(); ItemInfo itemAt2 = client.Player.GetItemAt(bagType, place2); if (itemAt2 != null) { stringBuilder.Append(string.Concat(new object[] { itemAt2.ItemID, ":", itemAt2.TemplateID, "," })); } eBageType bagType2 = (eBageType)packet.ReadInt(); int place3 = packet.ReadInt(); ItemInfo itemAt3 = client.Player.GetItemAt(bagType2, place3); bool flag2 = itemAt3 != null; if (num2 != 4 || itemAt2 == null) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemRefineryHandler.ItemNotEnough", new object[0])); return(1); } bool flag3 = false; bool flag4 = false; if (num == 0) { ItemTemplateInfo itemTemplateInfo = RefineryMgr.Refinery(client.Player, list, itemAt2, flag2, num, ref flag3, ref num3, ref flag4); if (itemTemplateInfo != null) { client.Out.SendRefineryPreview(client.Player, itemTemplateInfo.TemplateID, flag, itemAt2); } return(0); } int num4 = 10000; if (client.Player.PlayerCharacter.Gold > num4) { client.Player.RemoveGold(num4); ItemTemplateInfo itemTemplateInfo2 = RefineryMgr.Refinery(client.Player, list, itemAt2, flag2, num, ref flag3, ref num3, ref flag4); if (itemTemplateInfo2 != null && flag4 && flag3) { stringBuilder.Append("Success"); flag3 = true; if (flag3) { ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo2, 1, 114); if (itemInfo != null) { client.Player.OnItemMelt(itemAt2.Template.CategoryID); itemInfo.IsBinds = flag; AbstractInventory itemInventory = client.Player.GetItemInventory(itemTemplateInfo2); if (!itemInventory.AddItem(itemInfo, itemInventory.BeginSlot)) { stringBuilder.Append("NoPlace"); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(itemInfo.GetBagName(), new object[0]) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace", new object[0])); } gSPacketIn.WriteByte(0); itemAt2.Count--; client.Player.UpdateItem(itemAt2); } } else { stringBuilder.Append("false"); } } else { gSPacketIn.WriteByte(1); } if (flag2) { itemAt3.Count--; client.Player.UpdateItem(itemAt3); } for (int j = 0; j < list.Count; j++) { client.Player.UpdateItem(list[j]); if (list[j].Count <= 0) { client.Player.RemoveItem(list[j]); } } client.Player.RemoveItem(list[list.Count - 1]); client.Player.Out.SendTCP(gSPacketIn); } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemRefineryHandler.NoGold", new object[0])); } return(1); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { AASInfo info = new AASInfo(); info.UserID = player.PlayerCharacter.ID; bool rlt = false; bool isclosed = packet.ReadBoolean(); bool result; if (isclosed) { info.Name = ""; info.IDNumber = ""; info.State = 0; result = true; } else { info.Name = packet.ReadString(); info.IDNumber = packet.ReadString(); result = this.CheckIDNumber(info.IDNumber); if (info.IDNumber != "") { player.IsAASInfo = true; int Age = Convert.ToInt32(info.IDNumber.Substring(6, 4)); int month = Convert.ToInt32(info.IDNumber.Substring(10, 2)); if (DateTime.Now.Year.CompareTo(Age + 18) > 0 || (DateTime.Now.Year.CompareTo(Age + 18) == 0 && DateTime.Now.Month.CompareTo(month) >= 0)) { player.IsMinor = false; } } if (info.Name != "" && result) { info.State = 1; } else { info.State = 0; } } if (result) { player.Out.SendAASState(false); player.Out.SendAASControl(false, player.IsAASInfo, player.IsMinor); using (ProduceBussiness db = new ProduceBussiness()) { rlt = db.AddAASInfo(info); } } else { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("AASInfoSetHandle.error", new object[0])); } if (rlt && info.State == 1) { ItemTemplateInfo rewardItem = ItemMgr.FindItemTemplate(11019); if (rewardItem != null) { ItemInfo item = ItemInfo.CreateFromTemplate(rewardItem, 1, 107); if (item != null) { item.IsBinds = true; AbstractInventory bg = player.GetItemInventory(item.Template); if (bg.AddItem(item)) { player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.Success", new object[] { item.Template.Name })); } else { player.SendItemToMail(item, LanguageMgr.GetTranslation("ASSInfoSetHandle.Content", new object[] { item.Template.Name }), LanguageMgr.GetTranslation("ASSInfoSetHandle.Title", new object[] { item.Template.Name }), eMailType.Common); player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver); player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.NoPlace", new object[0])); } } } } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); bool IsBinds = false; int OpertionType = packet.ReadInt(); int Count = packet.ReadInt(); List <ItemInfo> Items = new List <ItemInfo>(); List <ItemInfo> AppendItems = new List <ItemInfo>(); List <eBageType> BagTypes = new List <eBageType>(); StringBuilder str = new StringBuilder(); int defaultprobability = 25; 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.ReadInt(); int place = packet.ReadInt(); ItemInfo info = client.Player.GetItemAt(bagType, place); if (info != null) { if (!Items.Contains(info)) { if (info.IsBinds == true) { IsBinds = true; } str.Append(info.ItemID + ":" + info.TemplateID + ","); Items.Add(info); BagTypes.Add(bagType); } else { client.Out.SendMessage(eMessageType.Normal, "Bad Input"); return(1); } } } // ItemInfo MainMaterial = client.Player.GetItemAt(packet.ReadInt(), packet.ReadInt()); eBageType BagType = (eBageType)packet.ReadInt(); int Place = packet.ReadInt(); ItemInfo Item = client.Player.GetItemAt(BagType, Place); if (Item != null) { str.Append(Item.ItemID + ":" + Item.TemplateID + ","); } eBageType LuckBagType = (eBageType)packet.ReadInt(); int LuckPlace = packet.ReadInt(); ItemInfo LuckItem = client.Player.GetItemAt(LuckBagType, LuckPlace);; bool Luck = LuckItem == null ? false : true; //if (IsBinds != Item.IsBinds && IsBinds == true) //{ // client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemRefineryHandler.IsBinds")); // // return 1; //} if (Count != 4 || Item == null) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemRefineryHandler.ItemNotEnough")); return(1); } bool result = false; bool IsFormula = false; if (OpertionType == 0) //预览模式 { ItemTemplateInfo Template = Managers.RefineryMgr.Refinery(client.Player, Items, Item, Luck, OpertionType, ref result, ref defaultprobability, ref IsFormula); if (Template != null) { client.Out.SendRefineryPreview(client.Player, Template.TemplateID, IsBinds, Item); } return(0); } else //玩家炼化 { int MustGold = 10000; if (client.Player.PlayerCharacter.Gold > MustGold) { client.Player.RemoveGold(MustGold); ItemTemplateInfo RewardItem = Managers.RefineryMgr.Refinery(client.Player, Items, Item, Luck, OpertionType, ref result, ref defaultprobability, ref IsFormula); if (RewardItem != null && IsFormula && result) { str.Append("Success"); result = true; if (result) { ItemInfo item = ItemInfo.CreateFromTemplate(RewardItem, 1, (int)ItemAddType.Refinery); if (item != null) { client.Player.OnItemMelt(Item.Template.CategoryID); // Managers.RefineryMgr.InheritProperty(Item, ref item); item.IsBinds = IsBinds; AbstractInventory bg = client.Player.GetItemInventory(RewardItem); if (!bg.AddItem(item, bg.BeginSlot)) { str.Append("NoPlace"); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(item.GetBagName()) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace")); } pkg.WriteByte(0); Item.Count--; client.Player.UpdateItem(Item); } } else { str.Append("false"); } } else { pkg.WriteByte(1); } if (Luck) { LuckItem.Count--; client.Player.UpdateItem(LuckItem); } for (int i = 0; i < Items.Count; i++) { client.Player.UpdateItem(Items[i]); if (Items[i].Count <= 0) { client.Player.RemoveItem(Items[i]); } } client.Player.RemoveItem(Items[Items.Count - 1]); client.Player.Out.SendTCP(pkg); } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemRefineryHandler.NoGold")); } return(1); } }
public int HandlePacket(GameClient client, GSPacketIn packet) { eBageType ItemBagType = (eBageType)packet.ReadInt(); int ItemPlace = packet.ReadInt(); eBageType PropBagType = (eBageType)packet.ReadInt(); ItemInfo Item = null; List <ShopItemInfo> ShopItem = new List <ShopItemInfo>(); ItemInfo Prop = null; int PropPlace = packet.ReadInt(); int Operation = packet.ReadInt(); if (PropPlace == -1) { int templateID = packet.ReadInt(); int type = packet.ReadInt(); int gold = 0; int money = 0; ItemTemplateInfo template = Bussiness.Managers.ItemMgr.FindItemTemplate(34101); Prop = ItemInfo.CreateFromTemplate(template, 1, (int)ItemAddType.Buy); ShopItem = Bussiness.Managers.ShopMgr.FindShopbyTemplatID(34101); for (int i = 0; i < ShopItem.Count; i++) { if (ShopItem[i].APrice1 == -1 && ShopItem[i].AValue1 != 0) { money = ShopItem[i].AValue1; Prop.ValidDate = ShopItem[i].AUnit; } } if (Prop != null) { // item = ItemInfo.SetItemType(item, type, ref gold, ref money, ref offer); if (gold <= client.Player.PlayerCharacter.Gold && money <= client.Player.PlayerCharacter.Money) { client.Player.RemoveMoney(money); client.Player.RemoveGold(gold); LogMgr.LogMoneyAdd(LogMoneyType.Item, LogMoneyType.Item_Move, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, gold, 0, 0, "牌子编号", Prop.TemplateID.ToString(), type.ToString()); } else { Prop = null; } } } else { Prop = client.Player.GetItemAt(PropBagType, PropPlace); } Item = client.Player.GetItemAt(ItemBagType, ItemPlace); StringBuilder str = new StringBuilder(); if (Prop == null || Item == null) { return(1); } bool result = false; ItemTemplateInfo TemplateItem = Managers.RefineryMgr.RefineryTrend(Operation, Item, ref result); if (result && TemplateItem != null) { ItemInfo item = ItemInfo.CreateFromTemplate(TemplateItem, 1, (int)ItemAddType.RefineryTrend); AbstractInventory bg = client.Player.GetItemInventory(TemplateItem); // Managers.RefineryMgr.InheritProperty(Item, ref item); if (bg.AddItem(item, bg.BeginSlot)) { client.Player.UpdateItem(item); client.Player.RemoveItem(Item); Prop.Count--; client.Player.UpdateItem(Prop); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Success")); } else { str.Append("NoPlace"); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(item.GetBagName()) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace")); } return(1); } else { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Fail")); return(1); } }
public int HandlePacket(GameClient client, GSPacketIn packet) { AASInfo info = new AASInfo(); info.UserID = client.Player.PlayerCharacter.ID; bool result = false; bool rlt = false; bool isclosed = packet.ReadBoolean(); if (isclosed) { info.Name = ""; info.IDNumber = ""; info.State = 0; result = true; } else { info.Name = packet.ReadString(); info.IDNumber = packet.ReadString(); result = CheckIDNumber(info.IDNumber); if (info.IDNumber != "") { client.Player.IsAASInfo = true; //result = false; int Age = Convert.ToInt32(info.IDNumber.Substring(6, 4)); int month = Convert.ToInt32(info.IDNumber.Substring(10, 2)); if (DateTime.Now.Year.CompareTo(Age + 18) > 0 || (DateTime.Now.Year.CompareTo(Age + 18) == 0 && DateTime.Now.Month.CompareTo(month) >= 0)) { client.Player.IsMinor = false; } } if (info.Name != "" && result) { info.State = 1; } else { info.State = 0; } } if (result) { client.Out.SendAASState(false); //client.Out.SendAASControl(false, client.Player.IsAASInfo, client.Player.IsMinor); using (ProduceBussiness db = new ProduceBussiness()) { rlt = db.AddAASInfo(info); client.Out.SendAASInfoSet(rlt); } } if (rlt && (info.State == 1)) { ItemTemplateInfo rewardItem = Bussiness.Managers.ItemMgr.FindItemTemplate(11019); if (rewardItem != null) { ItemInfo item = ItemInfo.CreateFromTemplate(rewardItem, 1, (int)ItemAddType.Other); if (item != null) { item.IsBinds = true; AbstractInventory bg = client.Player.GetItemInventory(item.Template); if (bg.AddItem(item, bg.BeginSlot)) { client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.Success", item.Template.Name)); } else { client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.NoPlace")); } } } } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { AASInfo aASInfo = new AASInfo(); aASInfo.UserID = client.Player.PlayerCharacter.ID; bool flag = false; bool flag2 = packet.ReadBoolean(); bool flag3; if (flag2) { aASInfo.Name = ""; aASInfo.IDNumber = ""; aASInfo.State = 0; flag3 = true; } else { aASInfo.Name = packet.ReadString(); aASInfo.IDNumber = packet.ReadString(); flag3 = this.CheckIDNumber(aASInfo.IDNumber); if (aASInfo.IDNumber != "") { client.Player.IsAASInfo = true; int num = Convert.ToInt32(aASInfo.IDNumber.Substring(6, 4)); int value = Convert.ToInt32(aASInfo.IDNumber.Substring(10, 2)); if (DateTime.Now.Year.CompareTo(num + 18) > 0 || (DateTime.Now.Year.CompareTo(num + 18) == 0 && DateTime.Now.Month.CompareTo(value) >= 0)) { client.Player.IsMinor = false; } } if (aASInfo.Name != "" && flag3) { aASInfo.State = 1; } else { aASInfo.State = 0; } } if (flag3) { client.Out.SendAASState(false); using (ProduceBussiness produceBussiness = new ProduceBussiness()) { flag = produceBussiness.AddAASInfo(aASInfo); client.Out.SendAASInfoSet(flag); } } if (flag && aASInfo.State == 1) { ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(11019); if (itemTemplateInfo != null) { ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 107); if (itemInfo != null) { itemInfo.IsBinds = true; AbstractInventory itemInventory = client.Player.GetItemInventory(itemInfo.Template); if (itemInventory.AddItem(itemInfo, itemInventory.BeginSlot)) { client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.Success", new object[] { itemInfo.Template.Name })); } else { client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.NoPlace", new object[0])); } } } } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { eBageType bagType = (eBageType)packet.ReadInt(); int place = packet.ReadInt(); eBageType bagType2 = (eBageType)packet.ReadInt(); List <ShopItemInfo> list = new List <ShopItemInfo>(); int num = packet.ReadInt(); int operation = packet.ReadInt(); ItemInfo itemInfo; if (num == -1) { packet.ReadInt(); int num2 = packet.ReadInt(); int num3 = 0; int num4 = 0; ItemTemplateInfo goods = ItemMgr.FindItemTemplate(34101); itemInfo = ItemInfo.CreateFromTemplate(goods, 1, 102); list = ShopMgr.FindShopbyTemplatID(34101); for (int i = 0; i < list.Count; i++) { if (list[i].APrice1 == -1 && list[i].AValue1 != 0) { num4 = list[i].AValue1; itemInfo.ValidDate = list[i].AUnit; } } if (itemInfo != null) { if (num3 <= client.Player.PlayerCharacter.Gold && num4 <= client.Player.PlayerCharacter.Money) { client.Player.RemoveMoney(num4); client.Player.RemoveGold(num3); LogMgr.LogMoneyAdd(LogMoneyType.Item, LogMoneyType.Item_Move, client.Player.PlayerCharacter.ID, num4, client.Player.PlayerCharacter.Money, num3, 0, 0, 0, "牌子编号", itemInfo.TemplateID.ToString(), num2.ToString()); } else { itemInfo = null; } } } else { itemInfo = client.Player.GetItemAt(bagType2, num); } ItemInfo itemAt = client.Player.GetItemAt(bagType, place); StringBuilder stringBuilder = new StringBuilder(); if (itemInfo == null || itemAt == null) { return(1); } bool flag = false; ItemTemplateInfo itemTemplateInfo = RefineryMgr.RefineryTrend(operation, itemAt, ref flag); if (flag && itemTemplateInfo != null) { ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 115); AbstractInventory itemInventory = client.Player.GetItemInventory(itemTemplateInfo); if (itemInventory.AddItem(itemInfo2, itemInventory.BeginSlot)) { client.Player.UpdateItem(itemInfo2); client.Player.RemoveItem(itemAt); itemInfo.Count--; client.Player.UpdateItem(itemInfo); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Success", new object[0])); } else { stringBuilder.Append("NoPlace"); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(itemInfo2.GetBagName(), new object[0]) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace", new object[0])); } return(1); } client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Fail", new object[0])); return(1); }