public static Packet Purchase(MeretMarketMetadata item, int itemIndex, int totalQuantity) { PacketWriter pWriter = PacketWriter.Of(SendOp.MERET_MARKET); pWriter.WriteEnum(MeretMarketMode.Purchase); pWriter.WriteByte((byte)totalQuantity); pWriter.WriteInt(item.MarketItemId); pWriter.WriteLong(); pWriter.WriteInt(1); pWriter.WriteInt(); pWriter.WriteLong(); pWriter.WriteInt(itemIndex); pWriter.WriteInt(totalQuantity); pWriter.WriteInt(); pWriter.WriteByte(); pWriter.WriteUnicodeString(""); pWriter.WriteUnicodeString(""); pWriter.WriteLong(item.SalePrice); pWriter.WriteByte(); pWriter.WriteByte(); pWriter.WriteInt(); pWriter.WriteInt(); pWriter.WriteInt(); pWriter.WriteInt(); return(pWriter); }
private static void HandlePurchase(GameSession session, PacketReader packet) { byte quantity = packet.ReadByte(); int marketItemId = packet.ReadInt(); byte[] unk = packet.Read(12); int childMarketItemId = packet.ReadInt(); long unk2 = packet.ReadLong(); int itemIndex = packet.ReadInt(); int totalQuantity = packet.ReadInt(); int unk3 = packet.ReadInt(); byte unk4 = packet.ReadByte(); string unk5 = packet.ReadUnicodeString(); string unk6 = packet.ReadUnicodeString(); long price = packet.ReadLong(); MeretMarketMetadata marketItem = MeretMarketMetadataStorage.GetMetadata(marketItemId); if (marketItem == null) { return; } if (childMarketItemId == 0) { HandleMarketItemPay(session, marketItem, itemIndex, totalQuantity); } else { MeretMarketMetadata childItem = marketItem.AdditionalQuantities.FirstOrDefault(x => x.MarketItemId == childMarketItemId); HandleMarketItemPay(session, childItem, itemIndex, totalQuantity); } }
private static void HandleMarketItemPay(GameSession session, MeretMarketMetadata marketItem, int itemIndex, int totalQuantity) { switch (marketItem.TokenType) { case MeretMarketCurrencyType.Meret: if (!session.Player.Wallet.RemoveMerets(marketItem.SalePrice)) { return; } break; case MeretMarketCurrencyType.Meso: if (!session.Player.Wallet.Meso.Modify(marketItem.SalePrice)) { return; } break; } Item item = new Item(marketItem.ItemId) { Amount = marketItem.Quantity + marketItem.BonusQuantity, Rarity = marketItem.Rarity }; if (marketItem.Duration != 0) { item.ExpiryTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + Environment.TickCount + (marketItem.Duration * (24 * 60 * 60)); } InventoryController.Add(session, item, true); session.Send(MeretMarketPacket.Purchase(marketItem, itemIndex, totalQuantity)); }
public static void WriteMeretMarketItem(PacketWriter pWriter, MeretMarketMetadata item) { pWriter.WriteInt(item.MarketItemId); pWriter.WriteByte(2); pWriter.WriteUnicodeString(item.ItemName); pWriter.WriteByte(1); pWriter.WriteInt(item.ParentMarketItemId); pWriter.WriteInt(254); pWriter.WriteInt(); // promo bool pWriter.WriteByte(2); pWriter.WriteEnum(item.Flag); pWriter.WriteEnum(item.TokenType); pWriter.WriteLong(item.Price); pWriter.WriteLong(item.SalePrice); pWriter.WriteByte(1); pWriter.WriteLong(item.SellBeginTime); pWriter.WriteLong(item.SellEndTime); pWriter.WriteEnum(item.JobRequirement); pWriter.WriteInt(3); pWriter.WriteBool(item.RestockUnavailable); pWriter.WriteInt(); pWriter.WriteByte(); pWriter.WriteShort(item.MinLevelRequirement); pWriter.WriteShort(item.MaxLevelRequirement); pWriter.WriteEnum(item.JobRequirement); pWriter.WriteInt(item.ItemId); pWriter.WriteByte(item.Rarity); pWriter.WriteInt(item.Quantity); pWriter.WriteInt(item.Duration); pWriter.WriteInt(item.BonusQuantity); pWriter.WriteInt(40300); pWriter.WriteInt(0); pWriter.WriteByte(0); pWriter.WriteEnum(item.PromoFlag); pWriter.WriteMapleString(item.PromoName); pWriter.WriteMapleString(""); pWriter.WriteByte(); pWriter.WriteByte(0); pWriter.WriteInt(0); pWriter.WriteByte(0); pWriter.WriteInt(item.RequiredAchievementId); pWriter.WriteInt(item.RequiredAchievementGrade); pWriter.WriteInt(0); pWriter.WriteBool(item.PCCafe); pWriter.WriteByte(0); pWriter.WriteInt(0); }