Пример #1
0
    private static void HandleListItem(GameSession session, PacketReader packet)
    {
        long          itemUid     = packet.ReadLong();
        long          salePrice   = packet.ReadLong();
        bool          promote     = packet.ReadBool();
        List <string> tags        = packet.ReadUnicodeString().Split(",").ToList();
        string        description = packet.ReadUnicodeString();
        long          listingFee  = packet.ReadLong();

        Item item = null;

        if (session.Player.Inventory.HasItem(itemUid))
        {
            item = session.Player.Inventory.GetByUid(itemUid);
        }
        else if (session.Player.Account.Home.WarehouseInventory.ContainsKey(itemUid))
        {
            item = session.Player.Account.Home.WarehouseInventory[itemUid];
        }

        if (item is null)
        {
            return;
        }

        if (item.Ugc is null || item.Ugc.CharacterId != session.Player.CharacterId || ItemMetadataStorage.GetLimitMetadata(item.Id).MeretMarketListable)
        {
            return;
        }

        if (salePrice < item.Ugc.SalePrice || salePrice > long.Parse(ConstantsMetadataStorage.GetConstant("UGCShopSellMaxPrice")))
        {
            return;
        }

        long totalFee = GetListingFee(session.Player.CharacterId, promote);

        if (!HandleMarketItemPay(session, totalFee, MeretMarketCurrencyType.Meret))
        {
            return;
        }

        UgcMarketItem marketItem = new(item, salePrice, session.Player, tags, description, promote);

        session.Send(MeretMarketPacket.ListItem(marketItem));
        session.Send(MeretMarketPacket.UpdateExpiration(marketItem));
    }
Пример #2
0
    private static void HandleListItem(GameSession session, PacketReader packet)
    {
        long          itemUid     = packet.ReadLong();
        long          salePrice   = packet.ReadLong();
        bool          promote     = packet.ReadBool();
        List <string> tags        = packet.ReadUnicodeString().Split(",").ToList();
        string        description = packet.ReadUnicodeString();
        long          listingFee  = packet.ReadLong();

        // TODO: Check if item is a ugc block and not an item. Find item from their block inventory
        if (!session.Player.Inventory.Items.ContainsKey(itemUid))
        {
            return;
        }

        Item item = session.Player.Inventory.Items[itemUid];

        if (item.UGC is null || item.UGC.CharacterId != session.Player.CharacterId)
        {
            return;
        }

        if (salePrice < item.UGC.SalePrice || salePrice > long.Parse(ConstantsMetadataStorage.GetConstant("UGCShopSellMaxPrice")))
        {
            return;
        }

        long totalFee = GetListingFee(session.Player.CharacterId, promote);

        if (!HandleMarketItemPay(session, totalFee, MeretMarketCurrencyType.Meret))
        {
            return;
        }

        UGCMarketItem marketItem = new(item, salePrice, session.Player, tags, description, promote);

        session.Send(MeretMarketPacket.ListItem(marketItem));
        session.Send(MeretMarketPacket.UpdateExpiration(marketItem));
    }