/** * This code was AUTOGENERATED using the Codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ import { combineCodec, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, } from '@solana/kit'; import { getCargoIdDecoder, getCargoIdEncoder, type CargoId, type CargoIdArgs, } from '.'; /** * A single registered offer in a pool's envelope: one item the NPC may sell and/or buy. * * `side_flags` is a bitmask (not an [`OrderSide`](crate::state::OrderSide) enum) so the entry stays * `Pod`/zero-copy, exactly like `ScanLootEntry`: `bit0` = NPC sells to the player (Ask), * `bit1` = NPC buys from the player (Bid — the faucet leg, gated by `EncounterPool::faucet_enabled`). */ export type PoolOfferEntry = { /** The item this offer concerns (same id space as the cargo/market system). */ cargoId: CargoId; /** Side bitmask: `SIDE_SELL` (NPC sells / Ask) and/or `SIDE_BUY` (NPC buys / Bid / faucet). */ sideFlags: number; /** * Predefined price band, Atlas (Floyds). The concrete price is drawn in `[min, max]` at reveal. * A truly fixed price is the degenerate band `min == max`. */ minPrice: bigint; maxPrice: bigint; /** * Per-spawn supply band (units). The concrete qty is drawn in `[min, max]`, then capped by the * treasury reserve and (at trade time) by the player's own fleet cargo. */ minQty: bigint; maxQty: bigint; /** * Threshold gate over the reveal draw value (same semantics as `ScanLootEntry.threshold`): * the offer is eligible only when `threshold < value`. Enables "rare within the rare event" items. */ threshold: number; /** Selection weight for the weighted draw (same domain as `ScanLootEntry.roll_weight`). */ rollWeight: number; }; export type PoolOfferEntryArgs = { /** The item this offer concerns (same id space as the cargo/market system). */ cargoId: CargoIdArgs; /** Side bitmask: `SIDE_SELL` (NPC sells / Ask) and/or `SIDE_BUY` (NPC buys / Bid / faucet). */ sideFlags: number; /** * Predefined price band, Atlas (Floyds). The concrete price is drawn in `[min, max]` at reveal. * A truly fixed price is the degenerate band `min == max`. */ minPrice: number | bigint; maxPrice: number | bigint; /** * Per-spawn supply band (units). The concrete qty is drawn in `[min, max]`, then capped by the * treasury reserve and (at trade time) by the player's own fleet cargo. */ minQty: number | bigint; maxQty: number | bigint; /** * Threshold gate over the reveal draw value (same semantics as `ScanLootEntry.threshold`): * the offer is eligible only when `threshold < value`. Enables "rare within the rare event" items. */ threshold: number; /** Selection weight for the weighted draw (same domain as `ScanLootEntry.roll_weight`). */ rollWeight: number; }; export function getPoolOfferEntryEncoder(): FixedSizeEncoder { return getStructEncoder([ ['cargoId', getCargoIdEncoder()], ['sideFlags', getU8Encoder()], ['minPrice', getU64Encoder()], ['maxPrice', getU64Encoder()], ['minQty', getU64Encoder()], ['maxQty', getU64Encoder()], ['threshold', getU32Encoder()], ['rollWeight', getU32Encoder()], ]); } export function getPoolOfferEntryDecoder(): FixedSizeDecoder { return getStructDecoder([ ['cargoId', getCargoIdDecoder()], ['sideFlags', getU8Decoder()], ['minPrice', getU64Decoder()], ['maxPrice', getU64Decoder()], ['minQty', getU64Decoder()], ['maxQty', getU64Decoder()], ['threshold', getU32Decoder()], ['rollWeight', getU32Decoder()], ]); } export function getPoolOfferEntryCodec(): FixedSizeCodec< PoolOfferEntryArgs, PoolOfferEntry > { return combineCodec(getPoolOfferEntryEncoder(), getPoolOfferEntryDecoder()); }