public void EquipBuffer() { this.m_player.EquipEffect.Clear(); for (int i = 0; i < 31; i++) { ItemInfo item = this.GetItemAt(i); if (item != null) { string[] hole = item.Template.Hole.Split(new char[] { '|' }); if (item.Hole1 > 0 && item.StrengthenLevel >= Convert.ToInt32(hole[0].Split(new char[] { ',' })[0])) { if (ItemMgr.FindItemTemplate(item.Hole1).Property2 != 3) { this.m_player.EquipEffect.Add(item.Hole1); } } if (item.Hole2 > 0 && item.StrengthenLevel >= Convert.ToInt32(hole[1].Split(new char[] { ',' })[0])) { if (ItemMgr.FindItemTemplate(item.Hole2).Property2 != 3) { this.m_player.EquipEffect.Add(item.Hole2); } } if (item.Hole3 > 0 && item.StrengthenLevel >= Convert.ToInt32(hole[2].Split(new char[] { ',' })[0])) { if (ItemMgr.FindItemTemplate(item.Hole3).Property2 != 3) { this.m_player.EquipEffect.Add(item.Hole3); } } if (item.Hole4 > 0 && item.StrengthenLevel >= Convert.ToInt32(hole[3].Split(new char[] { ',' })[0])) { if (ItemMgr.FindItemTemplate(item.Hole4).Property2 != 3) { this.m_player.EquipEffect.Add(item.Hole4); } } if (item.Hole5 > 0 && item.StrengthenLevel >= Convert.ToInt32(hole[4].Split(new char[] { ',' })[0])) { if (ItemMgr.FindItemTemplate(item.Hole5).Property2 != 3) { this.m_player.EquipEffect.Add(item.Hole5); } } if (item.Hole6 > 0 && item.StrengthenLevel >= Convert.ToInt32(hole[5].Split(new char[] { ',' })[0])) { if (ItemMgr.FindItemTemplate(item.Hole6).Property2 != 3) { this.m_player.EquipEffect.Add(item.Hole6); } } } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { int bagType = packet.ReadInt(); int num = packet.ReadInt(); string translateId = null; List <ShopItemInfo> list = new List <ShopItemInfo>(); if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(0); } ItemInfo itemInfo; if (num == -1) { int num2 = packet.ReadInt(); int num3 = packet.ReadInt(); int num4 = 0; int num5 = 0; ItemTemplateInfo goods = ItemMgr.FindItemTemplate(num2); itemInfo = ItemInfo.CreateFromTemplate(goods, 1, 102); list = ShopMgr.FindShopbyTemplatID(num2); for (int i = 0; i < list.Count; i++) { if (list[i].APrice1 == -1 && list[i].AValue1 != 0) { num5 = list[i].AValue1; itemInfo.ValidDate = list[i].AUnit; } } if (itemInfo != null) { if (num4 <= client.Player.PlayerCharacter.Gold && num5 <= client.Player.PlayerCharacter.Money) { client.Player.RemoveMoney(num5); client.Player.RemoveGold(num4); LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Card, client.Player.PlayerCharacter.ID, num5, client.Player.PlayerCharacter.Money, num4, 0, 0, 0, "牌子编号", itemInfo.TemplateID.ToString(), num3.ToString()); translateId = "CardUseHandler.Success"; } else { itemInfo = null; } } } else { itemInfo = client.Player.PropBag.GetItemAt(num); translateId = "CardUseHandler.Success"; } if (itemInfo != null) { string translateId2 = string.Empty; if (itemInfo.Template.Property1 != 21) { AbstractBuffer abstractBuffer = BufferList.CreateBuffer(itemInfo.Template, itemInfo.ValidDate); if (abstractBuffer != null) { abstractBuffer.Start(client.Player); if (num != -1) { client.Player.PropBag.RemoveCountFromStack(itemInfo, 1); } } client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(translateId, new object[0])); } else { if (itemInfo.IsValidItem()) { client.Player.PlayerCharacter.GP += client.Player.AddGP(itemInfo.Template.Property2 * itemInfo.Count);//fix add nuoc kinh nghiem if (itemInfo.Template.CanDelete) { client.Player.RemoveAt((eBageType)bagType, num); translateId2 = "GPDanUser.Success"; } } client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(translateId2, new object[] { itemInfo.Template.Property2 *itemInfo.Count })); } } 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); }
private static bool GetDropItems(eDropType type, int dropId, ref List <ItemInfo> itemInfos) { bool result; if (dropId == 0) { result = false; } else { try { int dropItemCount = 1; List <DropItem> unFiltItems = DropMgr.FindDropItem(dropId); int maxRound = DropInventory.random.Next(( from s in unFiltItems select s.Random).Max()); List <DropItem> filtItems = ( from s in unFiltItems where s.Random >= maxRound select s).ToList <DropItem>(); int maxItems = filtItems.Count <DropItem>(); if (maxItems == 0) { result = false; return(result); } dropItemCount = ((dropItemCount > maxItems) ? maxItems : dropItemCount); int[] randomArray = DropInventory.GetRandomUnrepeatArray(0, maxItems - 1, dropItemCount); int[] array = randomArray; for (int j = 0; j < array.Length; j++) { int i = array[j]; int itemCount = DropInventory.random.Next(filtItems[i].BeginData, filtItems[i].EndData); ItemTemplateInfo temp = ItemMgr.FindItemTemplate(filtItems[i].ItemId); ItemInfo item = ItemInfo.CreateFromTemplate(temp, itemCount, 101); if (item != null) { item.IsBinds = filtItems[i].IsBind; item.ValidDate = filtItems[i].ValueDate; item.IsTips = filtItems[i].IsTips; item.IsLogs = filtItems[i].IsLogs; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } switch (type) { case eDropType.Cards: case eDropType.Box: case eDropType.NPC: case eDropType.Boss: case eDropType.Special: if (DropInfoMgr.CanDrop(temp.TemplateID)) { itemInfos.Add(item); } break; default: itemInfos.Add(item); break; } } } if (itemInfos != null && itemInfos.Count > 0) { result = true; return(result); } } catch (Exception ex) { //if (DropInventory.log.IsErrorEnabled) { DropInventory.log.Error(string.Concat(new object[] { "Drop Error:", type, " @ ", ex })); } } result = false; } return(result); }
public void HandleGameRoomCreate(GSPacketIn pkg) { int roomId = pkg.ReadInt(); int gameType = pkg.ReadInt(); int guildId = pkg.ReadInt(); int count = pkg.ReadInt(); int totalLevel = 0; IGamePlayer[] players = new IGamePlayer[count]; for (int i = 0; i < count; i++) { PlayerInfo info = new PlayerInfo(); info.ID = pkg.ReadInt(); info.NickName = pkg.ReadString(); info.Sex = pkg.ReadBoolean(); info.Hide = pkg.ReadInt(); info.Style = pkg.ReadString(); info.Colors = pkg.ReadString(); info.Skin = pkg.ReadString(); info.Offer = pkg.ReadInt(); info.GP = pkg.ReadInt(); info.Grade = pkg.ReadInt(); info.Repute = pkg.ReadInt(); info.ConsortiaID = pkg.ReadInt(); info.ConsortiaName = pkg.ReadString(); info.ConsortiaLevel = pkg.ReadInt(); info.ConsortiaRepute = pkg.ReadInt(); info.Attack = pkg.ReadInt(); info.Defence = pkg.ReadInt(); info.Agility = pkg.ReadInt(); info.Luck = pkg.ReadInt(); double baseAttack = pkg.ReadDouble(); double baseDefence = pkg.ReadDouble(); double baseAgility = pkg.ReadDouble(); double baseBlood = pkg.ReadDouble(); int templateId = pkg.ReadInt(); bool canUserProp = pkg.ReadBoolean(); int secondWeapon = pkg.ReadInt(); int strengthLevel = pkg.ReadInt(); double gprate = pkg.ReadDouble(); double offerrate = pkg.ReadDouble(); double rate = pkg.ReadDouble(); int serverid = pkg.ReadInt(); ItemTemplateInfo itemTemplate = ItemMgr.FindItemTemplate(templateId); ItemInfo item = null; if (secondWeapon != 0) { ItemTemplateInfo secondWeaponTemp = ItemMgr.FindItemTemplate(secondWeapon); item = ItemInfo.CreateFromTemplate(secondWeaponTemp, 1, 1); item.StrengthenLevel = strengthLevel; } List <BufferInfo> infos = new List <BufferInfo>(); int buffercout = pkg.ReadInt(); for (int j = 0; j < buffercout; j++) { BufferInfo buffinfo = new BufferInfo(); buffinfo.Type = pkg.ReadInt(); buffinfo.IsExist = pkg.ReadBoolean(); buffinfo.BeginDate = pkg.ReadDateTime(); buffinfo.ValidDate = pkg.ReadInt(); buffinfo.Value = pkg.ReadInt(); if (info != null) { infos.Add(buffinfo); } } players[i] = new ProxyPlayer(this, info, itemTemplate, item, baseAttack, baseDefence, baseAgility, baseBlood, gprate, offerrate, rate, infos, serverid); players[i].CanUseProp = canUserProp; int ec = pkg.ReadInt(); for (int j = 0; j < ec; j++) { players[i].EquipEffect.Add(pkg.ReadInt()); } totalLevel += info.Grade; } ProxyRoom room = new ProxyRoom(ProxyRoomMgr.NextRoomId(), roomId, players, this); room.GuildId = guildId; room.GameType = (eGameType)gameType; lock (m_rooms) { if (!m_rooms.ContainsKey(roomId)) { m_rooms.Add(roomId, room); } else { room = null; } } if (room != null) { ProxyRoomMgr.AddRoom(room); } else { log.ErrorFormat("Room already exists:{0}", roomId); } }
public bool HandleCommand(TankMarryLogicProcessor process, GamePlayer player, GSPacketIn packet) { if (player.CurrentMarryRoom != null /* && player.CurrentMarryRoom.RoomState == eRoomState.FREE*/) { int userID = packet.ReadInt(); int templateID = packet.ReadInt(); ItemTemplateInfo template = ItemMgr.FindItemTemplate(templateID); if (template != null) { if (player.CurrentMarryRoom.Info.IsGunsaluteUsed == false && (player.CurrentMarryRoom.Info.GroomID == player.PlayerCharacter.ID || player.CurrentMarryRoom.Info.BrideID == player.PlayerCharacter.ID)) { player.CurrentMarryRoom.ReturnPacketForScene(player, packet); player.CurrentMarryRoom.Info.IsGunsaluteUsed = true; GSPacketIn msg = player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("GunsaluteCommand.Successed1", player.PlayerCharacter.NickName)); player.CurrentMarryRoom.SendToPlayerExceptSelfForScene(msg, player); GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(player.CurrentMarryRoom.Info.GroomID, true, player.CurrentMarryRoom.Info); GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(player.CurrentMarryRoom.Info.BrideID, true, player.CurrentMarryRoom.Info); using (PlayerBussiness db = new PlayerBussiness()) { db.UpdateMarryRoomInfo(player.CurrentMarryRoom.Info); } return(true); } //未开始 //if(template.PayType == 0) //{ // if(player.PlayerCharacter.Gold >= template.Price1) // { // player.RemoveGold(template.Price1, GoldRemoveType.Firecrackers); // CountBussiness.InsertSystemPayCount(player.PlayerCharacter.ID, 0, template.Price1, (int)eConsumerType.Marry, (int)eSubConsumerType.Marry_Gunsalute); // //0 player.CurrentMarryRoom.ReturnPacket(player, packet); // player.CurrentMarryRoom.ReturnPacketForScene(player, packet); // GSPacketIn msg = player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("GunsaluteCommand.Successed1", player.PlayerCharacter.NickName)); // player.CurrentMarryRoom.SendToPlayerExceptSelfForScene(msg, player); // return true; // } // else // { // player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("GunsaluteCommand.GoldNotEnough")); // } //} //else //{ // if(player.PlayerCharacter.Money >= template.Price1) // { // player.RemoveMoney(template.Price1, MoneyRemoveType.Firecrackers); // CountBussiness.InsertSystemPayCount(player.PlayerCharacter.ID, template.Price1, 0, (int)eConsumerType.Marry, (int)eSubConsumerType.Marry_Gunsalute); // //0 player.CurrentMarryRoom.ReturnPacket(player, packet); // player.CurrentMarryRoom.ReturnPacketForScene(player, packet); // GSPacketIn msg = player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("GunsaluteCommand.Successed1", player.PlayerCharacter.NickName)); // player.CurrentMarryRoom.SendToPlayerExceptSelfForScene(msg, player); // return true; // } // else // { // player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("GunsaluteCommand.MoneyNotEnough")); // } //} } } return(false); }
public static ItemTemplateInfo Refinery(GamePlayer player, List <ItemInfo> Items, ItemInfo Item, bool Luck, int OpertionType, ref bool result, ref int defaultprobability, ref bool IsFormula) { ItemTemplateInfo TempItem = new ItemTemplateInfo(); ItemTemplateInfo result2; foreach (int i in RefineryMgr.m_Item_Refinery.Keys) { if (RefineryMgr.m_Item_Refinery[i].m_Equip.Contains(Item.TemplateID)) { IsFormula = true; int j = 0; List <int> Template = new List <int>(); foreach (ItemInfo info in Items) { if (info.TemplateID == RefineryMgr.m_Item_Refinery[i].Item1 && info.Count >= RefineryMgr.m_Item_Refinery[i].Item1Count && !Template.Contains(info.TemplateID)) { Template.Add(info.TemplateID); if (OpertionType != 0) { info.Count -= RefineryMgr.m_Item_Refinery[i].Item1Count; } j++; } if (info.TemplateID == RefineryMgr.m_Item_Refinery[i].Item2 && info.Count >= RefineryMgr.m_Item_Refinery[i].Item2Count && !Template.Contains(info.TemplateID)) { Template.Add(info.TemplateID); if (OpertionType != 0) { info.Count -= RefineryMgr.m_Item_Refinery[i].Item2Count; } j++; } if (info.TemplateID == RefineryMgr.m_Item_Refinery[i].Item3 && info.Count >= RefineryMgr.m_Item_Refinery[i].Item3Count && !Template.Contains(info.TemplateID)) { Template.Add(info.TemplateID); if (OpertionType != 0) { info.Count -= RefineryMgr.m_Item_Refinery[i].Item3Count; } j++; } } if (j == 3) { for (int k = 0; k < RefineryMgr.m_Item_Refinery[i].m_Reward.Count; k++) { if (Items[Items.Count - 1].TemplateID == RefineryMgr.m_Item_Refinery[i].m_Reward[k]) { if (Luck) { defaultprobability += 20; } if (OpertionType == 0) { int TempItemID = RefineryMgr.m_Item_Refinery[i].m_Reward[k + 1]; result2 = ItemMgr.FindItemTemplate(TempItemID); return(result2); } if (RefineryMgr.random.Next(100) < defaultprobability) { int TempItemID = RefineryMgr.m_Item_Refinery[i].m_Reward[k + 1]; result = true; result2 = ItemMgr.FindItemTemplate(TempItemID); return(result2); } } } } } else { IsFormula = false; } } result2 = null; return(result2); }
public bool HandleCommand(TankMarryLogicProcessor process, GamePlayer player, GSPacketIn packet) { bool result2; if (player.CurrentMarryRoom == null || player.CurrentMarryRoom.RoomState != eRoomState.FREE) { result2 = false; } else { if (player.PlayerCharacter.ID != player.CurrentMarryRoom.Info.GroomID && player.PlayerCharacter.ID != player.CurrentMarryRoom.Info.BrideID) { result2 = false; } else { int needMoney = 500; if (player.CurrentMarryRoom.Info.IsHymeneal) { if (player.PlayerCharacter.Money < needMoney) { player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0])); result2 = false; return(result2); } } GamePlayer Groom = player.CurrentMarryRoom.GetPlayerByUserID(player.CurrentMarryRoom.Info.GroomID); if (Groom == null) { player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("HymenealCommand.NoGroom", new object[0])); result2 = false; } else { GamePlayer Bride = player.CurrentMarryRoom.GetPlayerByUserID(player.CurrentMarryRoom.Info.BrideID); if (Bride == null) { player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("HymenealCommand.NoBride", new object[0])); result2 = false; } else { bool result = false; bool isFirst = false; GSPacketIn pkg = packet.Clone(); int hymenealState = packet.ReadInt(); if (1 == hymenealState) { player.CurrentMarryRoom.RoomState = eRoomState.FREE; } else { player.CurrentMarryRoom.RoomState = eRoomState.Hymeneal; player.CurrentMarryRoom.BeginTimerForHymeneal(170000); if (!player.PlayerCharacter.IsGotRing) { isFirst = true; ItemTemplateInfo ringTemplate = ItemMgr.FindItemTemplate(9022); ItemInfo ring = ItemInfo.CreateFromTemplate(ringTemplate, 1, 112); ring.IsBinds = true; using (PlayerBussiness pb = new PlayerBussiness()) { ring.UserID = 0; pb.AddGoods(ring); string content = LanguageMgr.GetTranslation("HymenealCommand.Content", new object[] { Bride.PlayerCharacter.NickName }); MailInfo mail = new MailInfo(); mail.Annex1 = ring.ItemID.ToString(); mail.Content = content; mail.Gold = 0; mail.IsExist = true; mail.Money = 0; mail.GiftToken = 0; mail.Receiver = Groom.PlayerCharacter.NickName; mail.ReceiverID = Groom.PlayerCharacter.ID; mail.Sender = LanguageMgr.GetTranslation("HymenealCommand.Sender", new object[0]); mail.SenderID = 0; mail.Title = LanguageMgr.GetTranslation("HymenealCommand.Title", new object[0]); mail.Type = 14; if (pb.SendMail(mail)) { result = true; } player.Out.SendMailResponse(mail.ReceiverID, eMailRespose.Receiver); } ItemInfo ring2 = ItemInfo.CreateFromTemplate(ringTemplate, 1, 112); ring2.IsBinds = true; using (PlayerBussiness pb = new PlayerBussiness()) { ring2.UserID = 0; pb.AddGoods(ring2); string content = LanguageMgr.GetTranslation("HymenealCommand.Content", new object[] { Groom.PlayerCharacter.NickName }); MailInfo mail = new MailInfo(); mail.Annex1 = ring2.ItemID.ToString(); mail.Content = content; mail.Gold = 0; mail.IsExist = true; mail.Money = 0; mail.GiftToken = 0; mail.Receiver = Bride.PlayerCharacter.NickName; mail.ReceiverID = Bride.PlayerCharacter.ID; mail.Sender = LanguageMgr.GetTranslation("HymenealCommand.Sender", new object[0]); mail.SenderID = 0; mail.Title = LanguageMgr.GetTranslation("HymenealCommand.Title", new object[0]); mail.Type = 14; if (pb.SendMail(mail)) { result = true; } player.Out.SendMailResponse(mail.ReceiverID, eMailRespose.Receiver); } player.CurrentMarryRoom.Info.IsHymeneal = true; using (PlayerBussiness db = new PlayerBussiness()) { db.UpdateMarryRoomInfo(player.CurrentMarryRoom.Info); db.UpdatePlayerGotRingProp(Groom.PlayerCharacter.ID, Bride.PlayerCharacter.ID); Groom.LoadMarryProp(); Bride.LoadMarryProp(); } } else { isFirst = false; result = true; } if (!isFirst) { player.RemoveMoney(needMoney, LogMoneyType.Marry, LogMoneyType.Marry_Hymeneal); CountBussiness.InsertSystemPayCount(player.PlayerCharacter.ID, needMoney, 0, 0, 1); } pkg.WriteInt(player.CurrentMarryRoom.Info.ID); pkg.WriteBoolean(result); player.CurrentMarryRoom.SendToAll(pkg); if (result) { string msg = LanguageMgr.GetTranslation("HymenealCommand.Succeed", new object[] { Groom.PlayerCharacter.NickName, Bride.PlayerCharacter.NickName }); GSPacketIn message = player.Out.SendMessage(eMessageType.ChatNormal, msg); player.CurrentMarryRoom.SendToPlayerExceptSelfForScene(message, player); } } result2 = true; } } } } return(result2); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int Lottery = client.Lottery; int[] numArray = listRandomitem[Lottery]; PlayerInventory caddyBag = client.Player.CaddyBag; PlayerInventory propBag = client.Player.PropBag; SqlDataProvider.Data.ItemInfo itemByTemplateID = propBag.GetItemByTemplateID(0, 11444); try { ThreadSafeRandom random = new ThreadSafeRandom(); int num2 = random.Next(100) * random.Next(100); int index = 0; string[] strArray = client.tempData.Split(new char[] { ',' }); List <int> list = new List <int>(); if (client.tempData != "start") { foreach (string str in strArray) { if (!string.IsNullOrEmpty(str)) { list.Add(int.Parse(str)); } } } IOrderedEnumerable <int> enumerable = from s in list orderby s select s; foreach (int num4 in RandomForGetItem) { if (num2 < (num4 * num4)) { foreach (int num5 in enumerable) { if (index == num5) { index++; } } break; } index++; } if (itemByTemplateID.Count > strArray.Length) { itemByTemplateID.Count -= strArray.Length; propBag.UpdateItem(itemByTemplateID); } else if (itemByTemplateID.Count == strArray.Length) { propBag.RemoveItem(itemByTemplateID); } if (client.tempData == "start") { client.tempData = index + ","; } else { client.tempData = client.tempData + index + ","; } if (index >= numArray.Length) { index = 0; } SqlDataProvider.Data.ItemInfo item = SqlDataProvider.Data.ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(numArray[index]), 1, 105); item.BeginDate = DateTime.Now; item.ValidDate = 7; item.RemoveDate = DateTime.Now.AddDays(7.0); caddyBag.AddItem(item); GSPacketIn pkg = new GSPacketIn(30, client.Player.PlayerId); pkg.WriteInt(numArray[index]); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteBoolean(false); pkg.WriteInt(7); pkg.WriteByte(1); client.SendTCP(pkg); } catch { Console.WriteLine("Error "); } return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { GSPacketIn pkg; int num2; int num3; var business = new Bussiness.ProduceBussiness(); if (client.Lottery != -1) { client.Out.SendMessage(eMessageType.Normal, "Rương đang hoạt động!"); return(1); } int num = new Random().Next(0, listRandomitem.Count - 1); client.Lottery = num; int num4 = packet.ReadByte(); int slot = packet.ReadInt(); int templateId = packet.ReadInt(); int money = 0; int gold = 0; int giftToken = 0; int medal = 0; PlayerInventory inventory = client.Player.GetInventory((eBageType)num4); PlayerInventory propBag = client.Player.PropBag; ItemInfo item = propBag.GetItemByTemplateID(0, 11456); //búa đập lu ItemInfo itemAt = inventory.GetItemAt(slot); List <ItemInfo> infos = new List <ItemInfo>(); if ((itemAt != null) && (itemAt.TemplateID == 112019)) { client.tempData = "start"; if (itemAt.Count > 1) { itemAt.Count--; propBag.UpdateItem(itemAt); } else { propBag.RemoveItem(itemAt); } pkg = new GSPacketIn((byte)ePackageType.LOTTERY_ALTERNATE_LIST, client.Player.PlayerId); foreach (int num10 in listRandomitem[num]) { pkg.WriteInt(num10); pkg.WriteBoolean(false); pkg.WriteByte(1); pkg.WriteByte(1); } client.Out.SendTCP(pkg); return(1); } if ((((templateId != 11252) && (templateId != 11257)) && ((templateId != 11258) && (templateId != 11259))) && (templateId != 11260)) { if (templateId != 112047 && templateId != 112100 && templateId != 112101) { int num12 = 0; List <int> list9 = new List <int>(); List <ItemInfo> list10 = new List <ItemInfo>(); foreach (int num10 in listTemplate) { int itemCount = propBag.GetItemCount(0, num10); if (itemCount != 0) { num12 += itemCount; list9.Add(num10); ItemTemplateInfo goods = ItemMgr.FindItemTemplate(num10); list10.Add(ItemInfo.CreateFromTemplate(goods, 1, 105)); } } if (list10.Count > 0) { int num14 = new Random().Next(0, list10.Count); ItemInfo info5 = list10[num14]; int[] bag = new int[3]; this.OpenUpItem(info5.Template.Data, bag, infos, ref gold, ref money, ref giftToken, ref medal); if (infos.Count > 0) { pkg = new GSPacketIn((byte)ePackageType.CADDY_GET_AWARDS, client.Player.PlayerId); pkg.WriteBoolean(true); num3 = 1; pkg.WriteInt(num3); for (num2 = 0; num2 < num3; num2++) { pkg.WriteString(infos[0].Template.Name); pkg.WriteInt(infos[0].TemplateID); pkg.WriteInt(4); pkg.WriteBoolean(false); } client.Out.SendTCP(pkg); inventory.AddItem(infos[0]); ItemInfo info6 = propBag.GetItemByTemplateID(0, info5.TemplateID); if (info6.Count > 0) { info6.Count--; propBag.UpdateItem(info6); } else { propBag.RemoveItem(info6); } } } client.Lottery = -1; return(1); } else { ItemInfo itemByTemplateID = propBag.GetItemByTemplateID(0, templateId); if ((itemByTemplateID != null) && (item != null)) { Console.WriteLine("User open ItemBoxID: " + itemByTemplateID.TemplateID); if (itemByTemplateID.Count > 1) { itemByTemplateID.Count--; propBag.UpdateItem(itemByTemplateID); } else { propBag.RemoveItem(itemByTemplateID); } if (item.Count > 4) { item.Count -= 4; propBag.UpdateItem(item); } else { propBag.RemoveItem(item); } ThreadSafeRandom random = new ThreadSafeRandom(); int num15 = random.Next(100) * random.Next(100); num2 = 0; foreach (int num16 in RandomForGetItem) { if (num15 < (num16 * num16)) { break; } num2++; } pkg = new GSPacketIn((byte)ePackageType.CADDY_GET_AWARDS, client.Player.PlayerId); pkg.WriteBoolean(true); ItemInfo info9 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(listItemRandomForBox[num2]), 1, 105); //ItemInfo info9 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(business.GetSingleItemsBox(itemByTemplateID.TemplateID)[num2].TemplateId), 1, 105); num3 = 1; pkg.WriteInt(num3); pkg.WriteString(client.Player.PlayerCharacter.NickName); //pkg.WriteInt(business.GetSingleItemsBox(itemByTemplateID.TemplateID)[num2].TemplateId); pkg.WriteInt(listItemRandomForBox[num2]); pkg.WriteInt(4); pkg.WriteBoolean(false); client.Out.SendTCP(pkg); info9.BeginDate = DateTime.Now; info9.ValidDate = 7; info9.RemoveDate = DateTime.Now.AddDays(7.0); inventory.AddItem(info9); } } } else { List <int> list2 = new List <int>(); switch (templateId) { case 11252: { List <int> list3 = new List <int> { 0x1fa8, 0x2bcc, 0x2edd, 0x2e7f, 0x1b6e, 0x2b1f, 0x2b21, 0x2b23, 0x2b25, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d, 0x2e7e, 0x2e7f, 0x2edd, 0x2e81 }; list2 = list3; break; } case 11257: { List <int> list4 = new List <int> { 0x1fa8, 0x1f44, 0x1f46, 0x1f4e, 0x1fa7, 0x1b6e, 0x2b21, 0x2b23, 0x2b25, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d, 0x2e7e, 0x2e7f, 0x2e80, 0x2e81 }; list2 = list4; break; } case 11258: { List <int> list5 = new List <int> { 0x2b10, 0x2b0f, 0x2b04, 0x2b00, 0x23f2, 0x2072, 0x2b21, 0x2b23, 0x23f2, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d, 0x23f3, 0x2e7f, 0x2e80, 0x2e81 }; list2 = list5; break; } case 11259: { List <int> list6 = new List <int> { 0x2b10, 0x2b0f, 0x1b6e, 0x1b5e, 0x23f2, 0x2072, 0x2b21, 0x2b23, 0x23f2, 0x2b27, 0x1b61, 0x36c2, 0x36c4, 0x1b67, 0x36c8, 0x2e7d, 0x23f3, 0x2e7f, 0x2e80, 0x2e81 }; list2 = list6; break; } case 11260: { List <int> list7 = new List <int> { 0x1fa8, 0x2bcc, 0x2e80, 0x2e7f, 0x2b1d, 0x2b1f, 0x2b21, 0x2b23, 0x2b25, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d, 0x2e7e, 0x2e7f, 0x2e80, 0x2e81 }; list2 = list7; break; } default: { List <int> list8 = new List <int> { 0x1b72, 0x20d2, 0x1b6e, 0x11261, 0x23f2, 0x1124d, 0x2b21, 0x2b23, 0x23f2, 0x2b27, 0x2b00, 0x36c2, 0x36c4, 0x1b67, 0x36c8, 0x2e7d, 0x23f3, 0x2e82, 0x334a, 0x334e }; list2 = list8; break; } } int num11 = new Random().Next(0, list2.Count - 1); ItemInfo info3 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(list2[num11]), 1, 105); pkg = new GSPacketIn((byte)ePackageType.CADDY_GET_AWARDS, client.Player.PlayerId); pkg.WriteBoolean(true); num3 = 1; pkg.WriteInt(num3); for (num2 = 0; num2 < num3; num2++) { pkg.WriteString(info3.Template.Name); pkg.WriteInt(info3.TemplateID); pkg.WriteInt(4); pkg.WriteBoolean(false); } client.Out.SendTCP(pkg); inventory.AddItem(info3); ItemInfo info4 = client.Player.PropBag.GetItemByTemplateID(0, templateId); if (info4.Count > 1) { info4.Count--; client.Player.PropBag.UpdateItem(info4); } else { client.Player.PropBag.RemoveItem(info4); } client.Lottery = -1; return(1); } client.Lottery = -1; return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { //return 1; var typeCard = packet.ReadInt(); var param1 = packet.ReadInt(); var param2 = 0; var cardBag = client.Player.CardBag; ItemInfo item = null; cardBag.BeginChanges(); switch (typeCard) { case 0: //move card param2 = packet.ReadInt(); if (param1 > 4) { if (cardBag.GetItemAt(param1) != null) { cardBag.MoveItem(param1, param2, cardBag.GetItemAt(param1).Count); } } else { item = cardBag.GetItemAt(param1); if (item == null) { return(1); } if (cardBag.GetItemByTemplateID(5, item.TemplateID) != null) { var itemUpdate = cardBag.GetItemByTemplateID(5, item.TemplateID); itemUpdate.Count++; cardBag.UpdateItem(itemUpdate); cardBag.RemoveItem(item); break; } else { cardBag.MoveItem(item.Place, cardBag.FindFirstEmptySlot(5), item.Count); } } break; case 1: //open vice card //mo phong an cho card break; case 2: //OpenCardBox param2 = packet.ReadInt(); item = client.Player.MainBag.GetItemAt(param1); client.Player.MainBag.RemoveItem(item); var cardTemplateID = item.Template.Property5; ItemMgr.FindItemTemplate(cardTemplateID); //neu co' roi` thi cong them vo if (cardBag.GetItemByTemplateID(5, cardTemplateID) != null) { var itemUpdate = cardBag.GetItemByTemplateID(5, cardTemplateID); itemUpdate.Count++; cardBag.UpdateItem(itemUpdate); break; } //neu chua co' var index = cardBag.FindFirstEmptySlot(5); cardBag.AddItemTo(ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(cardTemplateID), 1, (int)ItemAddType.Buy), index); break; case 3: //UpgradeCard item = cardBag.GetItemAt(param1); if (item != null && item.Count > 3) { item.Count -= 3; item.AgilityCompose += 250; if (item.AgilityCompose > 500 && item.AgilityCompose < 2000) { item.StrengthenLevel = 1; } else if (item.AgilityCompose > 2000 && item.AgilityCompose < 7000) { item.StrengthenLevel = 2; } else if (item.AgilityCompose > 7000 && item.AgilityCompose < 10000) { item.StrengthenLevel = 3; } cardBag.UpdateItem(item); } break; case 4: //CardSort case 5: //FirstGetCard break; default: break; } cardBag.CommitChanges(); // cardBag.SaveToDatabase(); //GSPacketIn pkg = new GSPacketIn((byte)ePackageType.CARDS_DATA); //pkg.WriteInt(client.Player.PlayerCharacter.ID); //var length = 17; //pkg.WriteInt(17); //for (int i = 0; i < length; i++) //{ // pkg.WriteInt(i); // if (cardBag.GetItemAt(i) != null) // { // pkg.WriteBoolean(true); // item = cardBag.GetItemAt(i); // //cardId // pkg.WriteInt(item.ItemID); // pkg.WriteInt(client.Player.PlayerCharacter.ID); // //count // pkg.WriteInt(item.Count); // //place // pkg.WriteInt(item.Place); // pkg.WriteInt(item.Template.TemplateID); // //_loc_9.Attack = _loc_2.readInt(); // // _loc_9.Defend = _loc_2.readInt(); // // _loc_9.Agility = _loc_2.readInt(); // // _loc_9.Lucy = _loc_2.readInt(); // // _loc_9.Damage = _loc_2.readInt(); // // _loc_9.Guard = _loc_2.readInt(); // // _loc_9.Level = _loc_2.readInt(); // // _loc_9.CardGP = _loc_2.readInt() // pkg.WriteInt(item.Attack); pkg.WriteInt(item.Defence); pkg.WriteInt(item.Agility); // pkg.WriteInt(item.Luck); pkg.WriteInt(item.AttackCompose); // pkg.WriteInt(i); pkg.WriteInt(3); pkg.WriteInt(3); // pkg.WriteBoolean(true); // } // else // { // pkg.WriteBoolean(false); // } //} //client.SendTCP(pkg); 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); }