Merge branch 'feature/craft-qty-all-stations'
@@ -277,7 +277,7 @@
277
277
<div id="craft-progress-fill" class="craft-progress-fill"></div>
278
278
</div>
279
279
<div id="craft-actions" class="craft-actions">
280
<button id="craft-button" type="button" disabled>Craft</button>
280
<button id="craft-button" type="button" disabled>Craft 1</button>
281
281
<button id="craft-batch-button" type="button" hidden disabled>Craft x</button>
282
282
<button id="craft-batch-all-button" type="button" hidden disabled>Craft all</button>
283
283
</div>
@@ -277,7 +277,7 @@277
<div id="craft-progress-fill" class="craft-progress-fill"></div>277
<div id="craft-progress-fill" class="craft-progress-fill"></div>278
</div>278
</div>279
<div id="craft-actions" class="craft-actions">279
<div id="craft-actions" class="craft-actions">280
<button id="craft-button" type="button" disabled>Craft</button>280
<button id="craft-button" type="button" disabled>Craft 1</button>281
<button id="craft-batch-button" type="button" hidden disabled>Craft x</button>281
<button id="craft-batch-button" type="button" hidden disabled>Craft x</button>282
<button id="craft-batch-all-button" type="button" hidden disabled>Craft all</button>282
<button id="craft-batch-all-button" type="button" hidden disabled>Craft all</button>283
</div>283
</div>@@ -537,7 +537,10 @@ export function initCrafting ({
537
537
538
538
function updateCraftState (slots, recipe)
539
539
{
540
const batchVisible = isCraftingBenchStation();
540
// Recipe craft UI (not alchemy): always offer Craft 1 / Craft x / Craft all.
541
const batchVisible = stationId != null;
542
if (craftButton)
543
{ craftButton.textContent = batchVisible ? "Craft 1" : "Craft"; }
541
544
if (craftBatchButton)
542
545
{ craftBatchButton.hidden = !batchVisible; }
543
546
if (craftBatchAllButton)
@@ -537,7 +537,10 @@ export function initCrafting ({537
537
538
function updateCraftState (slots, recipe)538
function updateCraftState (slots, recipe)539
{539
{540
const batchVisible = isCraftingBenchStation();540
// Recipe craft UI (not alchemy): always offer Craft 1 / Craft x / Craft all.541
const batchVisible = stationId != null;542
if (craftButton)543
{ craftButton.textContent = batchVisible ? "Craft 1" : "Craft"; }541
if (craftBatchButton)544
if (craftBatchButton)542
{ craftBatchButton.hidden = !batchVisible; }545
{ craftBatchButton.hidden = !batchVisible; }543
if (craftBatchAllButton)546
if (craftBatchAllButton)@@ -227,15 +227,10 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
227
227
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
228
228
);
229
229
let batchRemaining = 1;
230
if (stationId === CraftingStationId.craftingBench)
231
{
232
if (options.batchAll)
233
{ batchRemaining = Infinity; }
234
else if (options.batchCount != null)
235
{
236
batchRemaining = Math.max(1, options.batchCount | 0);
237
}
238
}
230
if (options.batchAll)
231
{ batchRemaining = Infinity; }
232
else if (options.batchCount != null)
233
{ batchRemaining = Math.max(1, options.batchCount | 0); }
239
234
sessions.set(characterId, {
240
235
sessionId,
241
236
stationId,
@@ -227,15 +227,10 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,227
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))227
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))228
);228
);229
let batchRemaining = 1;229
let batchRemaining = 1;230
if (stationId === CraftingStationId.craftingBench)230
if (options.batchAll)231
{231
{ batchRemaining = Infinity; }232
if (options.batchAll)232
else if (options.batchCount != null)233
{ batchRemaining = Infinity; }233
{ batchRemaining = Math.max(1, options.batchCount | 0); }234
else if (options.batchCount != null)235
{236
batchRemaining = Math.max(1, options.batchCount | 0);237
}238
}239
sessions.set(characterId, {234
sessions.set(characterId, {240
sessionId,235
sessionId,241
stationId,236
stationId,@@ -443,6 +443,35 @@ test("bronze pickaxe chain: pine log → handle, bar → head, assemble pickaxe"
443
443
{ harness.close(); }
444
444
});
445
445
446
test("anvil accepts Craft x batchCount like the crafting bench", () =>
447
{
448
const harness = makeSimulation({ workerCount: 1 });
449
try
450
{
451
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });
452
const playerId = harness.simulation.spawnCharacter(1, character);
453
const record = harness.simulation.entityRecord(playerId);
454
const worker = harness.simulation.workers[record.workerId];
455
placeStation(worker, 9, 9, BlockType.anvil, "anvil");
456
giveInventory(harness, playerId, [{ itemId: ItemId.bronzeBar, quantity: 3 }]);
457
458
harness.simulation.enqueue(1, {
459
type: "start-craft",
460
characterId: character.character_id,
461
stationId: CraftingStationId.anvil,
462
recipeId: "pickaxe-head-bronze",
463
batchCount: 3
464
});
465
const one = craftDurationMs(recipeDefinition("pickaxe-head-bronze"), CRAFT_DURATION_MS);
466
advanceMs(harness, one * 3 + 200);
467
const bag = harness.simulation.bagOf(playerId);
468
assert.equal(countItem(bag.inventory, ItemId.bronzePickaxeHead), 3);
469
assert.equal(countItem(bag.inventory, ItemId.bronzeBar), 0);
470
}
471
finally
472
{ harness.close(); }
473
});
474
446
475
test("anvil armour recipes use bar counts per piece", () =>
447
476
{
448
477
const chest = recipeDefinition("armour-chestplate-bronze");
@@ -443,6 +443,35 @@ test("bronze pickaxe chain: pine log → handle, bar → head, assemble pickaxe"443
{ harness.close(); }443
{ harness.close(); }444
});444
});445
445
446
test("anvil accepts Craft x batchCount like the crafting bench", () =>447
{448
const harness = makeSimulation({ workerCount: 1 });449
try450
{451
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });452
const playerId = harness.simulation.spawnCharacter(1, character);453
const record = harness.simulation.entityRecord(playerId);454
const worker = harness.simulation.workers[record.workerId];455
placeStation(worker, 9, 9, BlockType.anvil, "anvil");456
giveInventory(harness, playerId, [{ itemId: ItemId.bronzeBar, quantity: 3 }]);457
458
harness.simulation.enqueue(1, {459
type: "start-craft",460
characterId: character.character_id,461
stationId: CraftingStationId.anvil,462
recipeId: "pickaxe-head-bronze",463
batchCount: 3464
});465
const one = craftDurationMs(recipeDefinition("pickaxe-head-bronze"), CRAFT_DURATION_MS);466
advanceMs(harness, one * 3 + 200);467
const bag = harness.simulation.bagOf(playerId);468
assert.equal(countItem(bag.inventory, ItemId.bronzePickaxeHead), 3);469
assert.equal(countItem(bag.inventory, ItemId.bronzeBar), 0);470
}471
finally472
{ harness.close(); }473
});474
446
test("anvil armour recipes use bar counts per piece", () =>475
test("anvil armour recipes use bar counts per piece", () =>447
{476
{448
const chest = recipeDefinition("armour-chestplate-bronze");477
const chest = recipeDefinition("armour-chestplate-bronze");