private static bool AddComposeItemsToHideBag(GamePlayer player, ItemInfo item) { int place = -1; if (item.TemplateID >= 11001 && item.TemplateID <= 11016) { place = 2; } if (item.TemplateID == 11018) { place = 0; } bool result; if (place != -1 && player.HideBag.IsEmpty(place)) { if (item.Count > 1) { ItemInfo copyitem = item.Clone(); copyitem.Count = 1; item.Count--; result = (player.HideBag.AddItemTo(copyitem, place) && player.AddItem(item)); } else { result = player.HideBag.AddItemTo(item, place); } } else { result = player.AddItem(item); } return(result); }
public bool GetAnnex(string value, GamePlayer player, ref string msg, ref bool result, ref eMessageType eMsg) { int gid = int.Parse(value); using (PlayerBussiness db = new PlayerBussiness()) { ItemInfo goods = db.GetUserItemSingle(gid); if (goods != null) { if (goods.TemplateID == 11408) { player.AddMedal(goods.Count); return(true); } else { if (player.AddItem(goods)) { eMsg = eMessageType.Normal; return(true); } else { eMsg = eMessageType.ERROR; result = false; msg = LanguageMgr.GetTranslation(goods.GetBagName()) + LanguageMgr.GetTranslation("MailGetAttachHandler.NoPlace"); } } } } return(false); }
public bool GetAnnex(string value, GamePlayer player, ref string msg, ref bool result, ref eMessageType eMsg) { int itemID = int.Parse(value); using (PlayerBussiness playerBussiness = new PlayerBussiness()) { ItemInfo userItemSingle = playerBussiness.GetUserItemSingle(itemID); if (userItemSingle != null) { if (userItemSingle.TemplateID == 11408) { player.AddMedal(userItemSingle.Count); bool result2 = true; return(result2); } if (player.StackItemToAnother(userItemSingle) || player.AddItem(userItemSingle)) { eMsg = eMessageType.Normal; bool result2 = true; return(result2); } eMsg = eMessageType.ERROR; result = false; msg = LanguageMgr.GetTranslation(userItemSingle.GetBagName(), new object[0]) + LanguageMgr.GetTranslation("MailGetAttachHandler.NoPlace", new object[0]); } } return(false); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int Place = packet.ReadInt(); int Templateid = packet.ReadInt(); ItemInfo Item = player.HideBag.GetItemAt(0); int result2; if (Place <= 0 || Templateid <= 0) { result2 = 0; } else { int NeedMoney = 500; if (player.PlayerCharacter.GiftToken < NeedMoney) { result2 = 0; } else { bool result = false; int Hole = this.GetItemHole(Place, Item); if (Hole == Templateid) { ItemTemplateInfo template = ItemMgr.FindItemTemplate(Templateid); if (template != null) { ItemInfo item = ItemInfo.CreateFromTemplate(template, 1, 119); if (item != null) { if (player.RemoveGiftToken(NeedMoney) == NeedMoney) { item.IsBinds = true; result = true; player.HideBag.UpdateItem(Item); if (!player.AddItem(item)) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Game.Server.GameUtils.Title2", new object[0])); player.SendItemToMail(item, LanguageMgr.GetTranslation("DismountGemHandler.Full", new object[0]), item.Template.Name, eMailType.Default); player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver); } else { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("DismountGem.success", new object[0])); } } } } } if (!result) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("DismountGem.Fail", new object[0])); } result2 = 0; } } return(result2); }
private static bool AddFusionItemsToHideBag(GamePlayer player, ItemInfo item) { bool result; if (player.HideBag.IsEmpty(0)) { if (item.Count > 1) { ItemInfo copyitem = item.Clone(); copyitem.Count = 1; item.Count--; result = (player.HideBag.AddItemTo(copyitem, 0) && player.AddItem(item)); } else { result = player.HideBag.AddItemTo(item, 0); } } else { result = player.AddItem(item); } return(result); }
private static bool AddDailyAward(GamePlayer player, int getWay) { ItemInfo item = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(100 + player.VIPLevel), 1, 0); item.IsBinds = true; if (player.AddItem(item)) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("GameUserDailyAward.Success", new object[0])); } else { using (PlayerBussiness db = new PlayerBussiness()) { item.UserID = 0; db.AddGoods(item); MailInfo message = new MailInfo(); message.Annex1 = item.ItemID.ToString(); message.Content = LanguageMgr.GetTranslation("AwardMgr.AddDailyAward.Content", new object[] { item.Template.Name }); message.Gold = 0; message.Money = 0; message.GiftToken = 0; message.Receiver = player.PlayerCharacter.NickName; message.ReceiverID = player.PlayerCharacter.ID; message.Sender = message.Receiver; message.SenderID = message.ReceiverID; message.Title = LanguageMgr.GetTranslation("AwardMgr.AddDailyAward.Title", new object[] { item.Template.Name }); message.Type = 15; db.SendMail(message); string full = LanguageMgr.GetTranslation("AwardMgr.AddDailyAward.Mail", new object[0]); player.Out.SendMessage(eMessageType.Normal, full); player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver); } } return(true); }
public bool GetAnnex(PlayerBussiness db, string value, GamePlayer player, ref string msg, ref eMessageType eMsg) { int gid = int.Parse(value); ItemInfo goods = db.GetUserItemSingle(gid); bool result; if (goods != null) { if (player.AddItem(goods)) { eMsg = eMessageType.Normal; result = true; return(result); } eMsg = eMessageType.ERROR; msg = LanguageMgr.GetTranslation(goods.GetBagName(), new object[0]) + LanguageMgr.GetTranslation("MailGetAttachHandler.NoPlace", new object[0]); } result = false; return(result); }
private void receiveResult(GamePlayer player, GSPacketIn packet) { int num = packet.ReadInt(); packet.ReadInt(); ThreadSafeRandom threadSafeRandom = new ThreadSafeRandom(); int num2; int num3; switch (num) { case 1: num2 = threadSafeRandom.Next(2, 13); num3 = DiceSystemMgr.MoneyXUDoi; break; case 2: num2 = threadSafeRandom.Next(4, 7); num3 = DiceSystemMgr.MoneyXULon; break; case 3: num2 = threadSafeRandom.Next(1, 4); num3 = DiceSystemMgr.MoneyXUNho; break; default: num2 = threadSafeRandom.Next(1, 7); num3 = DiceSystemMgr.MoneyMacDinh; break; } GSPacketIn gSPacketIn = new GSPacketIn(134); gSPacketIn.WriteByte(4); gSPacketIn.WriteInt(player.DicePlace.CurrentPosition); gSPacketIn.WriteInt(num2); player.DicePlace.CurrentPosition += num2; if (player.DicePlace.CurrentPosition > 18) { player.DicePlace.CurrentPosition -= 18; } int num4 = threadSafeRandom.Next(6, 9); player.DicePlace.LuckIntegral += num4; if (player.DicePlace.LuckIntegral > 50 && player.DicePlace.LuckIntegralLevel == -1) { player.DicePlace.LuckIntegralLevel = 0; ItemInfo itemInfo = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(11036), 1, 116); ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(200549), 1, 116); itemInfo.Count = 1; itemInfo2.Count = 1; itemInfo.IsBinds = true; itemInfo2.IsBinds = true; player.AddItem(itemInfo); player.AddItem(itemInfo2); } if (player.DicePlace.LuckIntegral > 250 && player.DicePlace.LuckIntegralLevel == 0) { player.DicePlace.LuckIntegralLevel = 1; ItemInfo itemInfo3 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(40002), 1, 116); ItemInfo itemInfo4 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(200549), 1, 116); itemInfo3.Count = 1; itemInfo4.Count = 1; itemInfo3.IsBinds = true; itemInfo4.IsBinds = true; player.AddItem(itemInfo3); player.AddItem(itemInfo4); } gSPacketIn.WriteInt(player.DicePlace.LuckIntegral); gSPacketIn.WriteInt(player.DicePlace.LuckIntegralLevel); gSPacketIn.WriteInt(0); DiceSystemItem diceSystemItem = player.DicePlace.ItemDice[player.DicePlace.CurrentPosition]; ItemInfo itemInfo5 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(diceSystemItem.TemplateID), 1, 116); itemInfo5.IsBinds = diceSystemItem.IsBind; itemInfo5.StrengthenLevel = diceSystemItem.StrengthLevel; itemInfo5.Count = diceSystemItem.Count; itemInfo5.ValidDate = diceSystemItem.Validate; gSPacketIn.WriteString(string.Concat(new object[] { itemInfo5.Template.Name, " x ", itemInfo5.Count, "." })); if (player.RemoveMoney(num3) == num3) { player.AddItem(itemInfo5); } player.Out.SendTCP(gSPacketIn); }
private static bool AddStrengthItemsToHideBag(GamePlayer player, ItemInfo item) { int place = -1; int templateID = item.TemplateID; switch (templateID) { case 11018: place = 4; break; case 11019: break; case 11020: place = 3; break; default: if (templateID == 11023) { for (int i = 0; i < 3; i++) { if (player.HideBag.IsEmpty(i) && item.Count >= 1) { ItemInfo copyitem = item.Clone(); copyitem.Count = 1; player.HideBag.AddItemTo(copyitem, i); item.Count--; } } place = -1; } break; } bool result; if (item.Count <= 0) { result = true; } else { if (place != -1 && player.HideBag.IsEmpty(place)) { if (item.Count > 1) { ItemInfo copyitem = item.Clone(); copyitem.Count = 1; item.Count--; result = (player.HideBag.AddItemTo(copyitem, place) && player.AddItem(item)); } else { result = player.HideBag.AddItemTo(item, place); } } else { result = player.AddItem(item); } } return(result); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int totalGold = 0; int totalMoney = 0; int totalOffer = 0; int totalGifttoken = 0; int buyItemCount = 0; eMessageType eMsg = eMessageType.Normal; string msg = "UserBuyItemHandler.Success"; GSPacketIn pkg = new GSPacketIn(44); List <ItemInfo> buyItems = new List <ItemInfo>(); List <ItemInfo> canNotBuyItems = new List <ItemInfo>(); List <int> needitemsinfo = new List <int>(); Dictionary <int, int> changeLimitShopsID = new Dictionary <int, int>(); List <bool> dresses = new List <bool>(); List <int> places = new List <int>(); List <ItemJoinShopInfo> log = new List <ItemJoinShopInfo>(); Dictionary <int, int> playerPayGoods = new Dictionary <int, int>(); int result2; if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); result2 = 1; } else { ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID); int count = packet.ReadInt(); for (int i = 0; i < count; i++) { int goodsId = packet.ReadInt(); int type = packet.ReadInt(); string color = packet.ReadString(); bool isDress = packet.ReadBoolean(); string skin = packet.ReadString(); int place = packet.ReadInt(); bool isBind = false; int gold = 0; int money = 0; int offer = 0; int gifttoken = 0; ShopItemInfo shopItem = ShopMgr.GetShopItemInfoById(goodsId); if (shopItem != null && shopItem.ShopID != 21 && shopItem.ShopID != 22) { if (shopItem.ShopID == 2 || !ShopMgr.CanBuy(shopItem.ShopID, (consotia == null) ? 1 : consotia.ShopLevel, ref isBind, player.PlayerCharacter.ConsortiaID, player.PlayerCharacter.Riches)) { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailbyPermission", new object[0])); result2 = 1; return(result2); } List <int> needsItems = ShopMgr.GetShopItemBuyConditions(shopItem, type, ref gold, ref money, ref offer, ref gifttoken); for (int j = 0; j < needsItems.Count; j += 2) { if (!playerPayGoods.ContainsKey(needsItems[j])) { playerPayGoods.Add(needsItems[j], player.GetItemCount(needsItems[j])); } } bool result = true; string needsItemsLog = ""; for (int j = 0; j < needsItems.Count; j += 2) { if (playerPayGoods.ContainsKey(needsItems[j]) && playerPayGoods[needsItems[j]] >= needsItems[j + 1]) { foreach (int a in needsItems) { needitemsinfo.Add(a); } string text = needsItemsLog; needsItemsLog = string.Concat(new string[] { text, needsItems[j].ToString(), ":", needsItems[j + 1].ToString(), "|" }); Dictionary <int, int> dictionary; int key; (dictionary = playerPayGoods)[key = needsItems[j]] = dictionary[key] - needsItems[j + 1]; } else { result = false; } } ItemInfo item = ShopMgr.CreateItem(shopItem, 102, type, color, skin, isBind); int limitCount = ShopMgr.GetLimitCountByID(goodsId); if (limitCount == -1 || limitCount > 0) { if (result && player.PlayerCharacter.Gold >= gold + totalGold && player.PlayerCharacter.Money >= money + totalMoney && player.PlayerCharacter.Offer >= offer + totalOffer && player.PlayerCharacter.GiftToken >= gifttoken + totalGifttoken) { totalGold += gold; totalMoney += money; totalOffer += offer; totalGifttoken += gifttoken; buyItemCount++; buyItems.Add(item); dresses.Add(isDress); places.Add(place); if (limitCount != -1) { ShopMgr.SubtractShopLimit(goodsId); this.Notice(player, goodsId, item.Template.Name); if (!changeLimitShopsID.ContainsKey(goodsId)) { changeLimitShopsID.Add(goodsId, ShopMgr.GetLimitCountByID(goodsId)); } else { changeLimitShopsID[goodsId] = ShopMgr.GetLimitCountByID(goodsId); } } log.Add(new ItemJoinShopInfo(item.TemplateID, item.Count, money, gold, gifttoken, offer, needsItemsLog)); } else { canNotBuyItems.Add(item); } } } } if (buyItems.Count == 0) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserBuyItemHandler.Failed", new object[0])); result2 = 1; } else { int buyFrom = packet.ReadInt(); player.RemoveMoney(totalMoney, LogMoneyType.Shop, LogMoneyType.Shop_Buy); player.RemoveGold(totalGold); player.RemoveOffer(totalOffer); player.RemoveGiftToken(totalGifttoken); StringBuilder allPayItemsStr = new StringBuilder(); for (int j = 0; j < needitemsinfo.Count; j += 2) { player.RemoveTemplate(needitemsinfo[j], needitemsinfo[j + 1], eItemRemoveType.Shopping); allPayItemsStr.Append(needitemsinfo[j]).Append(","); } foreach (ItemJoinShopInfo templog in log) { //LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, player.PlayerCharacter.ID, templog.Moneys, templog.Gold, templog.GiftToken, templog.Offer, templog.OtherPay, templog.TemplateID, 4, templog.Data); } List <ItemInfo> lastItems = new List <ItemInfo>(); player.StackItem(ref buyItems); for (int i = 0; i < buyItems.Count; i++) { switch (buyFrom) { case 0: case 3: if (player.AddItem(buyItems[i])) { if (dresses[i]) { player.EquipItem(buyItems[i], places[i]); msg = "UserBuyItemHandler.Save"; } } else { lastItems.Add(buyItems[i]); } break; case 1: if (!UserBuyItemHandler.AddStrengthItemsToHideBag(player, buyItems[i])) { lastItems.Add(buyItems[i]); } break; case 2: if (!UserBuyItemHandler.AddComposeItemsToHideBag(player, buyItems[i])) { lastItems.Add(buyItems[i]); } break; case 4: if (!UserBuyItemHandler.AddFusionItemsToHideBag(player, buyItems[i])) { lastItems.Add(buyItems[i]); } break; } } bool sentMail = false; if (lastItems.Count > 0) { string title = ""; sentMail = player.SendItemsToMail(lastItems, "", title, eMailType.BuyItem); msg = "UserBuyItemHandler.Mail"; } if (canNotBuyItems.Count > 0) { string title = LanguageMgr.GetTranslation("UserBuyItemHandler.ListTitle", new object[0]); StringBuilder content = new StringBuilder(); if (buyItems.Count > 0) { content.Append(LanguageMgr.GetTranslation("UserBuyItemHandler.BuyList", new object[] { buyItems.Count })); for (int i = 0; i < buyItems.Count; i++) { content.Append(string.Format("{0}{1}", (i == 0) ? "" : ";", buyItems[i].Template.Name)); } } if (canNotBuyItems.Count > 0) { content.Append(LanguageMgr.GetTranslation("UserBuyItemHandler.NoBuyList", new object[] { "\n" })); for (int j = 0; j < canNotBuyItems.Count; j++) { content.Append(string.Format("{0}{1}", (j == 0) ? "" : ";", canNotBuyItems[j].Template.Name)); } } sentMail = player.SendMail(content.ToString(), title, null, eMailType.BuyItem); } if (sentMail) { player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver); } player.OnPaid(totalMoney, totalGold, totalOffer, totalGifttoken, allPayItemsStr.ToString()); int buyResult = 0; if (buyItemCount == count) { buyResult = (sentMail ? 2 : 1); } pkg.WriteInt(buyResult); pkg.WriteInt(buyFrom); player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0])); player.Out.SendTCP(pkg); player.SaveIntoDatabase(); this.UpdateLimitShopCount(player, changeLimitShopsID); result2 = 0; } } return(result2); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int bagType = (int)packet.ReadByte(); int place = packet.ReadInt(); PlayerInventory arkBag = player.GetInventory((eBageType)bagType); ItemInfo goods = arkBag.GetItemAt(place); string full = ""; List <ItemInfo> infos = new List <ItemInfo>(); int result; if (goods != null && goods.IsValidItem() && goods.Template.CategoryID == 11 && goods.Template.Property1 == 6 && player.PlayerCharacter.Grade >= goods.Template.NeedLevel) { int money = 0; int gold = 0; int giftToken = 0; int[] bags = new int[3]; int gp = 0; this.OpenUpItem(goods.Template.Data, bags, infos, ref gold, ref money, ref giftToken, ref gp); if (infos.Count == 0 && gold == 0 && money == 0 && giftToken == 0 && gp == 0) { result = 0; return(result); } bags[goods.GetBagType()]--; if (player.RemoveItem(goods, eItemRemoveType.Use)) { player.OnUsingItem(goods.Template.TemplateID); StringBuilder notice = new StringBuilder(); StringBuilder msg = new StringBuilder(); msg.Append(LanguageMgr.GetTranslation("OpenUpArkHandler.Start", new object[0])); if (money != 0) { msg.Append(money + LanguageMgr.GetTranslation("OpenUpArkHandler.Money", new object[0])); player.AddMoney(money, LogMoneyType.Box, LogMoneyType.Box_Open); } if (gold != 0) { msg.Append(gold + LanguageMgr.GetTranslation("OpenUpArkHandler.Gold", new object[0])); player.AddGold(gold); } if (giftToken != 0) { msg.Append(giftToken + LanguageMgr.GetTranslation("OpenUpArkHandler.GiftToken", new object[0])); player.AddGiftToken(giftToken); } if (gp != 0) { msg.Append(gp + LanguageMgr.GetTranslation("OpenUpArkHandler.Gp", new object[0])); player.AddGpDirect(gp); } StringBuilder msga = new StringBuilder(); foreach (ItemInfo info in infos) { msg.Append(info.Template.Name + "x" + info.Count.ToString() + ","); List <ItemInfo> list = ItemMgr.SpiltGoodsMaxCount(info); List <ItemInfo> last = new List <ItemInfo>(); foreach (ItemInfo it in list) { if (!player.AddItem(it)) { last.Add(it); } } if (last.Count > 0) { player.SendItemsToMail(last, LanguageMgr.GetTranslation("OpenUpArkHandler.Content1", new object[0]) + info.Template.Name + LanguageMgr.GetTranslation("OpenUpArkHandler.Content2", new object[0]), LanguageMgr.GetTranslation("OpenUpArkHandler.Title", new object[0]) + info.Template.Name + "]", eMailType.Common); full = LanguageMgr.GetTranslation("OpenUpArkHandler.Mail", new object[0]); } } foreach (ItemInfo info in infos) { player.SendItemNotice(info, goods.Template.Name, 3); } msg.Remove(msg.Length - 1, 1); msg.Append("."); player.Out.SendMessage(eMessageType.Normal, full + msg.ToString()); if (!string.IsNullOrEmpty(full)) { player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver); } } } result = 1; return(result); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int gold = 0; int money = 0; int offer = 0; int gifttoken = 0; int totalGold = 0; int totalMoney = 0; int totalOffer = 0; int totalGifttoken = 0; List <ItemJoinShopInfo> itemPrice = new List <ItemJoinShopInfo>(); int GroupID = packet.ReadInt(); eMessageType eMsg = eMessageType.Normal; string msg = "UserBuyItemHandler.Success"; List <ItemInfo> buyItems = new List <ItemInfo>(); int result; if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); result = 1; } else { List <ShopItemInfo> infos = ShopMgr.FindShopByGroupID(GroupID); foreach (ShopItemInfo info in infos) { ItemInfo item = ShopMgr.CreateItem(info, 102, 1, "", "", true); buyItems.Add(item); ShopMgr.GetShopItemBuyConditions(info, 1, ref gold, ref money, ref offer, ref gifttoken); itemPrice.Add(new ItemJoinShopInfo(info.TemplateID, item.Count, money, gold, gifttoken, offer, "")); totalGold += gold; totalMoney += money; totalOffer += offer; totalGifttoken += gifttoken; } if (buyItems.Count == 0) { result = 1; } else { if (totalGold <= player.PlayerCharacter.Gold && totalMoney <= player.PlayerCharacter.Money && totalOffer <= player.PlayerCharacter.Offer && totalGifttoken <= player.PlayerCharacter.GiftToken) { player.RemoveGold(totalGold); player.RemoveMoney(totalMoney, LogMoneyType.Shop, LogMoneyType.Shop_BuySale); player.RemoveOffer(totalOffer); player.RemoveGiftToken(totalGifttoken); foreach (ItemJoinShopInfo log in itemPrice) { //LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_BuySale, player.PlayerCharacter.ID, log.Moneys, log.Gold, log.GiftToken, log.Offer, log.OtherPay, log.TemplateID, 5, log.Data); } List <ItemInfo> remainitems = new List <ItemInfo>(); List <ItemInfo> sendMailItem = new List <ItemInfo>(); for (int i = 0; i < buyItems.Count; i++) { if (!player.HideBag.AddItemTo(buyItems[i], buyItems.Count - (i + 1))) { remainitems.Add(buyItems[i]); } } player.StackItem(ref remainitems); foreach (ItemInfo info2 in remainitems) { if (!player.AddItem(info2)) { sendMailItem.Add(info2); } } if (sendMailItem.Count > 0) { using (new PlayerBussiness()) { string title = ""; if (player.SendItemsToMail(sendMailItem, "", title, eMailType.BuyItem)) { player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver); } eMsg = eMessageType.ERROR; msg = "UserBuyItemHandler.Mail"; } } player.OnPaid(totalMoney, totalGold, totalOffer, totalGifttoken, ""); player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0])); player.SaveIntoDatabase(); result = 0; } else { if (money > player.PlayerCharacter.Money) { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.Money", new object[0])); } result = 1; } } } return(result); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { StringBuilder str = new StringBuilder(); int opertionType = (int)packet.ReadByte(); int count = 4; int MinValid = 2147483647; List <ItemInfo> items = new List <ItemInfo>(); List <ItemInfo> appendItems = new List <ItemInfo>(); List <eBageType> bagTypes = new List <eBageType>(); int result2; if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); result2 = 1; } else { GameServer.log.Debug("Fuck1"); for (int i = 1; i < 5; i++) { ItemInfo info = player.HideBag.GetItemAt(i); if (info != null) { if (items.Contains(info)) { player.Out.SendMessage(eMessageType.Normal, "Bad Input"); result2 = 1; return(result2); } if (!info.IsValidItem()) { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemFusionHandler.Itemvalid", new object[0])); result2 = 1; return(result2); } str.Append(string.Concat(new object[] { info.ItemID, ":", info.TemplateID, "," })); items.Add(info); if (info.ValidDate != 0) { if (!info.IsUsed) { if (info.ValidDate < MinValid) { MinValid = info.ValidDate; } } else { int spareDate = info.BeginDate.AddDays((double)info.ValidDate).Subtract(DateTime.Now).Days + 1; if (spareDate > info.ValidDate || spareDate <= 0) { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemFusionHandler.ItemValidDate", new object[0])); result2 = 1; return(result2); } if (spareDate < MinValid) { MinValid = spareDate; } } } } } if (MinValid == 2147483647) { MinValid = 0; } ItemInfo formul = player.HideBag.GetItemAt(0); ItemInfo tempitem = null; //string beginProperty = null; string AddItem = ""; //foreach (ItemInfo item in items) //{ // ItemInfo item; //ItemRecordBussiness.FusionItem(item, ref beginProperty); //} if (items.Count != 4 || formul == null) { GameServer.log.Debug("Fuck2"); result2 = 0; } else { GameServer.log.Debug("Fuck3"); int appendCount = 0; List <eBageType> bagTypesAppend = new List <eBageType>(); for (int i = 5; i < 11; i++) { ItemInfo info = player.HideBag.GetItemAt(i); if (info != null) { if (items.Contains(info) || appendItems.Contains(info)) { player.Out.SendMessage(eMessageType.Normal, "Bad Input"); result2 = 1; return(result2); } str.Append(string.Concat(new object[] { info.ItemID, ":", info.TemplateID, "," })); appendItems.Add(info); appendCount++; object obj = AddItem; AddItem = string.Concat(new object[] { obj, info.ItemID, ":", info.Template.Name, ",", info.IsBinds, "|" }); } } if (opertionType == 0) { GameServer.log.Debug("Fuck4"); bool isBind = false; Dictionary <int, double> previewItemList = FusionMgr.FusionPreview(items, appendItems, formul, ref isBind); if (previewItemList != null) { GameServer.log.Debug("OnSendFusionPreview"); if (previewItemList.Count != 0) { GameServer.log.Debug("Fuck5"); player.Out.SendFusionPreview(player, previewItemList, isBind, MinValid); } } else { GameServer.log.Debug("FusionPreview is Null"); } } else { GameServer.log.Debug("Fuck5"); int mustGold = (count + appendCount) * 400; if (player.PlayerCharacter.Gold < mustGold) { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemFusionHandler.NoMoney", new object[0])); result2 = 0; return(result2); } bool isBind = false; bool result = false; ItemTemplateInfo rewardItem = FusionMgr.Fusion(items, appendItems, formul, ref isBind, ref result); if (rewardItem != null) { if (rewardItem.IsOnly) { if (player.GetItemCount(rewardItem.TemplateID) >= 1) { player.Out.SendMessage(eMessageType.ERROR, "该物品为唯一物品,只能拥有一个"); return(0); } } player.BeginAllChanges(); player.RemoveGold(mustGold); for (int i = 0; i < items.Count; i++) { items[i].Count--; player.UpdateItem(items[i]); } formul.Count--; player.UpdateItem(formul); for (int i = 0; i < appendItems.Count; i++) { appendItems[i].Count--; player.UpdateItem(appendItems[i]); } if (result) { str.Append(rewardItem.TemplateID + ","); ItemInfo item = ItemInfo.CreateFromTemplate(rewardItem, 1, 105); if (item == null) { result2 = 0; return(result2); } tempitem = item; item.IsBinds = isBind; item.ValidDate = MinValid; player.OnItemFusion(item.Template.FusionType); player.Out.SendFusionResult(player, result); player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.Succeed1", new object[0]) + item.Template.Name); if (item.TemplateID >= 201 && item.TemplateID <= 221 || item.TemplateID >= 301 && item.TemplateID <= 310) { string msg = LanguageMgr.GetTranslation("ItemFusionHandler.Notice", new object[] { player.PlayerCharacter.NickName, "|" }); GSPacketIn sys_notice = WorldMgr.SendSysNotice(msg, item, player); GameServer.Instance.LoginServer.SendPacket(sys_notice); } PlayerInventory bag = player.GetItemInventory(item.Template); if (!bag.StackItemToAnother(item) && !player.AddItem(item)) { str.Append("NoPlace"); List <ItemInfo> its = new List <ItemInfo>(); its.Add(item); player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.full", new object[0])); player.SendItemsToMail(its, LanguageMgr.GetTranslation("ItemFusionHandler.mail", new object[0]), LanguageMgr.GetTranslation("ItemFusionHandler.mail", new object[0]), eMailType.ItemOverdue); player.Out.SendMailResponse(player.PlayerId, eMailRespose.Receiver); } } else { str.Append("false"); player.Out.SendFusionResult(player, result); player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.Failed", new object[0])); } //LogMgr.LogItemAdd(player.PlayerCharacter.ID, LogItemType.Fusion, beginProperty, tempitem, AddItem, Convert.ToInt32(result)); player.CommitAllChanges(); player.SaveIntoDatabase(); } else { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.NoCondition", new object[0])); } } result2 = 0; } } return(result2); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int operate = packet.ReadInt(); BoxInfo box = null; int result2; if (operate == 0) { int time = packet.ReadInt(); int onlineTime = (int)DateTime.Now.Subtract(player.BoxBeginTime).TotalMinutes; box = BoxMgr.FindTemplateByCondition(0, player.PlayerCharacter.Grade, player.PlayerCharacter.BoxProgression); if (box != null && onlineTime >= time && box.Condition == time) { using (ProduceBussiness db = new ProduceBussiness()) { db.UpdateBoxProgression(player.PlayerCharacter.ID, player.PlayerCharacter.BoxProgression, player.PlayerCharacter.GetBoxLevel, player.PlayerCharacter.AddGPLastDate, DateTime.Now, time); player.PlayerCharacter.AlreadyGetBox = time; player.PlayerCharacter.BoxGetDate = DateTime.Now; } } result2 = 0; } else { int type = packet.ReadInt(); GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); bool updatedb = false; bool result = true; if (type == 0) { int onlineTime = (int)DateTime.Now.Subtract(player.BoxBeginTime).TotalMinutes; box = BoxMgr.FindTemplateByCondition(0, player.PlayerCharacter.Grade, player.PlayerCharacter.BoxProgression); if (box != null && (onlineTime >= box.Condition || player.PlayerCharacter.AlreadyGetBox == box.Condition)) { using (ProduceBussiness db = new ProduceBussiness()) { if (db.UpdateBoxProgression(player.PlayerCharacter.ID, box.Condition, player.PlayerCharacter.GetBoxLevel, player.PlayerCharacter.AddGPLastDate, DateTime.Now.Date, 0)) { player.PlayerCharacter.BoxProgression = box.Condition; player.PlayerCharacter.BoxGetDate = DateTime.Now.Date; player.PlayerCharacter.AlreadyGetBox = 0; updatedb = true; } } } } else { box = BoxMgr.FindTemplateByCondition(1, player.PlayerCharacter.GetBoxLevel, Convert.ToInt32(player.PlayerCharacter.Sex)); if (box != null && player.PlayerCharacter.Grade >= box.Level) { using (ProduceBussiness db = new ProduceBussiness()) { if (db.UpdateBoxProgression(player.PlayerCharacter.ID, player.PlayerCharacter.BoxProgression, box.Level, player.PlayerCharacter.AddGPLastDate, player.PlayerCharacter.BoxGetDate, 0)) { player.PlayerCharacter.GetBoxLevel = box.Level; updatedb = true; } } } } if (updatedb) { if (box != null) { List <ItemInfo> mailList = new List <ItemInfo>(); List <ItemInfo> items = new List <ItemInfo>(); int gold = 0; int money = 0; int giftToken = 0; int gp = 0; ItemBoxMgr.CreateItemBox(Convert.ToInt32(box.Template), items, ref gold, ref money, ref giftToken, ref gp); if (gold > 0) { player.AddGold(gold); } if (money > 0) { player.AddMoney(money, LogMoneyType.Award, LogMoneyType.Award); } if (giftToken > 0) { player.AddGiftToken(giftToken); } if (gp > 0) { player.AddGP(gp); } foreach (ItemInfo item in items) { item.RemoveType = 120; if (!player.AddItem(item)) { mailList.Add(item); } } if (type == 0) { player.BoxBeginTime = DateTime.Now; box = BoxMgr.FindTemplateByCondition(0, player.PlayerCharacter.Grade, player.PlayerCharacter.BoxProgression); if (box != null) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.success", new object[] { box.Condition })); } else { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.todayOver", new object[0])); } } else { box = BoxMgr.FindTemplateByCondition(1, player.PlayerCharacter.GetBoxLevel, Convert.ToInt32(player.PlayerCharacter.Sex)); if (box != null) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.level", new object[] { box.Level })); } else { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.over", new object[0])); } } if (mailList.Count > 0) { if (player.SendItemsToMail(mailList, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.mail", new object[0]), LanguageMgr.GetTranslation("UserGetTimeBoxHandler.title", new object[0]), eMailType.OpenUpArk)) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBixHandler..full", new object[0])); result = true; player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver); } } } else { result = false; } } else { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.fail", new object[0])); } if (type == 0) { pkg.WriteBoolean(result); pkg.WriteInt(player.PlayerCharacter.BoxProgression); player.SendTCP(pkg); } result2 = 0; } return(result2); }