Block partially used potions and dyes from the Central Exchange.
CE matching is blind, so any fill or charge below the bottled/full amount is refused alongside worn tools.
@@ -2,6 +2,8 @@ import test from "node:test";
2
2
import assert from "node:assert/strict";
3
3
import { ItemId } from "../../shared/definitions/items.js";
4
4
import { CraftingItemId, tinderboxItemInstance } from "../../shared/definitions/craftingItems.js";
5
import { dyeItemInstance } from "../../shared/definitions/dyes.js";
6
import { potionItemInstance } from "../../shared/alchemy/recipes.js";
5
7
import { BlockType } from "../../shared/definitions/tiles.js";
6
8
import { canSellOnMarketplace, assertMarketplaceSellable } from "../../shared/items/marketplace.js";
7
9
import { midpointTradePrice, MARKET_ORDER_MAX_AGE_MS, soldLetterBody, marketOrderListingFee, orderCancelledLetterBody, orderExpiredLetterBody } from "../../shared/market/exchange.js";
@@ -59,6 +61,59 @@ test("fully charged tinderbox can list on CE; worn cannot", () =>
59
61
);
60
62
});
61
63
64
test("full potions and dyes can list on CE; sipped or used cannot", () =>
65
{
66
const fullPotion = {
67
itemId: ItemId.potion,
68
quantity: 1,
69
instance: potionItemInstance({
70
potionKey: "lesserHealthTonic",
71
displayName: "Lesser health tonic",
72
color: { r: 0.95, g: 0.38, b: 0.32 },
73
fillLevel: 4,
74
effect: { type: "health-regen", amountPerSecond: 1, durationMs: 10_000 },
75
effectKey: "health-regen"
76
})
77
};
78
const sipped = {
79
...fullPotion,
80
instance: { ...fullPotion.instance, fillLevel: 3 }
81
};
82
const fullDye = {
83
itemId: ItemId.dye,
84
quantity: 1,
85
instance: dyeItemInstance({ r: 0.8, g: 0.1, b: 0.1 }, 4)
86
};
87
const usedDye = {
88
itemId: ItemId.dye,
89
quantity: 1,
90
instance: dyeItemInstance({ r: 0.8, g: 0.1, b: 0.1 }, 2)
91
};
92
const unstableFull = {
93
itemId: ItemId.potion,
94
quantity: 1,
95
instance: potionItemInstance({
96
potionKey: "unstable:glow",
97
unstable: true,
98
displayName: "Unstable draught",
99
color: { r: 0.95, g: 0.9, b: 0.45 },
100
fillLevel: 3,
101
effectKey: "glow",
102
effect: { type: "glow", lightRadiusTiles: 2, durationMs: 10_000 }
103
})
104
};
105
const unstableSipped = {
106
...unstableFull,
107
instance: { ...unstableFull.instance, fillLevel: 2 }
108
};
109
assert.equal(canSellOnMarketplace(fullPotion), true);
110
assert.equal(canSellOnMarketplace(sipped), false);
111
assert.equal(canSellOnMarketplace(fullDye), true);
112
assert.equal(canSellOnMarketplace(usedDye), false);
113
assert.equal(canSellOnMarketplace(unstableFull), true);
114
assert.equal(canSellOnMarketplace(unstableSipped), false);
115
});
116
62
117
test("letters cannot be listed on the marketplace", () =>
63
118
{
64
119
const own = {
@@ -2,6 +2,8 @@ import test from "node:test";2
import assert from "node:assert/strict";2
import assert from "node:assert/strict";3
import { ItemId } from "../../shared/definitions/items.js";3
import { ItemId } from "../../shared/definitions/items.js";4
import { CraftingItemId, tinderboxItemInstance } from "../../shared/definitions/craftingItems.js";4
import { CraftingItemId, tinderboxItemInstance } from "../../shared/definitions/craftingItems.js";5
import { dyeItemInstance } from "../../shared/definitions/dyes.js";6
import { potionItemInstance } from "../../shared/alchemy/recipes.js";5
import { BlockType } from "../../shared/definitions/tiles.js";7
import { BlockType } from "../../shared/definitions/tiles.js";6
import { canSellOnMarketplace, assertMarketplaceSellable } from "../../shared/items/marketplace.js";8
import { canSellOnMarketplace, assertMarketplaceSellable } from "../../shared/items/marketplace.js";7
import { midpointTradePrice, MARKET_ORDER_MAX_AGE_MS, soldLetterBody, marketOrderListingFee, orderCancelledLetterBody, orderExpiredLetterBody } from "../../shared/market/exchange.js";9
import { midpointTradePrice, MARKET_ORDER_MAX_AGE_MS, soldLetterBody, marketOrderListingFee, orderCancelledLetterBody, orderExpiredLetterBody } from "../../shared/market/exchange.js";@@ -59,6 +61,59 @@ test("fully charged tinderbox can list on CE; worn cannot", () =>59
);61
);60
});62
});61
63
64
test("full potions and dyes can list on CE; sipped or used cannot", () =>65
{66
const fullPotion = {67
itemId: ItemId.potion,68
quantity: 1,69
instance: potionItemInstance({70
potionKey: "lesserHealthTonic",71
displayName: "Lesser health tonic",72
color: { r: 0.95, g: 0.38, b: 0.32 },73
fillLevel: 4,74
effect: { type: "health-regen", amountPerSecond: 1, durationMs: 10_000 },75
effectKey: "health-regen"76
})77
};78
const sipped = {79
...fullPotion,80
instance: { ...fullPotion.instance, fillLevel: 3 }81
};82
const fullDye = {83
itemId: ItemId.dye,84
quantity: 1,85
instance: dyeItemInstance({ r: 0.8, g: 0.1, b: 0.1 }, 4)86
};87
const usedDye = {88
itemId: ItemId.dye,89
quantity: 1,90
instance: dyeItemInstance({ r: 0.8, g: 0.1, b: 0.1 }, 2)91
};92
const unstableFull = {93
itemId: ItemId.potion,94
quantity: 1,95
instance: potionItemInstance({96
potionKey: "unstable:glow",97
unstable: true,98
displayName: "Unstable draught",99
color: { r: 0.95, g: 0.9, b: 0.45 },100
fillLevel: 3,101
effectKey: "glow",102
effect: { type: "glow", lightRadiusTiles: 2, durationMs: 10_000 }103
})104
};105
const unstableSipped = {106
...unstableFull,107
instance: { ...unstableFull.instance, fillLevel: 2 }108
};109
assert.equal(canSellOnMarketplace(fullPotion), true);110
assert.equal(canSellOnMarketplace(sipped), false);111
assert.equal(canSellOnMarketplace(fullDye), true);112
assert.equal(canSellOnMarketplace(usedDye), false);113
assert.equal(canSellOnMarketplace(unstableFull), true);114
assert.equal(canSellOnMarketplace(unstableSipped), false);115
});116
62
test("letters cannot be listed on the marketplace", () =>117
test("letters cannot be listed on the marketplace", () =>63
{118
{64
const own = {119
const own = {