Triple craft-station XP and double alchemy XP.
Scale tier-based craft XP by skill: 3× for smithing, jewelering, crafting, leatherworking, tailoring, and cooking; 2× for alchemy (brews and dye flowers).
@@ -30,7 +30,10 @@ import {
30
30
} from "../../../shared/items/inventory.js";
31
31
import { attachOrigins, craftOrigin, CraftOriginVerb, writtenOrigin, normalizeOrigins } from "../../../shared/items/origin.js";
32
32
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
33
import { craftXpForConsumedInputs } from "../../../shared/definitions/gathering.js";
33
import {
34
craftXpForConsumedInputs,
35
craftXpMultiplierForSkill
36
} from "../../../shared/definitions/gathering.js";
34
37
import { tileToChunk, tileToLocal } from "../world/coordinates.js";
35
38
import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";
36
39
import { randomUUID } from "node:crypto";
@@ -436,7 +439,7 @@ function bottle (world, sessionId, command)
436
439
itemId: row.itemId,
437
440
quantity: row.quantity
438
441
}));
439
const amount = craftXpForConsumedInputs(xpInputs);
442
const amount = craftXpForConsumedInputs(xpInputs, SkillId.alchemy);
440
443
if (amount > 0)
441
444
{
442
445
const result = applySkillXp(skills, SkillId.alchemy, amount);
@@ -558,7 +561,11 @@ function createDye (world, sessionId, command)
558
561
const flowerCount = rows.reduce((sum, row) => sum + (row.quantity | 0), 0);
559
562
if (skills?.xp && flowerCount > 0)
560
563
{
561
const result = applySkillXp(skills, SkillId.alchemy, flowerCount);
564
const result = applySkillXp(
565
skills,
566
SkillId.alchemy,
567
flowerCount * craftXpMultiplierForSkill(SkillId.alchemy)
568
);
562
569
if (result.changed)
563
570
{
564
571
events.push({
@@ -30,7 +30,10 @@ import {30
} from "../../../shared/items/inventory.js";30
} from "../../../shared/items/inventory.js";31
import { attachOrigins, craftOrigin, CraftOriginVerb, writtenOrigin, normalizeOrigins } from "../../../shared/items/origin.js";31
import { attachOrigins, craftOrigin, CraftOriginVerb, writtenOrigin, normalizeOrigins } from "../../../shared/items/origin.js";32
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";32
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";33
import { craftXpForConsumedInputs } from "../../../shared/definitions/gathering.js";33
import {34
craftXpForConsumedInputs,35
craftXpMultiplierForSkill36
} from "../../../shared/definitions/gathering.js";34
import { tileToChunk, tileToLocal } from "../world/coordinates.js";37
import { tileToChunk, tileToLocal } from "../world/coordinates.js";35
import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";38
import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";36
import { randomUUID } from "node:crypto";39
import { randomUUID } from "node:crypto";@@ -436,7 +439,7 @@ function bottle (world, sessionId, command)436
itemId: row.itemId,439
itemId: row.itemId,437
quantity: row.quantity440
quantity: row.quantity438
}));441
}));439
const amount = craftXpForConsumedInputs(xpInputs);442
const amount = craftXpForConsumedInputs(xpInputs, SkillId.alchemy);440
if (amount > 0)443
if (amount > 0)441
{444
{442
const result = applySkillXp(skills, SkillId.alchemy, amount);445
const result = applySkillXp(skills, SkillId.alchemy, amount);@@ -558,7 +561,11 @@ function createDye (world, sessionId, command)558
const flowerCount = rows.reduce((sum, row) => sum + (row.quantity | 0), 0);561
const flowerCount = rows.reduce((sum, row) => sum + (row.quantity | 0), 0);559
if (skills?.xp && flowerCount > 0)562
if (skills?.xp && flowerCount > 0)560
{563
{561
const result = applySkillXp(skills, SkillId.alchemy, flowerCount);564
const result = applySkillXp(565
skills,566
SkillId.alchemy,567
flowerCount * craftXpMultiplierForSkill(SkillId.alchemy)568
);562
if (result.changed)569
if (result.changed)563
{570
{564
events.push({571
events.push({@@ -428,7 +428,7 @@ export function stepCrafting (world, now)
428
428
const result = applySkillXp(
429
429
skills,
430
430
stationDef.skillId,
431
craftXpForConsumedInputs(recipe.inputs)
431
craftXpForConsumedInputs(recipe.inputs, stationDef.skillId)
432
432
);
433
433
if (result.changed)
434
434
{ skillsChanged = true; }
@@ -428,7 +428,7 @@ export function stepCrafting (world, now)428
const result = applySkillXp(428
const result = applySkillXp(429
skills,429
skills,430
stationDef.skillId,430
stationDef.skillId,431
craftXpForConsumedInputs(recipe.inputs)431
craftXpForConsumedInputs(recipe.inputs, stationDef.skillId)432
);432
);433
if (result.changed)433
if (result.changed)434
{ skillsChanged = true; }434
{ skillsChanged = true; }@@ -151,8 +151,8 @@ test("cauldron bottles lesser health tonic when steps and ratios match", () =>
151
151
assert.equal(potion.instance?.potionKey, "lesserHealthTonic");
152
152
assert.equal(potion.instance?.unstable, false);
153
153
const alchemyAfter = harness.stateDb.getSkills(cid).xp.alchemy ?? 0;
154
// thyme×2 (tier 2) + mint×2 (tier 1)
155
assert.equal(alchemyAfter - alchemyBefore, 6);
154
// thyme×2 (tier 2) + mint×2 (tier 1), alchemy 2×
155
assert.equal(alchemyAfter - alchemyBefore, 12);
156
156
157
157
harness.simulation.enqueue(1, { type: "cauldron-save-recipe", characterId: cid });
158
158
harness.simulation.step();
@@ -321,7 +321,7 @@ test("drinking a lesser health tonic applies health regen", () =>
321
321
{ harness.close(); }
322
322
});
323
323
324
test("creating dye awards 1 alchemy XP per flower and caps a slot at 16", () =>
324
test("creating dye awards 2 alchemy XP per flower and caps a slot at 16", () =>
325
325
{
326
326
const harness = makeSimulation({ workerCount: 1 });
327
327
try
@@ -357,7 +357,7 @@ test("creating dye awards 1 alchemy XP per flower and caps a slot at 16", () =>
357
357
const made = harness.simulation.step();
358
358
assert.equal(made.events.some((event) => event.type === "command-error"), false, JSON.stringify(made.events));
359
359
const alchemyAfter = harness.stateDb.getSkills(cid).xp.alchemy ?? 0;
360
assert.equal(alchemyAfter - alchemyBefore, 16);
360
assert.equal(alchemyAfter - alchemyBefore, 32);
361
361
const bag = harness.simulation.bagOf(entityId);
362
362
assert.equal(countItem(bag.inventory, ItemId.flower), 0);
363
363
assert.equal(countItem(bag.inventory, ItemId.dye), 16);
@@ -151,8 +151,8 @@ test("cauldron bottles lesser health tonic when steps and ratios match", () =>151
assert.equal(potion.instance?.potionKey, "lesserHealthTonic");151
assert.equal(potion.instance?.potionKey, "lesserHealthTonic");152
assert.equal(potion.instance?.unstable, false);152
assert.equal(potion.instance?.unstable, false);153
const alchemyAfter = harness.stateDb.getSkills(cid).xp.alchemy ?? 0;153
const alchemyAfter = harness.stateDb.getSkills(cid).xp.alchemy ?? 0;154
// thyme×2 (tier 2) + mint×2 (tier 1)154
// thyme×2 (tier 2) + mint×2 (tier 1), alchemy 2×155
assert.equal(alchemyAfter - alchemyBefore, 6);155
assert.equal(alchemyAfter - alchemyBefore, 12);156
156
157
harness.simulation.enqueue(1, { type: "cauldron-save-recipe", characterId: cid });157
harness.simulation.enqueue(1, { type: "cauldron-save-recipe", characterId: cid });158
harness.simulation.step();158
harness.simulation.step();@@ -321,7 +321,7 @@ test("drinking a lesser health tonic applies health regen", () =>321
{ harness.close(); }321
{ harness.close(); }322
});322
});323
323
324
test("creating dye awards 1 alchemy XP per flower and caps a slot at 16", () =>324
test("creating dye awards 2 alchemy XP per flower and caps a slot at 16", () =>325
{325
{326
const harness = makeSimulation({ workerCount: 1 });326
const harness = makeSimulation({ workerCount: 1 });327
try327
try@@ -357,7 +357,7 @@ test("creating dye awards 1 alchemy XP per flower and caps a slot at 16", () =>357
const made = harness.simulation.step();357
const made = harness.simulation.step();358
assert.equal(made.events.some((event) => event.type === "command-error"), false, JSON.stringify(made.events));358
assert.equal(made.events.some((event) => event.type === "command-error"), false, JSON.stringify(made.events));359
const alchemyAfter = harness.stateDb.getSkills(cid).xp.alchemy ?? 0;359
const alchemyAfter = harness.stateDb.getSkills(cid).xp.alchemy ?? 0;360
assert.equal(alchemyAfter - alchemyBefore, 16);360
assert.equal(alchemyAfter - alchemyBefore, 32);361
const bag = harness.simulation.bagOf(entityId);361
const bag = harness.simulation.bagOf(entityId);362
assert.equal(countItem(bag.inventory, ItemId.flower), 0);362
assert.equal(countItem(bag.inventory, ItemId.flower), 0);363
assert.equal(countItem(bag.inventory, ItemId.dye), 16);363
assert.equal(countItem(bag.inventory, ItemId.dye), 16);@@ -4,6 +4,7 @@ import { ItemId, itemDefinition } from "../../shared/definitions/items.js";
4
4
import { MetalItemId } from "../../shared/definitions/metalItems.js";
5
5
import { CraftingItemId } from "../../shared/definitions/craftingItems.js";
6
6
import { recipeDefinition } from "../../shared/crafting/stationRecipes.js";
7
import { SkillId } from "../../shared/definitions/skills.js";
7
8
import {
8
9
itemCraftXpValue,
9
10
craftXpForConsumedInputs
@@ -46,6 +47,21 @@ test("orichalcum smelt XP sums ore and three coal", () =>
46
47
assert.equal(craftXpForConsumedInputs(recipe.inputs), 6 + 3 * 3);
47
48
});
48
49
50
test("smithing craft XP is 3× base tier sum", () =>
51
{
52
const recipe = recipeDefinition("smelt-bronze");
53
assert.equal(craftXpForConsumedInputs(recipe.inputs, SkillId.smithing), 6);
54
});
55
56
test("alchemy craft XP is 2× base tier sum", () =>
57
{
58
const inputs = [
59
{ itemId: ItemId.mint, quantity: 2 },
60
{ itemId: ItemId.thyme, quantity: 2 }
61
];
62
assert.equal(craftXpForConsumedInputs(inputs, SkillId.alchemy), 12);
63
});
64
49
65
test("flowers stack to 16", () =>
50
66
{
51
67
assert.equal(itemDefinition(ItemId.flower).maxStackSize, FLOWER_MAX_STACK);
@@ -4,6 +4,7 @@ import { ItemId, itemDefinition } from "../../shared/definitions/items.js";4
import { MetalItemId } from "../../shared/definitions/metalItems.js";4
import { MetalItemId } from "../../shared/definitions/metalItems.js";5
import { CraftingItemId } from "../../shared/definitions/craftingItems.js";5
import { CraftingItemId } from "../../shared/definitions/craftingItems.js";6
import { recipeDefinition } from "../../shared/crafting/stationRecipes.js";6
import { recipeDefinition } from "../../shared/crafting/stationRecipes.js";7
import { SkillId } from "../../shared/definitions/skills.js";7
import {8
import {8
itemCraftXpValue,9
itemCraftXpValue,9
craftXpForConsumedInputs10
craftXpForConsumedInputs@@ -46,6 +47,21 @@ test("orichalcum smelt XP sums ore and three coal", () =>46
assert.equal(craftXpForConsumedInputs(recipe.inputs), 6 + 3 * 3);47
assert.equal(craftXpForConsumedInputs(recipe.inputs), 6 + 3 * 3);47
});48
});48
49
50
test("smithing craft XP is 3× base tier sum", () =>51
{52
const recipe = recipeDefinition("smelt-bronze");53
assert.equal(craftXpForConsumedInputs(recipe.inputs, SkillId.smithing), 6);54
});55
56
test("alchemy craft XP is 2× base tier sum", () =>57
{58
const inputs = [59
{ itemId: ItemId.mint, quantity: 2 },60
{ itemId: ItemId.thyme, quantity: 2 }61
];62
assert.equal(craftXpForConsumedInputs(inputs, SkillId.alchemy), 12);63
});64
49
test("flowers stack to 16", () =>65
test("flowers stack to 16", () =>50
{66
{51
assert.equal(itemDefinition(ItemId.flower).maxStackSize, FLOWER_MAX_STACK);67
assert.equal(itemDefinition(ItemId.flower).maxStackSize, FLOWER_MAX_STACK);@@ -251,7 +251,7 @@ test("smelting bronze consumes tin and copper, grants bar and Smithing XP", () =
251
251
assert.equal(bar?.origins?.[0]?.origin?.verb, "Forged");
252
252
assert.match(bar?.origins?.[0]?.origin?.displayName ?? "", /^Ada/);
253
253
const smithingAfter = harness.stateDb.getSkills(character.character_id).xp.smithing ?? 0;
254
assert.equal(smithingAfter - smithingBefore, 2);
254
assert.equal(smithingAfter - smithingBefore, 6);
255
255
}
256
256
finally
257
257
{ harness.close(); }
@@ -251,7 +251,7 @@ test("smelting bronze consumes tin and copper, grants bar and Smithing XP", () =251
assert.equal(bar?.origins?.[0]?.origin?.verb, "Forged");251
assert.equal(bar?.origins?.[0]?.origin?.verb, "Forged");252
assert.match(bar?.origins?.[0]?.origin?.displayName ?? "", /^Ada/);252
assert.match(bar?.origins?.[0]?.origin?.displayName ?? "", /^Ada/);253
const smithingAfter = harness.stateDb.getSkills(character.character_id).xp.smithing ?? 0;253
const smithingAfter = harness.stateDb.getSkills(character.character_id).xp.smithing ?? 0;254
assert.equal(smithingAfter - smithingBefore, 2);254
assert.equal(smithingAfter - smithingBefore, 6);255
}255
}256
finally256
finally257
{ harness.close(); }257
{ harness.close(); }