BlueGit

timfa questward

Fix recipe paper title, author, and bag description.

Saved recipes show the potion name as the read title, attribute authorship like letters, and use a recipe-paper sprite so the client no longer 404s the asset.

timfa Tim Falken · pushed by timfa

Authored 2026-08-27 · 2 months ago

Hash
48803caf2c51e3ea76314dba9548fb726ba78a06
Parent
3cb73567
5 files changed +17 −4
client/assets/items/paper/recipe-paper.png added Binary file +0 −0

The contents of this binary file are not shown.

client/src/play/inventory.js +4 −2
@@ -273,8 +273,9 @@ export function initInventory ({
273 273 mode: "read",
274 274 slotIndex,
275 275 instance: {
276 documentTitle: slot.instance.displayName ?? "Recipe",
276 277 body: slot.instance.body ?? "",
277 authorDisplayName: slot.instance.displayName ?? "Alchemy recipe"
278 authorDisplayName: slot.instance.authorDisplayName ?? "Unknown"
278 279 }
279 280 })
280 281 });
@@ -696,7 +697,8 @@ export function initInventory ({
696 697 function openLetter ({ mode, slotIndex, instance })
697 698 {
698 699 letterState = { mode, slotIndex, readOnly: mode === "read", instance: instance ?? null };
699 letterTitle.textContent = mode === "write" ? "Write letter" : mode === "edit" ? "Edit letter" : "Letter";
700 letterTitle.textContent = instance?.documentTitle
701 ?? (mode === "write" ? "Write letter" : mode === "edit" ? "Edit letter" : "Letter");
700 702 letterBody.value = instance?.body ?? "";
701 703 letterBody.readOnly = letterState.readOnly;
702 704 letterBody.maxLength = LETTER_MAX_BODY_CHARS;
@@ -273,8 +273,9 @@ export function initInventory ({
273 mode: "read",
273 mode: "read",
274 slotIndex,
274 slotIndex,
275 instance: {
275 instance: {
276 documentTitle: slot.instance.displayName ?? "Recipe",
276 body: slot.instance.body ?? "",
277 body: slot.instance.body ?? "",
277 authorDisplayName: slot.instance.displayName ?? "Alchemy recipe"
278 authorDisplayName: slot.instance.authorDisplayName ?? "Unknown"
278 }
279 }
279 })
280 })
280 });
281 });
@@ -696,7 +697,8 @@ export function initInventory ({
696 function openLetter ({ mode, slotIndex, instance })
697 function openLetter ({ mode, slotIndex, instance })
697 {
698 {
698 letterState = { mode, slotIndex, readOnly: mode === "read", instance: instance ?? null };
699 letterState = { mode, slotIndex, readOnly: mode === "read", instance: instance ?? null };
699 letterTitle.textContent = mode === "write" ? "Write letter" : mode === "edit" ? "Edit letter" : "Letter";
700 letterTitle.textContent = instance?.documentTitle
701 ?? (mode === "write" ? "Write letter" : mode === "edit" ? "Edit letter" : "Letter");
700 letterBody.value = instance?.body ?? "";
702 letterBody.value = instance?.body ?? "";
701 letterBody.readOnly = letterState.readOnly;
703 letterBody.readOnly = letterState.readOnly;
702 letterBody.maxLength = LETTER_MAX_BODY_CHARS;
704 letterBody.maxLength = LETTER_MAX_BODY_CHARS;
server/src/alchemy/service.js +3 −1
@@ -609,7 +609,9 @@ function saveRecipe (world, sessionId, command)
609 609 kind: "recipe-paper",
610 610 recipeId: randomUUID(),
611 611 potionKey: recipe.potionKey,
612 displayName: `${recipe.displayName} recipe`,
612 displayName: `${recipe.displayName} Recipe`,
613 authorCharacterId: command.characterId,
614 authorDisplayName: characterDisplayName(world, handle),
613 615 minAlchemyLevel: recipe.minAlchemyLevel ?? 1,
614 616 body: recipePaperBody(recipe),
615 617 writtenAt: Date.now()
@@ -609,7 +609,9 @@ function saveRecipe (world, sessionId, command)
609 kind: "recipe-paper",
609 kind: "recipe-paper",
610 recipeId: randomUUID(),
610 recipeId: randomUUID(),
611 potionKey: recipe.potionKey,
611 potionKey: recipe.potionKey,
612 displayName: `${recipe.displayName} recipe`,
612 displayName: `${recipe.displayName} Recipe`,
613 authorCharacterId: command.characterId,
614 authorDisplayName: characterDisplayName(world, handle),
613 minAlchemyLevel: recipe.minAlchemyLevel ?? 1,
615 minAlchemyLevel: recipe.minAlchemyLevel ?? 1,
614 body: recipePaperBody(recipe),
616 body: recipePaperBody(recipe),
615 writtenAt: Date.now()
617 writtenAt: Date.now()
server/tests/alchemy.test.js +2 −0
@@ -150,6 +150,8 @@ test("cauldron bottles lesser health tonic when steps and ratios match", () =>
150 150 const recipe = after.inventory.find((slot) => slot?.itemId === ItemId.recipePaper);
151 151 assert.match(recipe.instance?.body ?? "", /Lesser health tonic/);
152 152 assert.match(recipe.instance?.body ?? "", /Alchemy level required/);
153 assert.equal(recipe.instance?.displayName, "Lesser health tonic Recipe");
154 assert.equal(recipe.instance?.authorDisplayName, `${character.first_name} ${character.last_name}`);
153 155 }
154 156 finally
155 157 { harness.close(); }
@@ -150,6 +150,8 @@ test("cauldron bottles lesser health tonic when steps and ratios match", () =>
150 const recipe = after.inventory.find((slot) => slot?.itemId === ItemId.recipePaper);
150 const recipe = after.inventory.find((slot) => slot?.itemId === ItemId.recipePaper);
151 assert.match(recipe.instance?.body ?? "", /Lesser health tonic/);
151 assert.match(recipe.instance?.body ?? "", /Lesser health tonic/);
152 assert.match(recipe.instance?.body ?? "", /Alchemy level required/);
152 assert.match(recipe.instance?.body ?? "", /Alchemy level required/);
153 assert.equal(recipe.instance?.displayName, "Lesser health tonic Recipe");
154 assert.equal(recipe.instance?.authorDisplayName, `${character.first_name} ${character.last_name}`);
153 }
155 }
154 finally
156 finally
155 { harness.close(); }
157 { harness.close(); }
shared/definitions/items.js +8 −1
@@ -368,7 +368,14 @@ export function itemDescription (stack, { localCharacterId } = {})
368 368 : `${name}. A carefully bottled draught.`;
369 369 }
370 370 if (stack.itemId === ItemId.recipePaper && stack.instance?.kind === "recipe-paper")
371 { return "Notes on how to brew a particular draught."; }
371 {
372 const authorId = stack.instance.authorCharacterId;
373 const byYou = authorId != null && Number(authorId) === Number(localCharacterId);
374 const author = byYou
375 ? "you"
376 : (stack.instance.authorDisplayName?.trim() || "someone");
377 return `Written by ${author}.`;
378 }
372 379 return def.description ?? "";
373 380 }
374 381
@@ -368,7 +368,14 @@ export function itemDescription (stack, { localCharacterId } = {})
368 : `${name}. A carefully bottled draught.`;
368 : `${name}. A carefully bottled draught.`;
369 }
369 }
370 if (stack.itemId === ItemId.recipePaper && stack.instance?.kind === "recipe-paper")
370 if (stack.itemId === ItemId.recipePaper && stack.instance?.kind === "recipe-paper")
371 { return "Notes on how to brew a particular draught."; }
371 {
372 const authorId = stack.instance.authorCharacterId;
373 const byYou = authorId != null && Number(authorId) === Number(localCharacterId);
374 const author = byYou
375 ? "you"
376 : (stack.instance.authorDisplayName?.trim() || "someone");
377 return `Written by ${author}.`;
378 }
372 return def.description ?? "";
379 return def.description ?? "";
373}
380}
374
381