| 1 | import { itemDefinition } from "../definitions/items.js"; |
| 2 | |
| 3 | /** Whether this stack may be listed as a marketplace sell order. */ |
| 4 | export function canSellOnMarketplace (stack) |
| 5 | { |
| 6 | const def = itemDefinition(stack?.itemId); |
| 7 | if (!def || !stack) |
| 8 | { return false; } |
| 9 | return def.marketplaceSellable !== false; |
| 10 | } |
| 11 | |
| 12 | /** @throws {Error & { userFacing?: boolean }} */ |
| 13 | export function assertMarketplaceSellable (stack) |
| 14 | { |
| 15 | if (canSellOnMarketplace(stack)) |
| 16 | { return; } |
| 17 | const def = itemDefinition(stack?.itemId); |
| 18 | const error = new Error( |
| 19 | def?.marketplaceSellBlockedReason |
| 20 | ?? "That item cannot be sold on the marketplace." |
| 21 | ); |
| 22 | error.userFacing = true; |
| 23 | throw error; |
| 24 | } |