Make tanning brew a multi-use potion and refresh chicken/deer sprites.
Soft-to-hard leather spends one fill; drinking causes food poisoning. Co-authored-by: Cursor <cursoragent@cursor.com>
The contents of this binary file are not shown.
The contents of this binary file are not shown.
@@ -22,6 +22,12 @@ import
22
22
resolveDyeDisplayStack
23
23
} from "/shared/crafting/dye.js";
24
24
import
25
{
26
potionKeyDisplayName,
27
potionStacksForKey
28
} from "/shared/crafting/potionCharge.js";
29
import { stackQuantity } from "/shared/items/inventory.js";
30
import
25
31
{
26
32
CLOTH_TIER_ORDER,
27
33
CLOTH_DISPLAY_NAME,
@@ -518,6 +524,10 @@ export function initCrafting ({
518
524
: "Dye — none selected";
519
525
inputsList.append(row);
520
526
}
527
if (recipe.consumePotionKey)
528
{
529
inputsList.append(renderPotionChargeRow(recipe.consumePotionKey, slots));
530
}
521
531
522
532
if (dyePreview && dyeClearBtn)
523
533
{
@@ -558,6 +568,36 @@ export function initCrafting ({
558
568
return row;
559
569
}
560
570
571
function renderPotionChargeRow (potionKey, slots)
572
{
573
const matches = potionStacksForKey(slots, potionKey);
574
const totalFill = matches.reduce((sum, entry) => sum + entry.fill * stackQuantity(entry.stack.quantity), 0);
575
const label = potionKeyDisplayName(potionKey);
576
const sample = matches[0]?.stack ?? {
577
itemId: ItemId.potion,
578
quantity: 1,
579
instance: {
580
kind: "potion",
581
potionKey,
582
displayName: label,
583
fillLevel: 4
584
}
585
};
586
const row = document.createElement("li");
587
row.className = "craft-input-row";
588
if (totalFill < 1)
589
{ row.classList.add("short"); }
590
const img = document.createElement("img");
591
img.alt = label;
592
applyItemIcon(img, sample, itemAssetPathForStack(sample));
593
const text = document.createElement("span");
594
text.textContent = totalFill >= 1
595
? `${label} — 1 use (${totalFill} left)`
596
: `${label} — none`;
597
row.append(img, text);
598
return row;
599
}
600
561
601
function updateCraftState (slots, recipe)
562
602
{
563
603
// Recipe craft UI (not alchemy): always offer Craft 1 / Craft x / Craft all.
@@ -610,6 +650,10 @@ export function initCrafting ({
610
650
{
611
651
statusEl.textContent = "Not enough bag space (need room for the result or a partially used dye).";
612
652
}
653
else if (recipe.consumePotionKey)
654
{
655
statusEl.textContent = "Not enough bag space (need room for the result or a partially used brew).";
656
}
613
657
else
614
658
{
615
659
statusEl.textContent = "Not enough bag space for the result.";
@@ -22,6 +22,12 @@ import22
resolveDyeDisplayStack22
resolveDyeDisplayStack23
} from "/shared/crafting/dye.js";23
} from "/shared/crafting/dye.js";24
import24
import25
{26
potionKeyDisplayName,27
potionStacksForKey28
} from "/shared/crafting/potionCharge.js";29
import { stackQuantity } from "/shared/items/inventory.js";30
import25
{31
{26
CLOTH_TIER_ORDER,32
CLOTH_TIER_ORDER,27
CLOTH_DISPLAY_NAME,33
CLOTH_DISPLAY_NAME,@@ -518,6 +524,10 @@ export function initCrafting ({518
: "Dye — none selected";524
: "Dye — none selected";519
inputsList.append(row);525
inputsList.append(row);520
}526
}527
if (recipe.consumePotionKey)528
{529
inputsList.append(renderPotionChargeRow(recipe.consumePotionKey, slots));530
}521
531
522
if (dyePreview && dyeClearBtn)532
if (dyePreview && dyeClearBtn)523
{533
{@@ -558,6 +568,36 @@ export function initCrafting ({558
return row;568
return row;559
}569
}560
570
571
function renderPotionChargeRow (potionKey, slots)572
{573
const matches = potionStacksForKey(slots, potionKey);574
const totalFill = matches.reduce((sum, entry) => sum + entry.fill * stackQuantity(entry.stack.quantity), 0);575
const label = potionKeyDisplayName(potionKey);576
const sample = matches[0]?.stack ?? {577
itemId: ItemId.potion,578
quantity: 1,579
instance: {580
kind: "potion",581
potionKey,582
displayName: label,583
fillLevel: 4584
}585
};586
const row = document.createElement("li");587
row.className = "craft-input-row";588
if (totalFill < 1)589
{ row.classList.add("short"); }590
const img = document.createElement("img");591
img.alt = label;592
applyItemIcon(img, sample, itemAssetPathForStack(sample));593
const text = document.createElement("span");594
text.textContent = totalFill >= 1595
? `${label} — 1 use (${totalFill} left)`596
: `${label} — none`;597
row.append(img, text);598
return row;599
}600
561
function updateCraftState (slots, recipe)601
function updateCraftState (slots, recipe)562
{602
{563
// Recipe craft UI (not alchemy): always offer Craft 1 / Craft x / Craft all.603
// Recipe craft UI (not alchemy): always offer Craft 1 / Craft x / Craft all.@@ -610,6 +650,10 @@ export function initCrafting ({610
{650
{611
statusEl.textContent = "Not enough bag space (need room for the result or a partially used dye).";651
statusEl.textContent = "Not enough bag space (need room for the result or a partially used dye).";612
}652
}653
else if (recipe.consumePotionKey)654
{655
statusEl.textContent = "Not enough bag space (need room for the result or a partially used brew).";656
}613
else657
else614
{658
{615
statusEl.textContent = "Not enough bag space for the result.";659
statusEl.textContent = "Not enough bag space for the result.";@@ -13,6 +13,7 @@ import
13
13
} from "../../../shared/crafting/recipes.js";
14
14
import { resolveTailorCraft } from "../../../shared/crafting/tailor.js";
15
15
import { pickEmptiestDyeSlot } from "../../../shared/crafting/dye.js";
16
import { pickEmptiestPotionSlot } from "../../../shared/crafting/potionCharge.js";
16
17
import { dyeColorKey as dyeInstanceColorKey } from "../../../shared/definitions/dyes.js";
17
18
import { craftDurationMs, craftXpForConsumedInputs } from "../../../shared/definitions/gathering.js";
18
19
import { takeFromSlot, insertStack, stackQuantity, consumeFillCharge } from "../../../shared/items/inventory.js";
@@ -137,6 +138,16 @@ function consumeDyeUse (slots, slotIndex)
137
138
});
138
139
}
139
140
141
/** Spend one fill of a potion bottle; exhausted bottles become empty glass. */
142
function consumePotionUse (slots, slotIndex)
143
{
144
return consumeFillCharge(slots, slotIndex, {
145
kind: "potion",
146
itemId: ItemId.potion,
147
returnEmptyItemId: ItemId.glassBottle
148
});
149
}
150
140
151
export function startCraft (world, sessionId, characterId, stationId, recipeId, now, options = {})
141
152
{
142
153
const entityId = world.characterEntities.get(characterId);
@@ -210,6 +221,13 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
210
221
if (!dyeProbe.ok)
211
222
{ throw userError("Need bag space to separate the partially used dye."); }
212
223
}
224
if (recipe.consumePotionKey)
225
{
226
const probeSlot = pickEmptiestPotionSlot(inventory?.slots ?? [], recipe.consumePotionKey);
227
const potionProbe = consumePotionUse(inventory?.slots ?? [], probeSlot);
228
if (!potionProbe.ok)
229
{ throw userError("Need bag space to separate the partially used brew."); }
230
}
213
231
throw userError("Not enough bag space for the result.");
214
232
}
215
233
if (recipe.consumeDye && dyeColorKey != null)
@@ -219,6 +237,12 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
219
237
if (!dye || dye.itemId !== ItemId.dye)
220
238
{ throw userError("Selected dye is missing."); }
221
239
}
240
if (recipe.consumePotionKey)
241
{
242
const probeSlot = pickEmptiestPotionSlot(inventory?.slots ?? [], recipe.consumePotionKey);
243
if (probeSlot == null)
244
{ throw userError("Missing materials."); }
245
}
222
246
223
247
const sessions = ensureCraftSessions(world);
224
248
const equipment = world.ecs.get(handle, Component.equipment);
@@ -396,6 +420,25 @@ export function stepCrafting (world, now)
396
420
}
397
421
slotsAfter = dyeTaken.slots;
398
422
}
423
if (recipe.consumePotionKey)
424
{
425
const consumeSlot = pickEmptiestPotionSlot(slotsAfter, recipe.consumePotionKey);
426
const potionTaken = consumePotionUse(slotsAfter, consumeSlot);
427
if (!potionTaken.ok)
428
{
429
events.push({
430
type: "craft-result",
431
sessionId: session.sessionId,
432
recipeId: session.recipeId,
433
ok: false,
434
error: potionTaken.reason === "space"
435
? "Need bag space to separate the partially used brew."
436
: "Missing materials."
437
});
438
continue;
439
}
440
slotsAfter = potionTaken.slots;
441
}
399
442
400
443
const burnChance = cookBurnChance(session.stationId);
401
444
const burned = burnChance > 0
@@ -13,6 +13,7 @@ import13
} from "../../../shared/crafting/recipes.js";13
} from "../../../shared/crafting/recipes.js";14
import { resolveTailorCraft } from "../../../shared/crafting/tailor.js";14
import { resolveTailorCraft } from "../../../shared/crafting/tailor.js";15
import { pickEmptiestDyeSlot } from "../../../shared/crafting/dye.js";15
import { pickEmptiestDyeSlot } from "../../../shared/crafting/dye.js";16
import { pickEmptiestPotionSlot } from "../../../shared/crafting/potionCharge.js";16
import { dyeColorKey as dyeInstanceColorKey } from "../../../shared/definitions/dyes.js";17
import { dyeColorKey as dyeInstanceColorKey } from "../../../shared/definitions/dyes.js";17
import { craftDurationMs, craftXpForConsumedInputs } from "../../../shared/definitions/gathering.js";18
import { craftDurationMs, craftXpForConsumedInputs } from "../../../shared/definitions/gathering.js";18
import { takeFromSlot, insertStack, stackQuantity, consumeFillCharge } from "../../../shared/items/inventory.js";19
import { takeFromSlot, insertStack, stackQuantity, consumeFillCharge } from "../../../shared/items/inventory.js";@@ -137,6 +138,16 @@ function consumeDyeUse (slots, slotIndex)137
});138
});138
}139
}139
140
141
/** Spend one fill of a potion bottle; exhausted bottles become empty glass. */142
function consumePotionUse (slots, slotIndex)143
{144
return consumeFillCharge(slots, slotIndex, {145
kind: "potion",146
itemId: ItemId.potion,147
returnEmptyItemId: ItemId.glassBottle148
});149
}150
140
export function startCraft (world, sessionId, characterId, stationId, recipeId, now, options = {})151
export function startCraft (world, sessionId, characterId, stationId, recipeId, now, options = {})141
{152
{142
const entityId = world.characterEntities.get(characterId);153
const entityId = world.characterEntities.get(characterId);@@ -210,6 +221,13 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,210
if (!dyeProbe.ok)221
if (!dyeProbe.ok)211
{ throw userError("Need bag space to separate the partially used dye."); }222
{ throw userError("Need bag space to separate the partially used dye."); }212
}223
}224
if (recipe.consumePotionKey)225
{226
const probeSlot = pickEmptiestPotionSlot(inventory?.slots ?? [], recipe.consumePotionKey);227
const potionProbe = consumePotionUse(inventory?.slots ?? [], probeSlot);228
if (!potionProbe.ok)229
{ throw userError("Need bag space to separate the partially used brew."); }230
}213
throw userError("Not enough bag space for the result.");231
throw userError("Not enough bag space for the result.");214
}232
}215
if (recipe.consumeDye && dyeColorKey != null)233
if (recipe.consumeDye && dyeColorKey != null)@@ -219,6 +237,12 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,219
if (!dye || dye.itemId !== ItemId.dye)237
if (!dye || dye.itemId !== ItemId.dye)220
{ throw userError("Selected dye is missing."); }238
{ throw userError("Selected dye is missing."); }221
}239
}240
if (recipe.consumePotionKey)241
{242
const probeSlot = pickEmptiestPotionSlot(inventory?.slots ?? [], recipe.consumePotionKey);243
if (probeSlot == null)244
{ throw userError("Missing materials."); }245
}222
246
223
const sessions = ensureCraftSessions(world);247
const sessions = ensureCraftSessions(world);224
const equipment = world.ecs.get(handle, Component.equipment);248
const equipment = world.ecs.get(handle, Component.equipment);@@ -396,6 +420,25 @@ export function stepCrafting (world, now)396
}420
}397
slotsAfter = dyeTaken.slots;421
slotsAfter = dyeTaken.slots;398
}422
}423
if (recipe.consumePotionKey)424
{425
const consumeSlot = pickEmptiestPotionSlot(slotsAfter, recipe.consumePotionKey);426
const potionTaken = consumePotionUse(slotsAfter, consumeSlot);427
if (!potionTaken.ok)428
{429
events.push({430
type: "craft-result",431
sessionId: session.sessionId,432
recipeId: session.recipeId,433
ok: false,434
error: potionTaken.reason === "space"435
? "Need bag space to separate the partially used brew."436
: "Missing materials."437
});438
continue;439
}440
slotsAfter = potionTaken.slots;441
}399
442
400
const burnChance = cookBurnChance(session.stationId);443
const burnChance = cookBurnChance(session.stationId);401
const burned = burnChance > 0444
const burned = burnChance > 0@@ -59,7 +59,11 @@ function giveInventory (harness, playerId, items)
59
59
const inventory = emptySlots();
60
60
items.forEach((stack, index) =>
61
61
{
62
inventory[index] = { itemId: stack.itemId, quantity: stack.quantity };
62
inventory[index] = {
63
itemId: stack.itemId,
64
quantity: stack.quantity,
65
...(stack.instance ? { instance: structuredClone(stack.instance) } : {})
66
};
63
67
});
64
68
harness.simulation.applyBag(playerId, {
65
69
inventory,
@@ -214,6 +218,86 @@ test("open leatherworking table near station emits station-open", () =>
214
218
{ harness.close(); }
215
219
});
216
220
221
test("hard leather craft spends one tanning brew fill and returns empty glass when exhausted", () =>
222
{
223
const harness = makeSimulation({ workerCount: 1 });
224
try
225
{
226
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });
227
const playerId = harness.simulation.spawnCharacter(1, character);
228
const record = harness.simulation.entityRecord(playerId);
229
const worker = harness.simulation.workers[record.workerId];
230
const data = worker.world.chunkData(0, 0);
231
data.blocks[8 * 16 + 9] = {
232
typeId: BlockType.leatherworkingTable,
233
state: "leatherworking-table",
234
config: null
235
};
236
setSkillLevel(worker, playerId, SkillId.leatherworking, 10);
237
giveInventory(harness, playerId, [
238
{ itemId: LeatherItemId.softLeather, quantity: 2 },
239
{
240
itemId: ItemId.potion,
241
quantity: 1,
242
instance: {
243
kind: "potion",
244
potionKey: "tanningBrew",
245
displayName: "Tanning brew",
246
fillLevel: 2,
247
effect: { type: "food-poisoning", amountPerSecond: 1, durationMs: 10_000 },
248
effectKey: "food-poisoning"
249
}
250
}
251
]);
252
253
const hard = recipeDefinition("leather-hard");
254
assert.equal(hard.consumePotionKey, "tanningBrew");
255
assert.deepEqual(hard.inputs, [{ itemId: LeatherItemId.softLeather, quantity: 1 }]);
256
257
harness.simulation.enqueue(1, {
258
type: "start-craft",
259
characterId: character.character_id,
260
stationId: CraftingStationId.leatherworkingStation,
261
recipeId: "leather-hard"
262
});
263
harness.simulation.step();
264
const hardDuration = craftDurationMs(hard, CRAFT_DURATION_MS);
265
advanceMs(harness, hardDuration);
266
267
let bag = harness.simulation.bagOf(playerId);
268
assert.equal(countItem(bag.inventory, LeatherItemId.hardLeather), 1);
269
assert.equal(countItem(bag.inventory, LeatherItemId.softLeather), 1);
270
const brew = bag.inventory.find((slot) =>
271
slot?.itemId === ItemId.potion && slot.instance?.potionKey === "tanningBrew"
272
);
273
assert.ok(brew);
274
assert.equal(brew.instance.fillLevel, 1);
275
assert.equal(countItem(bag.inventory, ItemId.glassBottle), 0);
276
277
harness.simulation.enqueue(1, {
278
type: "start-craft",
279
characterId: character.character_id,
280
stationId: CraftingStationId.leatherworkingStation,
281
recipeId: "leather-hard"
282
});
283
harness.simulation.step();
284
advanceMs(harness, hardDuration);
285
286
bag = harness.simulation.bagOf(playerId);
287
assert.equal(countItem(bag.inventory, LeatherItemId.hardLeather), 2);
288
assert.equal(countItem(bag.inventory, LeatherItemId.softLeather), 0);
289
assert.equal(
290
bag.inventory.some((slot) =>
291
slot?.itemId === ItemId.potion && slot.instance?.potionKey === "tanningBrew"
292
),
293
false
294
);
295
assert.equal(countItem(bag.inventory, ItemId.glassBottle), 1);
296
}
297
finally
298
{ harness.close(); }
299
});
300
217
301
test("smelting bronze consumes tin and copper, grants bar and Smithing XP", () =>
218
302
{
219
303
const harness = makeSimulation({ workerCount: 1 });
@@ -59,7 +59,11 @@ function giveInventory (harness, playerId, items)59
const inventory = emptySlots();59
const inventory = emptySlots();60
items.forEach((stack, index) =>60
items.forEach((stack, index) =>61
{61
{62
inventory[index] = { itemId: stack.itemId, quantity: stack.quantity };62
inventory[index] = {63
itemId: stack.itemId,64
quantity: stack.quantity,65
...(stack.instance ? { instance: structuredClone(stack.instance) } : {})66
};63
});67
});64
harness.simulation.applyBag(playerId, {68
harness.simulation.applyBag(playerId, {65
inventory,69
inventory,@@ -214,6 +218,86 @@ test("open leatherworking table near station emits station-open", () =>214
{ harness.close(); }218
{ harness.close(); }215
});219
});216
220
221
test("hard leather craft spends one tanning brew fill and returns empty glass when exhausted", () =>222
{223
const harness = makeSimulation({ workerCount: 1 });224
try225
{226
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });227
const playerId = harness.simulation.spawnCharacter(1, character);228
const record = harness.simulation.entityRecord(playerId);229
const worker = harness.simulation.workers[record.workerId];230
const data = worker.world.chunkData(0, 0);231
data.blocks[8 * 16 + 9] = {232
typeId: BlockType.leatherworkingTable,233
state: "leatherworking-table",234
config: null235
};236
setSkillLevel(worker, playerId, SkillId.leatherworking, 10);237
giveInventory(harness, playerId, [238
{ itemId: LeatherItemId.softLeather, quantity: 2 },239
{240
itemId: ItemId.potion,241
quantity: 1,242
instance: {243
kind: "potion",244
potionKey: "tanningBrew",245
displayName: "Tanning brew",246
fillLevel: 2,247
effect: { type: "food-poisoning", amountPerSecond: 1, durationMs: 10_000 },248
effectKey: "food-poisoning"249
}250
}251
]);252
253
const hard = recipeDefinition("leather-hard");254
assert.equal(hard.consumePotionKey, "tanningBrew");255
assert.deepEqual(hard.inputs, [{ itemId: LeatherItemId.softLeather, quantity: 1 }]);256
257
harness.simulation.enqueue(1, {258
type: "start-craft",259
characterId: character.character_id,260
stationId: CraftingStationId.leatherworkingStation,261
recipeId: "leather-hard"262
});263
harness.simulation.step();264
const hardDuration = craftDurationMs(hard, CRAFT_DURATION_MS);265
advanceMs(harness, hardDuration);266
267
let bag = harness.simulation.bagOf(playerId);268
assert.equal(countItem(bag.inventory, LeatherItemId.hardLeather), 1);269
assert.equal(countItem(bag.inventory, LeatherItemId.softLeather), 1);270
const brew = bag.inventory.find((slot) =>271
slot?.itemId === ItemId.potion && slot.instance?.potionKey === "tanningBrew"272
);273
assert.ok(brew);274
assert.equal(brew.instance.fillLevel, 1);275
assert.equal(countItem(bag.inventory, ItemId.glassBottle), 0);276
277
harness.simulation.enqueue(1, {278
type: "start-craft",279
characterId: character.character_id,280
stationId: CraftingStationId.leatherworkingStation,281
recipeId: "leather-hard"282
});283
harness.simulation.step();284
advanceMs(harness, hardDuration);285
286
bag = harness.simulation.bagOf(playerId);287
assert.equal(countItem(bag.inventory, LeatherItemId.hardLeather), 2);288
assert.equal(countItem(bag.inventory, LeatherItemId.softLeather), 0);289
assert.equal(290
bag.inventory.some((slot) =>291
slot?.itemId === ItemId.potion && slot.instance?.potionKey === "tanningBrew"292
),293
false294
);295
assert.equal(countItem(bag.inventory, ItemId.glassBottle), 1);296
}297
finally298
{ harness.close(); }299
});300
217
test("smelting bronze consumes tin and copper, grants bar and Smithing XP", () =>301
test("smelting bronze consumes tin and copper, grants bar and Smithing XP", () =>218
{302
{219
const harness = makeSimulation({ workerCount: 1 });303
const harness = makeSimulation({ workerCount: 1 });@@ -290,8 +290,8 @@ test("market catalog lists each drinkable potion brew separately", () =>
290
290
assert.equal(potions.some((entry) => entry.displayName === "Potion"), false);
291
291
assert.equal(
292
292
potions.some((entry) => entry.listingKey === potionListingKey("tanningBrew")),
293
false,
294
"solid tanning brew output stays its own item id"
293
true,
294
"tanning brew is listed as a drinkable potion"
295
295
);
296
296
});
297
297
@@ -290,8 +290,8 @@ test("market catalog lists each drinkable potion brew separately", () =>290
assert.equal(potions.some((entry) => entry.displayName === "Potion"), false);290
assert.equal(potions.some((entry) => entry.displayName === "Potion"), false);291
assert.equal(291
assert.equal(292
potions.some((entry) => entry.listingKey === potionListingKey("tanningBrew")),292
potions.some((entry) => entry.listingKey === potionListingKey("tanningBrew")),293
false,293
true,294
"solid tanning brew output stays its own item id"294
"tanning brew is listed as a drinkable potion"295
);295
);296
});296
});297
297
@@ -302,8 +302,8 @@ test("animal fat and tanning brew alchemy recipes resolve", () =>
302
302
assert.ok(fat);
303
303
assert.equal(fat.effect?.type, StatusEffectType.foodPoisoning);
304
304
assert.ok(tan);
305
assert.equal(tan.outputItemId, LeatherItemId.tanningBrew);
306
assert.equal(tan.requiresEmptyBottles, false);
305
assert.equal(tan.outputItemId ?? null, null);
306
assert.equal(tan.effect?.type, StatusEffectType.foodPoisoning);
307
307
308
308
const fatEval = evaluateAlchemyBottle({
309
309
skills: { levels: { [SkillId.alchemy]: 1 } },
@@ -326,10 +326,12 @@ test("animal fat and tanning brew alchemy recipes resolve", () =>
326
326
takenSteps: tan.steps
327
327
});
328
328
assert.equal(tanEval.success, true);
329
assert.equal(tanEval.result.outputItemId, LeatherItemId.tanningBrew);
329
assert.equal(tanEval.result.potionKey, "tanningBrew");
330
assert.equal(tanEval.result.outputItemId ?? null, null);
331
assert.equal(tanEval.result.effect?.type, StatusEffectType.foodPoisoning);
330
332
});
331
333
332
test("cauldron bottles animal fat then tanning brew returns the empty bottle", () =>
334
test("cauldron bottles animal fat then tanning brew as a potion", () =>
333
335
{
334
336
const harness = makeSimulation({ workerCount: 1 });
335
337
try
@@ -418,8 +420,12 @@ test("cauldron bottles animal fat then tanning brew returns the empty bottle", (
418
420
harness.simulation.step();
419
421
420
422
bag = harness.simulation.bagOf(entityId);
421
assert.equal(countItem(bag.inventory, LeatherItemId.tanningBrew), 1);
422
assert.equal(countItem(bag.inventory, ItemId.potion), 0);
423
const brew = bag.inventory.find((slot) =>
424
slot?.itemId === ItemId.potion && slot.instance?.potionKey === "tanningBrew"
425
);
426
assert.ok(brew);
427
assert.equal(brew.instance.fillLevel, 4);
428
assert.equal(countItem(bag.inventory, LeatherItemId.tanningBrew), 0);
423
429
assert.equal(countItem(bag.inventory, ItemId.glassBottle), 1);
424
430
assert.equal(countItem(bag.inventory, WoodItemId.oakBark), 0);
425
431
assert.equal(countItem(bag.inventory, CraftingItemId.salt), 0);
@@ -302,8 +302,8 @@ test("animal fat and tanning brew alchemy recipes resolve", () =>302
assert.ok(fat);302
assert.ok(fat);303
assert.equal(fat.effect?.type, StatusEffectType.foodPoisoning);303
assert.equal(fat.effect?.type, StatusEffectType.foodPoisoning);304
assert.ok(tan);304
assert.ok(tan);305
assert.equal(tan.outputItemId, LeatherItemId.tanningBrew);305
assert.equal(tan.outputItemId ?? null, null);306
assert.equal(tan.requiresEmptyBottles, false);306
assert.equal(tan.effect?.type, StatusEffectType.foodPoisoning);307
307
308
const fatEval = evaluateAlchemyBottle({308
const fatEval = evaluateAlchemyBottle({309
skills: { levels: { [SkillId.alchemy]: 1 } },309
skills: { levels: { [SkillId.alchemy]: 1 } },@@ -326,10 +326,12 @@ test("animal fat and tanning brew alchemy recipes resolve", () =>326
takenSteps: tan.steps326
takenSteps: tan.steps327
});327
});328
assert.equal(tanEval.success, true);328
assert.equal(tanEval.success, true);329
assert.equal(tanEval.result.outputItemId, LeatherItemId.tanningBrew);329
assert.equal(tanEval.result.potionKey, "tanningBrew");330
assert.equal(tanEval.result.outputItemId ?? null, null);331
assert.equal(tanEval.result.effect?.type, StatusEffectType.foodPoisoning);330
});332
});331
333
332
test("cauldron bottles animal fat then tanning brew returns the empty bottle", () =>334
test("cauldron bottles animal fat then tanning brew as a potion", () =>333
{335
{334
const harness = makeSimulation({ workerCount: 1 });336
const harness = makeSimulation({ workerCount: 1 });335
try337
try@@ -418,8 +420,12 @@ test("cauldron bottles animal fat then tanning brew returns the empty bottle", (418
harness.simulation.step();420
harness.simulation.step();419
421
420
bag = harness.simulation.bagOf(entityId);422
bag = harness.simulation.bagOf(entityId);421
assert.equal(countItem(bag.inventory, LeatherItemId.tanningBrew), 1);423
const brew = bag.inventory.find((slot) =>422
assert.equal(countItem(bag.inventory, ItemId.potion), 0);424
slot?.itemId === ItemId.potion && slot.instance?.potionKey === "tanningBrew"425
);426
assert.ok(brew);427
assert.equal(brew.instance.fillLevel, 4);428
assert.equal(countItem(bag.inventory, LeatherItemId.tanningBrew), 0);423
assert.equal(countItem(bag.inventory, ItemId.glassBottle), 1);429
assert.equal(countItem(bag.inventory, ItemId.glassBottle), 1);424
assert.equal(countItem(bag.inventory, WoodItemId.oakBark), 0);430
assert.equal(countItem(bag.inventory, WoodItemId.oakBark), 0);425
assert.equal(countItem(bag.inventory, CraftingItemId.salt), 0);431
assert.equal(countItem(bag.inventory, CraftingItemId.salt), 0);