using System.IO;
namespace Dalamud.Game.Network.Structures;
///
/// Represents market board purchase information. This message is sent from the
/// client when a purchase is made at a market board.
///
public class MarketBoardPurchaseHandler : IMarketBoardPurchaseHandler
{
private MarketBoardPurchaseHandler()
{
}
///
/// Gets the object ID of the retainer associated with the sale.
///
public ulong RetainerId { get; private set; }
///
/// Gets the object ID of the item listing.
///
public ulong ListingId { get; private set; }
///
/// Gets the item ID of the item that was purchased.
///
public uint CatalogId { get; private set; }
///
/// Gets the quantity of the item that was purchased.
///
public uint ItemQuantity { get; private set; }
///
/// Gets the unit price of the item.
///
public uint PricePerUnit { get; private set; }
///
/// Reads market board purchase information from the struct at the provided pointer.
///
/// A pointer to a struct containing market board purchase information from the client.
/// An object representing the data read.
public static unsafe MarketBoardPurchaseHandler Read(IntPtr dataPtr)
{
using var stream = new UnmanagedMemoryStream((byte*)dataPtr.ToPointer(), 1544);
using var reader = new BinaryReader(stream);
var output = new MarketBoardPurchaseHandler
{
RetainerId = reader.ReadUInt64(),
ListingId = reader.ReadUInt64(),
CatalogId = reader.ReadUInt32(),
ItemQuantity = reader.ReadUInt32(),
PricePerUnit = reader.ReadUInt32(),
};
return output;
}
}
///
/// An interface that represents market board purchase information. This message is sent from the
/// client when a purchase is made at a market board.
///
public interface IMarketBoardPurchaseHandler
{
///
/// Gets the object ID of the retainer associated with the sale.
///
ulong RetainerId { get; }
///
/// Gets the object ID of the item listing.
///
ulong ListingId { get; }
///
/// Gets the item ID of the item that was purchased.
///
uint CatalogId { get; }
///
/// Gets the quantity of the item that was purchased.
///
uint ItemQuantity { get; }
///
/// Gets the unit price of the item.
///
uint PricePerUnit { get; }
}