BlueGit

timfa questward

Expand CE listings for flowers, tipped arrows, and unstable draughts.

Flower colours and arrow elements get specific buy rows; unstable draughts share one surprise listing; dyed clothing stays unkeyed so colour is a buyer surprise.

timfa Tim Falken · pushed by timfa

Authored 2026-09-04 · 2 months ago

Hash
e97c61c6118c4e3db6d42486071c66df2da498b5
Parent
5a1d2bc9
3 files changed +373 −26
server/src/market/service.js +5 −7
@@ -29,6 +29,7 @@ import {
29 29 buildMarketCatalogEntries,
30 30 listingKeyFromOrder,
31 31 listingKeyFromStack,
32 marketBuyListingKeyError,
32 33 marketBuyRequiresListingKey,
33 34 marketOrderDisplayName,
34 35 marketOrdersCompatible,
@@ -313,13 +314,10 @@ export class MarketService
313 314 { throw userError("Coins cannot be ordered on the marketplace."); }
314 315 const normalizedListingKey = normalizeBuyListingKey(itemId, listingKey);
315 316 if (marketBuyRequiresListingKey(itemId) && !normalizedListingKey)
316 {
317 throw userError(
318 (itemId | 0) === ItemId.recipePaper
319 ? "Choose which recipe to buy."
320 : "Choose which potion to buy."
321 );
322 }
317 { throw userError(marketBuyListingKeyError(itemId)); }
318 const rawListingKey = String(listingKey ?? "").trim();
319 if (rawListingKey && !normalizedListingKey)
320 { throw userError("That listing is not available."); }
323 321 const escrow = maxPrice * qty;
324 322 const fee = marketOrderListingFee(maxPrice, qty);
325 323 const bag = this.#loadBag(characterId);
@@ -29,6 +29,7 @@ import {
29 buildMarketCatalogEntries,
29 buildMarketCatalogEntries,
30 listingKeyFromOrder,
30 listingKeyFromOrder,
31 listingKeyFromStack,
31 listingKeyFromStack,
32 marketBuyListingKeyError,
32 marketBuyRequiresListingKey,
33 marketBuyRequiresListingKey,
33 marketOrderDisplayName,
34 marketOrderDisplayName,
34 marketOrdersCompatible,
35 marketOrdersCompatible,
@@ -313,13 +314,10 @@ export class MarketService
313 { throw userError("Coins cannot be ordered on the marketplace."); }
314 { throw userError("Coins cannot be ordered on the marketplace."); }
314 const normalizedListingKey = normalizeBuyListingKey(itemId, listingKey);
315 const normalizedListingKey = normalizeBuyListingKey(itemId, listingKey);
315 if (marketBuyRequiresListingKey(itemId) && !normalizedListingKey)
316 if (marketBuyRequiresListingKey(itemId) && !normalizedListingKey)
316 {
317 { throw userError(marketBuyListingKeyError(itemId)); }
317 throw userError(
318 const rawListingKey = String(listingKey ?? "").trim();
318 (itemId | 0) === ItemId.recipePaper
319 if (rawListingKey && !normalizedListingKey)
319 ? "Choose which recipe to buy."
320 { throw userError("That listing is not available."); }
320 : "Choose which potion to buy."
321 );
322 }
323 const escrow = maxPrice * qty;
321 const escrow = maxPrice * qty;
324 const fee = marketOrderListingFee(maxPrice, qty);
322 const fee = marketOrderListingFee(maxPrice, qty);
325 const bag = this.#loadBag(characterId);
323 const bag = this.#loadBag(characterId);
server/tests/marketplace.test.js +140 −1
@@ -15,9 +15,17 @@ import {
15 15 marketOrdersCompatible,
16 16 recipeListingKey,
17 17 recipePaperDisplayName,
18 potionListingKey
18 potionListingKey,
19 flowerListingKey,
20 arrowListingKey,
21 UNSTABLE_POTION_LISTING_KEY,
22 listingKeyFromStack
19 23 } from "../../shared/market/listingKey.js";
20 24 import { alchemyPotionDefinition } from "../../shared/definitions/alchemy.js";
25 import { MagicElement } from "../../shared/definitions/attackTypes.js";
26 import { RangedItemId } from "../../shared/definitions/rangedItems.js";
27 import { ClothItemId } from "../../shared/definitions/clothItems.js";
28 import { FlowerColorId, flowerItemInstance } from "../../shared/definitions/dyes.js";
21 29 import { emptyEquipment, emptySlots, addCoinsToSlots, countCoinsInSlots } from "../../shared/items/inventory.js";
22 30 import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";
23 31 import { createEmptyChunkData, encodeChunkBlob } from "../src/world/chunkData.js";
@@ -276,6 +284,8 @@ test("market catalog lists each drinkable potion brew separately", () =>
276 284 assert.ok(potions.length > 1);
277 285 assert.ok(potions.some((entry) => entry.listingKey === potionListingKey("lesserHealthTonic")));
278 286 assert.ok(potions.some((entry) => entry.displayName === "Lesser health tonic"));
287 assert.ok(potions.some((entry) => entry.listingKey === UNSTABLE_POTION_LISTING_KEY));
288 assert.equal(potions.filter((entry) => entry.listingKey === UNSTABLE_POTION_LISTING_KEY).length, 1);
279 289 assert.equal(potions.some((entry) => !entry.listingKey), false);
280 290 assert.equal(potions.some((entry) => entry.displayName === "Potion"), false);
281 291 assert.equal(
@@ -285,6 +295,135 @@ test("market catalog lists each drinkable potion brew separately", () =>
285 295 );
286 296 });
287 297
298 test("market catalog expands flowers and tipped arrows", () =>
299 {
300 const catalog = buildMarketCatalogEntries({
301 lastSaleFor: () => null,
302 undiscountedMarketCoins: () => 4,
303 now: Date.now(),
304 lerpDurationMs: 0,
305 settings: {}
306 });
307 const flowers = catalog.filter((entry) => entry.itemId === ItemId.flower);
308 assert.ok(flowers.length >= 9);
309 assert.ok(flowers.every((entry) => entry.listingKey));
310 assert.ok(flowers.some((entry) => entry.listingKey === flowerListingKey(FlowerColorId.red)));
311 assert.ok(flowers.some((entry) => entry.displayName === "Red flower"));
312
313 const bronze = catalog.filter((entry) => entry.itemId === RangedItemId.bronzeArrow);
314 assert.ok(bronze.some((entry) => entry.listingKey == null && entry.displayName));
315 assert.ok(bronze.some((entry) => entry.listingKey === arrowListingKey(MagicElement.fire)));
316 assert.ok(bronze.some((entry) => /fire/i.test(entry.displayName)));
317 });
318
319 test("unstable and tipped-arrow stacks carry market listing keys", () =>
320 {
321 const unstable = {
322 itemId: ItemId.potion,
323 quantity: 1,
324 instance: potionItemInstance({
325 potionKey: "unstable:glow",
326 unstable: true,
327 displayName: "Unstable draught",
328 color: { r: 0.95, g: 0.9, b: 0.45 },
329 fillLevel: 3,
330 effectKey: "glow",
331 effect: { type: "glow", lightRadiusTiles: 2, durationMs: 10_000 }
332 })
333 };
334 assert.equal(listingKeyFromStack(unstable), UNSTABLE_POTION_LISTING_KEY);
335 assert.equal(
336 listingKeyFromStack({
337 itemId: RangedItemId.bronzeArrow,
338 quantity: 5,
339 instance: { kind: "tipped-arrow", element: MagicElement.fire }
340 }),
341 arrowListingKey(MagicElement.fire)
342 );
343 assert.equal(
344 listingKeyFromStack({
345 itemId: ItemId.flower,
346 quantity: 1,
347 instance: flowerItemInstance(FlowerColorId.blue)
348 }),
349 flowerListingKey(FlowerColorId.blue)
350 );
351 assert.equal(
352 listingKeyFromStack({
353 itemId: ClothItemId.cottonShirt,
354 quantity: 1,
355 instance: { kind: "clothing", dyeColor: { r: 0.2, g: 0.4, b: 0.8 } }
356 }),
357 null,
358 "dyed clothing stays unkeyed so buyers get a colour surprise"
359 );
360 });
361
362 test("unstable buy orders match any unstable sell effect", () =>
363 {
364 const buy = { itemId: ItemId.potion, listingKey: UNSTABLE_POTION_LISTING_KEY };
365 const glowSell = {
366 itemId: ItemId.potion,
367 listingKey: UNSTABLE_POTION_LISTING_KEY,
368 escrowStack: {
369 itemId: ItemId.potion,
370 quantity: 1,
371 instance: potionItemInstance({
372 potionKey: "unstable:glow",
373 unstable: true,
374 displayName: "Unstable draught",
375 fillLevel: 3,
376 effectKey: "glow"
377 })
378 }
379 };
380 const shrinkSell = {
381 itemId: ItemId.potion,
382 listingKey: UNSTABLE_POTION_LISTING_KEY,
383 escrowStack: {
384 itemId: ItemId.potion,
385 quantity: 1,
386 instance: potionItemInstance({
387 potionKey: "unstable:shrink",
388 unstable: true,
389 displayName: "Unstable draught",
390 fillLevel: 2,
391 effectKey: "shrink"
392 })
393 }
394 };
395 assert.equal(marketOrdersCompatible(buy, glowSell), true);
396 assert.equal(marketOrdersCompatible(buy, shrinkSell), true);
397 assert.equal(
398 marketOrdersCompatible(buy, {
399 itemId: ItemId.potion,
400 listingKey: potionListingKey("lesserHealthTonic")
401 }),
402 false
403 );
404 });
405
406 test("dyed clothing sell matches an undyed clothing buy (colour surprise)", () =>
407 {
408 const buy = { itemId: ClothItemId.cottonShirt, listingKey: null };
409 const dyedSell = {
410 itemId: ClothItemId.cottonShirt,
411 listingKey: null,
412 escrowStack: {
413 itemId: ClothItemId.cottonShirt,
414 quantity: 1,
415 instance: { kind: "clothing", dyeColor: { r: 0.9, g: 0.1, b: 0.2 } }
416 }
417 };
418 const plainSell = {
419 itemId: ClothItemId.cottonShirt,
420 listingKey: null,
421 escrowStack: { itemId: ClothItemId.cottonShirt, quantity: 1, instance: null }
422 };
423 assert.equal(marketOrdersCompatible(buy, dyedSell), true);
424 assert.equal(marketOrdersCompatible(buy, plainSell), true);
425 });
426
288 427 test("recipe paper sell listings carry listing keys", () =>
289 428 {
290 429 const stack = recipePaperStack("lesserHealthTonic");
@@ -15,9 +15,17 @@ import {
15 marketOrdersCompatible,
15 marketOrdersCompatible,
16 recipeListingKey,
16 recipeListingKey,
17 recipePaperDisplayName,
17 recipePaperDisplayName,
18 potionListingKey
18 potionListingKey,
19 flowerListingKey,
20 arrowListingKey,
21 UNSTABLE_POTION_LISTING_KEY,
22 listingKeyFromStack
19} from "../../shared/market/listingKey.js";
23} from "../../shared/market/listingKey.js";
20import { alchemyPotionDefinition } from "../../shared/definitions/alchemy.js";
24import { alchemyPotionDefinition } from "../../shared/definitions/alchemy.js";
25import { MagicElement } from "../../shared/definitions/attackTypes.js";
26import { RangedItemId } from "../../shared/definitions/rangedItems.js";
27import { ClothItemId } from "../../shared/definitions/clothItems.js";
28import { FlowerColorId, flowerItemInstance } from "../../shared/definitions/dyes.js";
21import { emptyEquipment, emptySlots, addCoinsToSlots, countCoinsInSlots } from "../../shared/items/inventory.js";
29import { emptyEquipment, emptySlots, addCoinsToSlots, countCoinsInSlots } from "../../shared/items/inventory.js";
22import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";
30import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";
23import { createEmptyChunkData, encodeChunkBlob } from "../src/world/chunkData.js";
31import { createEmptyChunkData, encodeChunkBlob } from "../src/world/chunkData.js";
@@ -276,6 +284,8 @@ test("market catalog lists each drinkable potion brew separately", () =>
276 assert.ok(potions.length > 1);
284 assert.ok(potions.length > 1);
277 assert.ok(potions.some((entry) => entry.listingKey === potionListingKey("lesserHealthTonic")));
285 assert.ok(potions.some((entry) => entry.listingKey === potionListingKey("lesserHealthTonic")));
278 assert.ok(potions.some((entry) => entry.displayName === "Lesser health tonic"));
286 assert.ok(potions.some((entry) => entry.displayName === "Lesser health tonic"));
287 assert.ok(potions.some((entry) => entry.listingKey === UNSTABLE_POTION_LISTING_KEY));
288 assert.equal(potions.filter((entry) => entry.listingKey === UNSTABLE_POTION_LISTING_KEY).length, 1);
279 assert.equal(potions.some((entry) => !entry.listingKey), false);
289 assert.equal(potions.some((entry) => !entry.listingKey), false);
280 assert.equal(potions.some((entry) => entry.displayName === "Potion"), false);
290 assert.equal(potions.some((entry) => entry.displayName === "Potion"), false);
281 assert.equal(
291 assert.equal(
@@ -285,6 +295,135 @@ test("market catalog lists each drinkable potion brew separately", () =>
285 );
295 );
286});
296});
287
297
298test("market catalog expands flowers and tipped arrows", () =>
299{
300 const catalog = buildMarketCatalogEntries({
301 lastSaleFor: () => null,
302 undiscountedMarketCoins: () => 4,
303 now: Date.now(),
304 lerpDurationMs: 0,
305 settings: {}
306 });
307 const flowers = catalog.filter((entry) => entry.itemId === ItemId.flower);
308 assert.ok(flowers.length >= 9);
309 assert.ok(flowers.every((entry) => entry.listingKey));
310 assert.ok(flowers.some((entry) => entry.listingKey === flowerListingKey(FlowerColorId.red)));
311 assert.ok(flowers.some((entry) => entry.displayName === "Red flower"));
312
313 const bronze = catalog.filter((entry) => entry.itemId === RangedItemId.bronzeArrow);
314 assert.ok(bronze.some((entry) => entry.listingKey == null && entry.displayName));
315 assert.ok(bronze.some((entry) => entry.listingKey === arrowListingKey(MagicElement.fire)));
316 assert.ok(bronze.some((entry) => /fire/i.test(entry.displayName)));
317});
318
319test("unstable and tipped-arrow stacks carry market listing keys", () =>
320{
321 const unstable = {
322 itemId: ItemId.potion,
323 quantity: 1,
324 instance: potionItemInstance({
325 potionKey: "unstable:glow",
326 unstable: true,
327 displayName: "Unstable draught",
328 color: { r: 0.95, g: 0.9, b: 0.45 },
329 fillLevel: 3,
330 effectKey: "glow",
331 effect: { type: "glow", lightRadiusTiles: 2, durationMs: 10_000 }
332 })
333 };
334 assert.equal(listingKeyFromStack(unstable), UNSTABLE_POTION_LISTING_KEY);
335 assert.equal(
336 listingKeyFromStack({
337 itemId: RangedItemId.bronzeArrow,
338 quantity: 5,
339 instance: { kind: "tipped-arrow", element: MagicElement.fire }
340 }),
341 arrowListingKey(MagicElement.fire)
342 );
343 assert.equal(
344 listingKeyFromStack({
345 itemId: ItemId.flower,
346 quantity: 1,
347 instance: flowerItemInstance(FlowerColorId.blue)
348 }),
349 flowerListingKey(FlowerColorId.blue)
350 );
351 assert.equal(
352 listingKeyFromStack({
353 itemId: ClothItemId.cottonShirt,
354 quantity: 1,
355 instance: { kind: "clothing", dyeColor: { r: 0.2, g: 0.4, b: 0.8 } }
356 }),
357 null,
358 "dyed clothing stays unkeyed so buyers get a colour surprise"
359 );
360});
361
362test("unstable buy orders match any unstable sell effect", () =>
363{
364 const buy = { itemId: ItemId.potion, listingKey: UNSTABLE_POTION_LISTING_KEY };
365 const glowSell = {
366 itemId: ItemId.potion,
367 listingKey: UNSTABLE_POTION_LISTING_KEY,
368 escrowStack: {
369 itemId: ItemId.potion,
370 quantity: 1,
371 instance: potionItemInstance({
372 potionKey: "unstable:glow",
373 unstable: true,
374 displayName: "Unstable draught",
375 fillLevel: 3,
376 effectKey: "glow"
377 })
378 }
379 };
380 const shrinkSell = {
381 itemId: ItemId.potion,
382 listingKey: UNSTABLE_POTION_LISTING_KEY,
383 escrowStack: {
384 itemId: ItemId.potion,
385 quantity: 1,
386 instance: potionItemInstance({
387 potionKey: "unstable:shrink",
388 unstable: true,
389 displayName: "Unstable draught",
390 fillLevel: 2,
391 effectKey: "shrink"
392 })
393 }
394 };
395 assert.equal(marketOrdersCompatible(buy, glowSell), true);
396 assert.equal(marketOrdersCompatible(buy, shrinkSell), true);
397 assert.equal(
398 marketOrdersCompatible(buy, {
399 itemId: ItemId.potion,
400 listingKey: potionListingKey("lesserHealthTonic")
401 }),
402 false
403 );
404});
405
406test("dyed clothing sell matches an undyed clothing buy (colour surprise)", () =>
407{
408 const buy = { itemId: ClothItemId.cottonShirt, listingKey: null };
409 const dyedSell = {
410 itemId: ClothItemId.cottonShirt,
411 listingKey: null,
412 escrowStack: {
413 itemId: ClothItemId.cottonShirt,
414 quantity: 1,
415 instance: { kind: "clothing", dyeColor: { r: 0.9, g: 0.1, b: 0.2 } }
416 }
417 };
418 const plainSell = {
419 itemId: ClothItemId.cottonShirt,
420 listingKey: null,
421 escrowStack: { itemId: ClothItemId.cottonShirt, quantity: 1, instance: null }
422 };
423 assert.equal(marketOrdersCompatible(buy, dyedSell), true);
424 assert.equal(marketOrdersCompatible(buy, plainSell), true);
425});
426
288test("recipe paper sell listings carry listing keys", () =>
427test("recipe paper sell listings carry listing keys", () =>
289{
428{
290 const stack = recipePaperStack("lesserHealthTonic");
429 const stack = recipePaperStack("lesserHealthTonic");
shared/market/listingKey.js +228 −18
@@ -1,9 +1,21 @@
1 import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "../definitions/items.js";
1 import { ItemId, itemDefinition, ITEM_DEFINITIONS, itemDisplayName } from "../definitions/items.js";
2 2 import { alchemyPotionDefinition, listAlchemyPotions } from "../definitions/alchemy.js";
3 import { MAGIC_ELEMENT_ORDER } from "../definitions/attackTypes.js";
4 import {
5 FLOWER_COLOR_ORDER,
6 FLOWER_COLOR_DISPLAY,
7 DyeItemId
8 } from "../definitions/dyes.js";
9 import { ItemFamilyId } from "../definitions/tierFamilies.js";
3 10 import { canSellOnMarketplace } from "../items/marketplace.js";
4 11
5 12 export const RECIPE_LISTING_PREFIX = "recipe:";
6 13 export const POTION_LISTING_PREFIX = "potion:";
14 export const FLOWER_LISTING_PREFIX = "flower:";
15 export const ARROW_LISTING_PREFIX = "arrow:";
16
17 /** Shared CE key for any full unstable draught (buyer gets a surprise effect). */
18 export const UNSTABLE_POTION_LISTING_KEY = `${POTION_LISTING_PREFIX}unstable`;
7 19
8 20 /** Stable CE sub-type key for a written recipe paper (`recipe:lesserHealthTonic`, …). */
9 21 export function recipeListingKey (potionKey)
@@ -23,6 +35,22 @@ export function potionListingKey (potionKey)
23 35 return `${POTION_LISTING_PREFIX}${key}`;
24 36 }
25 37
38 export function flowerListingKey (colorId)
39 {
40 const id = String(colorId ?? "").trim();
41 if (!FLOWER_COLOR_ORDER.includes(id))
42 { return null; }
43 return `${FLOWER_LISTING_PREFIX}${id}`;
44 }
45
46 export function arrowListingKey (element)
47 {
48 const el = String(element ?? "").trim();
49 if (!MAGIC_ELEMENT_ORDER.includes(el))
50 { return null; }
51 return `${ARROW_LISTING_PREFIX}${el}`;
52 }
53
26 54 /** Potion key from a `recipe:…` listing key (recipe papers). */
27 55 export function potionKeyFromListingKey (listingKey)
28 56 {
@@ -41,7 +69,35 @@ export function potionKeyFromPotionListingKey (listingKey)
41 69 return text.slice(POTION_LISTING_PREFIX.length) || null;
42 70 }
43 71
44 /** Drinkable alchemy brew suitable for CE / gifts (not solid outputs). */
72 export function flowerColorIdFromListingKey (listingKey)
73 {
74 const text = String(listingKey ?? "");
75 if (!text.startsWith(FLOWER_LISTING_PREFIX))
76 { return null; }
77 const colorId = text.slice(FLOWER_LISTING_PREFIX.length);
78 return FLOWER_COLOR_ORDER.includes(colorId) ? colorId : null;
79 }
80
81 export function arrowElementFromListingKey (listingKey)
82 {
83 const text = String(listingKey ?? "");
84 if (!text.startsWith(ARROW_LISTING_PREFIX))
85 { return null; }
86 const element = text.slice(ARROW_LISTING_PREFIX.length);
87 return MAGIC_ELEMENT_ORDER.includes(element) ? element : null;
88 }
89
90 export function isArrowItemId (itemId)
91 {
92 return itemDefinition(itemId)?.familyId === ItemFamilyId.arrow;
93 }
94
95 export function isFlowerItemId (itemId)
96 {
97 return (itemId | 0) === ItemId.flower || (itemId | 0) === DyeItemId.flower;
98 }
99
100 /** Drinkable alchemy brew suitable for CE / gifts (not solid outputs, not unstable). */
45 101 export function isMarketPotionBrew (potionKey)
46 102 {
47 103 const potion = alchemyPotionDefinition(potionKey);
@@ -51,6 +107,15 @@ export function isMarketPotionBrew (potionKey)
51 107 return !!key && !key.startsWith("unstable:");
52 108 }
53 109
110 export function isUnstablePotionStack (stack)
111 {
112 if ((stack?.itemId | 0) !== ItemId.potion || stack?.instance?.kind !== "potion")
113 { return false; }
114 if (stack.instance.unstable)
115 { return true; }
116 return String(stack.instance.potionKey ?? "").startsWith("unstable:");
117 }
118
54 119 /** Listing key carried on a bag stack (sell escrow) or null for normal goods. */
55 120 export function listingKeyFromStack (stack)
56 121 {
@@ -65,13 +130,22 @@ export function listingKeyFromStack (stack)
65 130 {
66 131 if (stack.instance?.kind !== "potion")
67 132 { return null; }
68 if (stack.instance.unstable)
69 { return null; }
133 if (isUnstablePotionStack(stack))
134 { return UNSTABLE_POTION_LISTING_KEY; }
70 135 const potionKey = String(stack.instance.potionKey ?? "").trim();
71 136 if (!isMarketPotionBrew(potionKey))
72 137 { return null; }
73 138 return potionListingKey(potionKey);
74 139 }
140 if (isFlowerItemId(itemId))
141 {
142 if (stack.instance?.kind !== "flower")
143 { return null; }
144 return flowerListingKey(stack.instance.colorId);
145 }
146 if (isArrowItemId(itemId) && stack.instance?.kind === "tipped-arrow")
147 { return arrowListingKey(stack.instance.element); }
148 // Dyeable clothing keeps listingKey null so dyed and undyed match (buyer colour surprise).
75 149 return null;
76 150 }
77 151
@@ -102,6 +176,21 @@ export function recipePaperDisplayName (potionKey)
102 176 return `${def.displayName} recipe`;
103 177 }
104 178
179 export function flowerListingDisplayName (colorId)
180 {
181 const label = FLOWER_COLOR_DISPLAY[colorId] ?? "Flower";
182 return `${label} flower`;
183 }
184
185 export function tippedArrowListingDisplayName (itemId, element)
186 {
187 return itemDisplayName({
188 itemId,
189 quantity: 1,
190 instance: { kind: "tipped-arrow", element }
191 });
192 }
193
105 194 /**
106 195 * Editor / gift picker rows: one entry per alchemy recipe (same as CE buy catalog).
107 196 * @returns {Array<{ itemId: number, listingKey: string, potionKey: string, displayName: string, key: string }>}
@@ -151,6 +240,17 @@ export function listPotionPickerEntries ()
151 240 return entries;
152 241 }
153 242
243 export function listFlowerPickerEntries ()
244 {
245 return FLOWER_COLOR_ORDER.map((colorId) => ({
246 itemId: ItemId.flower,
247 listingKey: flowerListingKey(colorId),
248 colorId,
249 displayName: flowerListingDisplayName(colorId),
250 key: `flower:${colorId}`
251 }));
252 }
253
154 254 export function marketOrderDisplayName (order)
155 255 {
156 256 const listingKey = listingKeyFromOrder(order);
@@ -158,6 +258,8 @@ export function marketOrderDisplayName (order)
158 258 {
159 259 return recipePaperDisplayName(potionKeyFromListingKey(listingKey));
160 260 }
261 if (listingKey === UNSTABLE_POTION_LISTING_KEY)
262 { return "Unstable draught"; }
161 263 if (listingKey?.startsWith(POTION_LISTING_PREFIX))
162 264 {
163 265 const potionKey = potionKeyFromPotionListingKey(listingKey);
@@ -165,6 +267,19 @@ export function marketOrderDisplayName (order)
165 267 ?? itemDefinition(ItemId.potion)?.displayName
166 268 ?? "Potion";
167 269 }
270 if (listingKey?.startsWith(FLOWER_LISTING_PREFIX))
271 {
272 const colorId = flowerColorIdFromListingKey(listingKey);
273 return colorId ? flowerListingDisplayName(colorId) : "Flower";
274 }
275 if (listingKey?.startsWith(ARROW_LISTING_PREFIX))
276 {
277 const element = arrowElementFromListingKey(listingKey);
278 if (element && order?.itemId)
279 { return tippedArrowListingDisplayName(order.itemId, element); }
280 }
281 if (order?.escrowStack)
282 { return itemDisplayName(order.escrowStack); }
168 283 return itemDefinition(order?.itemId)?.displayName ?? `Item ${order?.itemId ?? "?"}`;
169 284 }
170 285
@@ -172,6 +287,8 @@ export function normalizeBuyListingKey (itemId, listingKey)
172 287 {
173 288 const id = itemId | 0;
174 289 const key = String(listingKey ?? "").trim();
290 if (!key)
291 { return null; }
175 292 if (id === ItemId.recipePaper)
176 293 {
177 294 if (!key.startsWith(RECIPE_LISTING_PREFIX))
@@ -183,6 +300,8 @@ export function normalizeBuyListingKey (itemId, listingKey)
183 300 }
184 301 if (id === ItemId.potion)
185 302 {
303 if (key === UNSTABLE_POTION_LISTING_KEY)
304 { return UNSTABLE_POTION_LISTING_KEY; }
186 305 if (!key.startsWith(POTION_LISTING_PREFIX))
187 306 { return null; }
188 307 const potionKey = potionKeyFromPotionListingKey(key);
@@ -190,6 +309,16 @@ export function normalizeBuyListingKey (itemId, listingKey)
190 309 { return null; }
191 310 return key;
192 311 }
312 if (isFlowerItemId(id))
313 {
314 const colorId = flowerColorIdFromListingKey(key);
315 return colorId ? flowerListingKey(colorId) : null;
316 }
317 if (isArrowItemId(id))
318 {
319 const element = arrowElementFromListingKey(key);
320 return element ? arrowListingKey(element) : null;
321 }
193 322 return null;
194 323 }
195 324
@@ -197,10 +326,35 @@ export function normalizeBuyListingKey (itemId, listingKey)
197 326 export function marketBuyRequiresListingKey (itemId)
198 327 {
199 328 const id = itemId | 0;
200 return id === ItemId.recipePaper || id === ItemId.potion;
329 return id === ItemId.recipePaper
330 || id === ItemId.potion
331 || isFlowerItemId(id);
332 }
333
334 export function marketBuyListingKeyError (itemId)
335 {
336 const id = itemId | 0;
337 if (id === ItemId.recipePaper)
338 { return "Choose which recipe to buy."; }
339 if (id === ItemId.potion)
340 { return "Choose which potion to buy."; }
341 if (isFlowerItemId(id))
342 { return "Choose which flower colour to buy."; }
343 return "Choose a specific listing to buy.";
201 344 }
202 345
203 /** Buy-tab catalog rows (recipe papers / potions expand per known subtype). */
346 function catalogHint (itemId, lastSaleFor, undiscountedMarketCoins, now, lerpDurationMs, settings)
347 {
348 return undiscountedMarketCoins(
349 itemId,
350 lastSaleFor(itemId),
351 now,
352 lerpDurationMs,
353 settings
354 );
355 }
356
357 /** Buy-tab catalog rows (subtype expansions for recipes, potions, flowers, tipped arrows). */
204 358 export function buildMarketCatalogEntries ({
205 359 lastSaleFor,
206 360 undiscountedMarketCoins,
@@ -216,27 +370,55 @@ export function buildMarketCatalogEntries ({
216 370 { continue; }
217 371 if (def.itemId === ItemId.coins)
218 372 { continue; }
219 if (def.itemId === ItemId.recipePaper || def.itemId === ItemId.potion)
373 if (
374 def.itemId === ItemId.recipePaper
375 || def.itemId === ItemId.potion
376 || isFlowerItemId(def.itemId)
377 )
220 378 { continue; }
379
380 const hint = catalogHint(
381 def.itemId,
382 lastSaleFor,
383 undiscountedMarketCoins,
384 now,
385 lerpDurationMs,
386 settings
387 );
388 if (isArrowItemId(def.itemId))
389 {
390 catalog.push({
391 itemId: def.itemId,
392 listingKey: null,
393 displayName: def.displayName,
394 hintPrice: hint
395 });
396 for (const element of MAGIC_ELEMENT_ORDER)
397 {
398 catalog.push({
399 itemId: def.itemId,
400 listingKey: arrowListingKey(element),
401 displayName: tippedArrowListingDisplayName(def.itemId, element),
402 hintPrice: hint
403 });
404 }
405 continue;
406 }
407
221 408 catalog.push({
222 409 itemId: def.itemId,
223 410 listingKey: null,
224 411 displayName: def.displayName,
225 hintPrice: undiscountedMarketCoins(
226 def.itemId,
227 lastSaleFor(def.itemId),
228 now,
229 lerpDurationMs,
230 settings
231 )
412 hintPrice: hint
232 413 });
233 414 }
234 415 const recipeDef = ITEM_DEFINITIONS[ItemId.recipePaper];
235 416 if (recipeDef && canSellOnMarketplace({ itemId: ItemId.recipePaper, quantity: 1 }))
236 417 {
237 const recipeHint = undiscountedMarketCoins(
418 const recipeHint = catalogHint(
238 419 ItemId.recipePaper,
239 lastSaleFor(ItemId.recipePaper),
420 lastSaleFor,
421 undiscountedMarketCoins,
240 422 now,
241 423 lerpDurationMs,
242 424 settings
@@ -257,9 +439,10 @@ export function buildMarketCatalogEntries ({
257 439 const potionDef = ITEM_DEFINITIONS[ItemId.potion];
258 440 if (potionDef && canSellOnMarketplace({ itemId: ItemId.potion, quantity: 1 }))
259 441 {
260 const potionHint = undiscountedMarketCoins(
442 const potionHint = catalogHint(
261 443 ItemId.potion,
262 lastSaleFor(ItemId.potion),
444 lastSaleFor,
445 undiscountedMarketCoins,
263 446 now,
264 447 lerpDurationMs,
265 448 settings
@@ -273,6 +456,33 @@ export function buildMarketCatalogEntries ({
273 456 hintPrice: potionHint
274 457 });
275 458 }
459 catalog.push({
460 itemId: ItemId.potion,
461 listingKey: UNSTABLE_POTION_LISTING_KEY,
462 displayName: "Unstable draught",
463 hintPrice: potionHint
464 });
465 }
466 const flowerDef = ITEM_DEFINITIONS[ItemId.flower];
467 if (flowerDef && canSellOnMarketplace({ itemId: ItemId.flower, quantity: 1 }))
468 {
469 const flowerHint = catalogHint(
470 ItemId.flower,
471 lastSaleFor,
472 undiscountedMarketCoins,
473 now,
474 lerpDurationMs,
475 settings
476 );
477 for (const entry of listFlowerPickerEntries())
478 {
479 catalog.push({
480 itemId: ItemId.flower,
481 listingKey: entry.listingKey,
482 displayName: entry.displayName,
483 hintPrice: flowerHint
484 });
485 }
276 486 }
277 487 catalog.sort((a, b) => a.displayName.localeCompare(b.displayName));
278 488 return catalog;
@@ -1,9 +1,21 @@
1import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "../definitions/items.js";
1import { ItemId, itemDefinition, ITEM_DEFINITIONS, itemDisplayName } from "../definitions/items.js";
2import { alchemyPotionDefinition, listAlchemyPotions } from "../definitions/alchemy.js";
2import { alchemyPotionDefinition, listAlchemyPotions } from "../definitions/alchemy.js";
3import { MAGIC_ELEMENT_ORDER } from "../definitions/attackTypes.js";
4import {
5 FLOWER_COLOR_ORDER,
6 FLOWER_COLOR_DISPLAY,
7 DyeItemId
8} from "../definitions/dyes.js";
9import { ItemFamilyId } from "../definitions/tierFamilies.js";
3import { canSellOnMarketplace } from "../items/marketplace.js";
10import { canSellOnMarketplace } from "../items/marketplace.js";
4
11
5export const RECIPE_LISTING_PREFIX = "recipe:";
12export const RECIPE_LISTING_PREFIX = "recipe:";
6export const POTION_LISTING_PREFIX = "potion:";
13export const POTION_LISTING_PREFIX = "potion:";
14export const FLOWER_LISTING_PREFIX = "flower:";
15export const ARROW_LISTING_PREFIX = "arrow:";
16
17/** Shared CE key for any full unstable draught (buyer gets a surprise effect). */
18export const UNSTABLE_POTION_LISTING_KEY = `${POTION_LISTING_PREFIX}unstable`;
7
19
8/** Stable CE sub-type key for a written recipe paper (`recipe:lesserHealthTonic`, …). */
20/** Stable CE sub-type key for a written recipe paper (`recipe:lesserHealthTonic`, …). */
9export function recipeListingKey (potionKey)
21export function recipeListingKey (potionKey)
@@ -23,6 +35,22 @@ export function potionListingKey (potionKey)
23 return `${POTION_LISTING_PREFIX}${key}`;
35 return `${POTION_LISTING_PREFIX}${key}`;
24}
36}
25
37
38export function flowerListingKey (colorId)
39{
40 const id = String(colorId ?? "").trim();
41 if (!FLOWER_COLOR_ORDER.includes(id))
42 { return null; }
43 return `${FLOWER_LISTING_PREFIX}${id}`;
44}
45
46export function arrowListingKey (element)
47{
48 const el = String(element ?? "").trim();
49 if (!MAGIC_ELEMENT_ORDER.includes(el))
50 { return null; }
51 return `${ARROW_LISTING_PREFIX}${el}`;
52}
53
26/** Potion key from a `recipe:…` listing key (recipe papers). */
54/** Potion key from a `recipe:…` listing key (recipe papers). */
27export function potionKeyFromListingKey (listingKey)
55export function potionKeyFromListingKey (listingKey)
28{
56{
@@ -41,7 +69,35 @@ export function potionKeyFromPotionListingKey (listingKey)
41 return text.slice(POTION_LISTING_PREFIX.length) || null;
69 return text.slice(POTION_LISTING_PREFIX.length) || null;
42}
70}
43
71
44/** Drinkable alchemy brew suitable for CE / gifts (not solid outputs). */
72export function flowerColorIdFromListingKey (listingKey)
73{
74 const text = String(listingKey ?? "");
75 if (!text.startsWith(FLOWER_LISTING_PREFIX))
76 { return null; }
77 const colorId = text.slice(FLOWER_LISTING_PREFIX.length);
78 return FLOWER_COLOR_ORDER.includes(colorId) ? colorId : null;
79}
80
81export function arrowElementFromListingKey (listingKey)
82{
83 const text = String(listingKey ?? "");
84 if (!text.startsWith(ARROW_LISTING_PREFIX))
85 { return null; }
86 const element = text.slice(ARROW_LISTING_PREFIX.length);
87 return MAGIC_ELEMENT_ORDER.includes(element) ? element : null;
88}
89
90export function isArrowItemId (itemId)
91{
92 return itemDefinition(itemId)?.familyId === ItemFamilyId.arrow;
93}
94
95export function isFlowerItemId (itemId)
96{
97 return (itemId | 0) === ItemId.flower || (itemId | 0) === DyeItemId.flower;
98}
99
100/** Drinkable alchemy brew suitable for CE / gifts (not solid outputs, not unstable). */
45export function isMarketPotionBrew (potionKey)
101export function isMarketPotionBrew (potionKey)
46{
102{
47 const potion = alchemyPotionDefinition(potionKey);
103 const potion = alchemyPotionDefinition(potionKey);
@@ -51,6 +107,15 @@ export function isMarketPotionBrew (potionKey)
51 return !!key && !key.startsWith("unstable:");
107 return !!key && !key.startsWith("unstable:");
52}
108}
53
109
110export function isUnstablePotionStack (stack)
111{
112 if ((stack?.itemId | 0) !== ItemId.potion || stack?.instance?.kind !== "potion")
113 { return false; }
114 if (stack.instance.unstable)
115 { return true; }
116 return String(stack.instance.potionKey ?? "").startsWith("unstable:");
117}
118
54/** Listing key carried on a bag stack (sell escrow) or null for normal goods. */
119/** Listing key carried on a bag stack (sell escrow) or null for normal goods. */
55export function listingKeyFromStack (stack)
120export function listingKeyFromStack (stack)
56{
121{
@@ -65,13 +130,22 @@ export function listingKeyFromStack (stack)
65 {
130 {
66 if (stack.instance?.kind !== "potion")
131 if (stack.instance?.kind !== "potion")
67 { return null; }
132 { return null; }
68 if (stack.instance.unstable)
133 if (isUnstablePotionStack(stack))
69 { return null; }
134 { return UNSTABLE_POTION_LISTING_KEY; }
70 const potionKey = String(stack.instance.potionKey ?? "").trim();
135 const potionKey = String(stack.instance.potionKey ?? "").trim();
71 if (!isMarketPotionBrew(potionKey))
136 if (!isMarketPotionBrew(potionKey))
72 { return null; }
137 { return null; }
73 return potionListingKey(potionKey);
138 return potionListingKey(potionKey);
74 }
139 }
140 if (isFlowerItemId(itemId))
141 {
142 if (stack.instance?.kind !== "flower")
143 { return null; }
144 return flowerListingKey(stack.instance.colorId);
145 }
146 if (isArrowItemId(itemId) && stack.instance?.kind === "tipped-arrow")
147 { return arrowListingKey(stack.instance.element); }
148 // Dyeable clothing keeps listingKey null so dyed and undyed match (buyer colour surprise).
75 return null;
149 return null;
76}
150}
77
151
@@ -102,6 +176,21 @@ export function recipePaperDisplayName (potionKey)
102 return `${def.displayName} recipe`;
176 return `${def.displayName} recipe`;
103}
177}
104
178
179export function flowerListingDisplayName (colorId)
180{
181 const label = FLOWER_COLOR_DISPLAY[colorId] ?? "Flower";
182 return `${label} flower`;
183}
184
185export function tippedArrowListingDisplayName (itemId, element)
186{
187 return itemDisplayName({
188 itemId,
189 quantity: 1,
190 instance: { kind: "tipped-arrow", element }
191 });
192}
193
105/**
194/**
106 * Editor / gift picker rows: one entry per alchemy recipe (same as CE buy catalog).
195 * Editor / gift picker rows: one entry per alchemy recipe (same as CE buy catalog).
107 * @returns {Array<{ itemId: number, listingKey: string, potionKey: string, displayName: string, key: string }>}
196 * @returns {Array<{ itemId: number, listingKey: string, potionKey: string, displayName: string, key: string }>}
@@ -151,6 +240,17 @@ export function listPotionPickerEntries ()
151 return entries;
240 return entries;
152}
241}
153
242
243export function listFlowerPickerEntries ()
244{
245 return FLOWER_COLOR_ORDER.map((colorId) => ({
246 itemId: ItemId.flower,
247 listingKey: flowerListingKey(colorId),
248 colorId,
249 displayName: flowerListingDisplayName(colorId),
250 key: `flower:${colorId}`
251 }));
252}
253
154export function marketOrderDisplayName (order)
254export function marketOrderDisplayName (order)
155{
255{
156 const listingKey = listingKeyFromOrder(order);
256 const listingKey = listingKeyFromOrder(order);
@@ -158,6 +258,8 @@ export function marketOrderDisplayName (order)
158 {
258 {
159 return recipePaperDisplayName(potionKeyFromListingKey(listingKey));
259 return recipePaperDisplayName(potionKeyFromListingKey(listingKey));
160 }
260 }
261 if (listingKey === UNSTABLE_POTION_LISTING_KEY)
262 { return "Unstable draught"; }
161 if (listingKey?.startsWith(POTION_LISTING_PREFIX))
263 if (listingKey?.startsWith(POTION_LISTING_PREFIX))
162 {
264 {
163 const potionKey = potionKeyFromPotionListingKey(listingKey);
265 const potionKey = potionKeyFromPotionListingKey(listingKey);
@@ -165,6 +267,19 @@ export function marketOrderDisplayName (order)
165 ?? itemDefinition(ItemId.potion)?.displayName
267 ?? itemDefinition(ItemId.potion)?.displayName
166 ?? "Potion";
268 ?? "Potion";
167 }
269 }
270 if (listingKey?.startsWith(FLOWER_LISTING_PREFIX))
271 {
272 const colorId = flowerColorIdFromListingKey(listingKey);
273 return colorId ? flowerListingDisplayName(colorId) : "Flower";
274 }
275 if (listingKey?.startsWith(ARROW_LISTING_PREFIX))
276 {
277 const element = arrowElementFromListingKey(listingKey);
278 if (element && order?.itemId)
279 { return tippedArrowListingDisplayName(order.itemId, element); }
280 }
281 if (order?.escrowStack)
282 { return itemDisplayName(order.escrowStack); }
168 return itemDefinition(order?.itemId)?.displayName ?? `Item ${order?.itemId ?? "?"}`;
283 return itemDefinition(order?.itemId)?.displayName ?? `Item ${order?.itemId ?? "?"}`;
169}
284}
170
285
@@ -172,6 +287,8 @@ export function normalizeBuyListingKey (itemId, listingKey)
172{
287{
173 const id = itemId | 0;
288 const id = itemId | 0;
174 const key = String(listingKey ?? "").trim();
289 const key = String(listingKey ?? "").trim();
290 if (!key)
291 { return null; }
175 if (id === ItemId.recipePaper)
292 if (id === ItemId.recipePaper)
176 {
293 {
177 if (!key.startsWith(RECIPE_LISTING_PREFIX))
294 if (!key.startsWith(RECIPE_LISTING_PREFIX))
@@ -183,6 +300,8 @@ export function normalizeBuyListingKey (itemId, listingKey)
183 }
300 }
184 if (id === ItemId.potion)
301 if (id === ItemId.potion)
185 {
302 {
303 if (key === UNSTABLE_POTION_LISTING_KEY)
304 { return UNSTABLE_POTION_LISTING_KEY; }
186 if (!key.startsWith(POTION_LISTING_PREFIX))
305 if (!key.startsWith(POTION_LISTING_PREFIX))
187 { return null; }
306 { return null; }
188 const potionKey = potionKeyFromPotionListingKey(key);
307 const potionKey = potionKeyFromPotionListingKey(key);
@@ -190,6 +309,16 @@ export function normalizeBuyListingKey (itemId, listingKey)
190 { return null; }
309 { return null; }
191 return key;
310 return key;
192 }
311 }
312 if (isFlowerItemId(id))
313 {
314 const colorId = flowerColorIdFromListingKey(key);
315 return colorId ? flowerListingKey(colorId) : null;
316 }
317 if (isArrowItemId(id))
318 {
319 const element = arrowElementFromListingKey(key);
320 return element ? arrowListingKey(element) : null;
321 }
193 return null;
322 return null;
194}
323}
195
324
@@ -197,10 +326,35 @@ export function normalizeBuyListingKey (itemId, listingKey)
197export function marketBuyRequiresListingKey (itemId)
326export function marketBuyRequiresListingKey (itemId)
198{
327{
199 const id = itemId | 0;
328 const id = itemId | 0;
200 return id === ItemId.recipePaper || id === ItemId.potion;
329 return id === ItemId.recipePaper
330 || id === ItemId.potion
331 || isFlowerItemId(id);
332}
333
334export function marketBuyListingKeyError (itemId)
335{
336 const id = itemId | 0;
337 if (id === ItemId.recipePaper)
338 { return "Choose which recipe to buy."; }
339 if (id === ItemId.potion)
340 { return "Choose which potion to buy."; }
341 if (isFlowerItemId(id))
342 { return "Choose which flower colour to buy."; }
343 return "Choose a specific listing to buy.";
201}
344}
202
345
203/** Buy-tab catalog rows (recipe papers / potions expand per known subtype). */
346function catalogHint (itemId, lastSaleFor, undiscountedMarketCoins, now, lerpDurationMs, settings)
347{
348 return undiscountedMarketCoins(
349 itemId,
350 lastSaleFor(itemId),
351 now,
352 lerpDurationMs,
353 settings
354 );
355}
356
357/** Buy-tab catalog rows (subtype expansions for recipes, potions, flowers, tipped arrows). */
204export function buildMarketCatalogEntries ({
358export function buildMarketCatalogEntries ({
205 lastSaleFor,
359 lastSaleFor,
206 undiscountedMarketCoins,
360 undiscountedMarketCoins,
@@ -216,27 +370,55 @@ export function buildMarketCatalogEntries ({
216 { continue; }
370 { continue; }
217 if (def.itemId === ItemId.coins)
371 if (def.itemId === ItemId.coins)
218 { continue; }
372 { continue; }
219 if (def.itemId === ItemId.recipePaper || def.itemId === ItemId.potion)
373 if (
374 def.itemId === ItemId.recipePaper
375 || def.itemId === ItemId.potion
376 || isFlowerItemId(def.itemId)
377 )
220 { continue; }
378 { continue; }
379
380 const hint = catalogHint(
381 def.itemId,
382 lastSaleFor,
383 undiscountedMarketCoins,
384 now,
385 lerpDurationMs,
386 settings
387 );
388 if (isArrowItemId(def.itemId))
389 {
390 catalog.push({
391 itemId: def.itemId,
392 listingKey: null,
393 displayName: def.displayName,
394 hintPrice: hint
395 });
396 for (const element of MAGIC_ELEMENT_ORDER)
397 {
398 catalog.push({
399 itemId: def.itemId,
400 listingKey: arrowListingKey(element),
401 displayName: tippedArrowListingDisplayName(def.itemId, element),
402 hintPrice: hint
403 });
404 }
405 continue;
406 }
407
221 catalog.push({
408 catalog.push({
222 itemId: def.itemId,
409 itemId: def.itemId,
223 listingKey: null,
410 listingKey: null,
224 displayName: def.displayName,
411 displayName: def.displayName,
225 hintPrice: undiscountedMarketCoins(
412 hintPrice: hint
226 def.itemId,
227 lastSaleFor(def.itemId),
228 now,
229 lerpDurationMs,
230 settings
231 )
232 });
413 });
233 }
414 }
234 const recipeDef = ITEM_DEFINITIONS[ItemId.recipePaper];
415 const recipeDef = ITEM_DEFINITIONS[ItemId.recipePaper];
235 if (recipeDef && canSellOnMarketplace({ itemId: ItemId.recipePaper, quantity: 1 }))
416 if (recipeDef && canSellOnMarketplace({ itemId: ItemId.recipePaper, quantity: 1 }))
236 {
417 {
237 const recipeHint = undiscountedMarketCoins(
418 const recipeHint = catalogHint(
238 ItemId.recipePaper,
419 ItemId.recipePaper,
239 lastSaleFor(ItemId.recipePaper),
420 lastSaleFor,
421 undiscountedMarketCoins,
240 now,
422 now,
241 lerpDurationMs,
423 lerpDurationMs,
242 settings
424 settings
@@ -257,9 +439,10 @@ export function buildMarketCatalogEntries ({
257 const potionDef = ITEM_DEFINITIONS[ItemId.potion];
439 const potionDef = ITEM_DEFINITIONS[ItemId.potion];
258 if (potionDef && canSellOnMarketplace({ itemId: ItemId.potion, quantity: 1 }))
440 if (potionDef && canSellOnMarketplace({ itemId: ItemId.potion, quantity: 1 }))
259 {
441 {
260 const potionHint = undiscountedMarketCoins(
442 const potionHint = catalogHint(
261 ItemId.potion,
443 ItemId.potion,
262 lastSaleFor(ItemId.potion),
444 lastSaleFor,
445 undiscountedMarketCoins,
263 now,
446 now,
264 lerpDurationMs,
447 lerpDurationMs,
265 settings
448 settings
@@ -273,6 +456,33 @@ export function buildMarketCatalogEntries ({
273 hintPrice: potionHint
456 hintPrice: potionHint
274 });
457 });
275 }
458 }
459 catalog.push({
460 itemId: ItemId.potion,
461 listingKey: UNSTABLE_POTION_LISTING_KEY,
462 displayName: "Unstable draught",
463 hintPrice: potionHint
464 });
465 }
466 const flowerDef = ITEM_DEFINITIONS[ItemId.flower];
467 if (flowerDef && canSellOnMarketplace({ itemId: ItemId.flower, quantity: 1 }))
468 {
469 const flowerHint = catalogHint(
470 ItemId.flower,
471 lastSaleFor,
472 undiscountedMarketCoins,
473 now,
474 lerpDurationMs,
475 settings
476 );
477 for (const entry of listFlowerPickerEntries())
478 {
479 catalog.push({
480 itemId: ItemId.flower,
481 listingKey: entry.listingKey,
482 displayName: entry.displayName,
483 hintPrice: flowerHint
484 });
485 }
276 }
486 }
277 catalog.sort((a, b) => a.displayName.localeCompare(b.displayName));
487 catalog.sort((a, b) => a.displayName.localeCompare(b.displayName));
278 return catalog;
488 return catalog;