BlueGit

timfa questward

Wire jewellery worn effects and combat-level equip gates.

Each piece now has a unique in-world effect (regen, resists, luck, teleports, fairy companion, and more). Wearing jewellery requires combat level; crafting still uses Jewelering.

timfa Tim Falken · pushed by timfa

Authored 2026-09-02 · 2 months ago

Hash
4374ec4e27438bf06308cc524c02c3cb9ee3f559
Parent
719e6d4a
17 files changed +268 −57
client/src/play/crafting.js +12 −2
@@ -40,12 +40,14 @@ import
40 40 clothTierForWood
41 41 } from "/shared/definitions/materialTiers.js";
42 42 import { craftDurationMs } from "/shared/definitions/gathering.js";
43 import { craftDurationMultiplier } from "/shared/equipment/jewelryEffects.js";
43 44 import { applyItemIcon } from "../render/potionIcon.js";
44 45
45 46 export function initCrafting ({
46 47 socket,
47 48 MessageType,
48 49 getInventorySlots,
50 getEquipment,
49 51 getSkillLevel
50 52 })
51 53 {
@@ -675,7 +677,11 @@ export function initCrafting ({
675 677 ? `Crafting ${options.batchCount}…`
676 678 : "Crafting…";
677 679 craftStartedAt = performance.now();
678 const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);
680 const equipment = { slots: getEquipment?.() ?? {} };
681 const durationMs = Math.max(
682 1,
683 Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
684 );
679 685 const payload = {
680 686 type: MessageType.startCraft,
681 687 stationId,
@@ -811,7 +817,11 @@ export function initCrafting ({
811 817 progressFill.style.width = "0%";
812 818 statusEl.textContent = "Crafting…";
813 819 craftStartedAt = performance.now();
814 const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);
820 const equipment = { slots: getEquipment?.() ?? {} };
821 const durationMs = Math.max(
822 1,
823 Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
824 );
815 825 if (craftTimer != null)
816 826 { clearTimeout(craftTimer); }
817 827 if (craftAnimFrame != null)
@@ -40,12 +40,14 @@ import
40 clothTierForWood
40 clothTierForWood
41} from "/shared/definitions/materialTiers.js";
41} from "/shared/definitions/materialTiers.js";
42import { craftDurationMs } from "/shared/definitions/gathering.js";
42import { craftDurationMs } from "/shared/definitions/gathering.js";
43import { craftDurationMultiplier } from "/shared/equipment/jewelryEffects.js";
43import { applyItemIcon } from "../render/potionIcon.js";
44import { applyItemIcon } from "../render/potionIcon.js";
44
45
45export function initCrafting ({
46export function initCrafting ({
46 socket,
47 socket,
47 MessageType,
48 MessageType,
48 getInventorySlots,
49 getInventorySlots,
50 getEquipment,
49 getSkillLevel
51 getSkillLevel
50})
52})
51{
53{
@@ -675,7 +677,11 @@ export function initCrafting ({
675 ? `Crafting ${options.batchCount}…`
677 ? `Crafting ${options.batchCount}…`
676 : "Crafting…";
678 : "Crafting…";
677 craftStartedAt = performance.now();
679 craftStartedAt = performance.now();
678 const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);
680 const equipment = { slots: getEquipment?.() ?? {} };
681 const durationMs = Math.max(
682 1,
683 Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
684 );
679 const payload = {
685 const payload = {
680 type: MessageType.startCraft,
686 type: MessageType.startCraft,
681 stationId,
687 stationId,
@@ -811,7 +817,11 @@ export function initCrafting ({
811 progressFill.style.width = "0%";
817 progressFill.style.width = "0%";
812 statusEl.textContent = "Crafting…";
818 statusEl.textContent = "Crafting…";
813 craftStartedAt = performance.now();
819 craftStartedAt = performance.now();
814 const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);
820 const equipment = { slots: getEquipment?.() ?? {} };
821 const durationMs = Math.max(
822 1,
823 Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
824 );
815 if (craftTimer != null)
825 if (craftTimer != null)
816 { clearTimeout(craftTimer); }
826 { clearTimeout(craftTimer); }
817 if (craftAnimFrame != null)
827 if (craftAnimFrame != null)
client/src/render/worldView.js +7 −1
@@ -977,6 +977,8 @@ export class WorldView
977 977 if (!existing)
978 978 { return; }
979 979 existing.lightRadiusTiles = payload.lightRadiusTiles ?? 0;
980 if (payload.lightIntensity != null)
981 { existing.lightIntensity = Number(payload.lightIntensity) || 1; }
980 982 if (payload.visualScale != null)
981 983 { existing.visualScale = Number(payload.visualScale) || 1; }
982 984 this.#applyLayers(existing, payload.layers ?? [{ sprite: payload.sprite }]);
@@ -2332,6 +2334,10 @@ export class WorldView
2332 2334 entity.untargetable = payload.untargetable != null ? !!payload.untargetable : !!entity.untargetable;
2333 2335 entity.freeFlight = payload.freeFlight != null ? !!payload.freeFlight : !!entity.freeFlight;
2334 2336 entity.lightRadiusTiles = payload.lightRadiusTiles ?? entity.lightRadiusTiles ?? 0;
2337 if (payload.lightIntensity != null)
2338 { entity.lightIntensity = Number(payload.lightIntensity) || 1; }
2339 else if (entity.lightIntensity == null)
2340 { entity.lightIntensity = 1; }
2335 2341 if (payload.visualScale != null)
2336 2342 { entity.visualScale = Number(payload.visualScale) || 1; }
2337 2343 else if (entity.visualScale == null)
@@ -3996,7 +4002,7 @@ export class WorldView
3996 4002 tileX: Math.floor(entity.visualX / tileSize),
3997 4003 tileY: Math.floor(entity.visualY / tileSize),
3998 4004 range,
3999 intensity: 1
4005 intensity: entity.lightIntensity ?? 1
4000 4006 });
4001 4007 }
4002 4008
@@ -977,6 +977,8 @@ export class WorldView
977 if (!existing)
977 if (!existing)
978 { return; }
978 { return; }
979 existing.lightRadiusTiles = payload.lightRadiusTiles ?? 0;
979 existing.lightRadiusTiles = payload.lightRadiusTiles ?? 0;
980 if (payload.lightIntensity != null)
981 { existing.lightIntensity = Number(payload.lightIntensity) || 1; }
980 if (payload.visualScale != null)
982 if (payload.visualScale != null)
981 { existing.visualScale = Number(payload.visualScale) || 1; }
983 { existing.visualScale = Number(payload.visualScale) || 1; }
982 this.#applyLayers(existing, payload.layers ?? [{ sprite: payload.sprite }]);
984 this.#applyLayers(existing, payload.layers ?? [{ sprite: payload.sprite }]);
@@ -2332,6 +2334,10 @@ export class WorldView
2332 entity.untargetable = payload.untargetable != null ? !!payload.untargetable : !!entity.untargetable;
2334 entity.untargetable = payload.untargetable != null ? !!payload.untargetable : !!entity.untargetable;
2333 entity.freeFlight = payload.freeFlight != null ? !!payload.freeFlight : !!entity.freeFlight;
2335 entity.freeFlight = payload.freeFlight != null ? !!payload.freeFlight : !!entity.freeFlight;
2334 entity.lightRadiusTiles = payload.lightRadiusTiles ?? entity.lightRadiusTiles ?? 0;
2336 entity.lightRadiusTiles = payload.lightRadiusTiles ?? entity.lightRadiusTiles ?? 0;
2337 if (payload.lightIntensity != null)
2338 { entity.lightIntensity = Number(payload.lightIntensity) || 1; }
2339 else if (entity.lightIntensity == null)
2340 { entity.lightIntensity = 1; }
2335 if (payload.visualScale != null)
2341 if (payload.visualScale != null)
2336 { entity.visualScale = Number(payload.visualScale) || 1; }
2342 { entity.visualScale = Number(payload.visualScale) || 1; }
2337 else if (entity.visualScale == null)
2343 else if (entity.visualScale == null)
@@ -3996,7 +4002,7 @@ export class WorldView
3996 tileX: Math.floor(entity.visualX / tileSize),
4002 tileX: Math.floor(entity.visualX / tileSize),
3997 tileY: Math.floor(entity.visualY / tileSize),
4003 tileY: Math.floor(entity.visualY / tileSize),
3998 range,
4004 range,
3999 intensity: 1
4005 intensity: entity.lightIntensity ?? 1
4000 });
4006 });
4001 }
4007 }
4002
4008
server/src/alchemy/service.js +8 −2
@@ -444,7 +444,12 @@ function bottle (world, sessionId, command)
444 444 const amount = craftXpForConsumedInputs(xpInputs, SkillId.alchemy);
445 445 if (amount > 0)
446 446 {
447 const result = applySkillXp(skills, SkillId.alchemy, amount);
447 const result = applySkillXp(
448 skills,
449 SkillId.alchemy,
450 amount,
451 world.ecs.get(handle, Component.equipment)
452 );
448 453 if (result.changed)
449 454 {
450 455 events.push({
@@ -566,7 +571,8 @@ function createDye (world, sessionId, command)
566 571 const result = applySkillXp(
567 572 skills,
568 573 SkillId.alchemy,
569 flowerCount * craftXpMultiplierForSkill(SkillId.alchemy)
574 flowerCount * craftXpMultiplierForSkill(SkillId.alchemy),
575 world.ecs.get(handle, Component.equipment)
570 576 );
571 577 if (result.changed)
572 578 {
@@ -444,7 +444,12 @@ function bottle (world, sessionId, command)
444 const amount = craftXpForConsumedInputs(xpInputs, SkillId.alchemy);
444 const amount = craftXpForConsumedInputs(xpInputs, SkillId.alchemy);
445 if (amount > 0)
445 if (amount > 0)
446 {
446 {
447 const result = applySkillXp(skills, SkillId.alchemy, amount);
447 const result = applySkillXp(
448 skills,
449 SkillId.alchemy,
450 amount,
451 world.ecs.get(handle, Component.equipment)
452 );
448 if (result.changed)
453 if (result.changed)
449 {
454 {
450 events.push({
455 events.push({
@@ -566,7 +571,8 @@ function createDye (world, sessionId, command)
566 const result = applySkillXp(
571 const result = applySkillXp(
567 skills,
572 skills,
568 SkillId.alchemy,
573 SkillId.alchemy,
569 flowerCount * craftXpMultiplierForSkill(SkillId.alchemy)
574 flowerCount * craftXpMultiplierForSkill(SkillId.alchemy),
575 world.ecs.get(handle, Component.equipment)
570 );
576 );
571 if (result.changed)
577 if (result.changed)
572 {
578 {
server/src/crafting/service.js +13 −3
@@ -24,6 +24,7 @@ import
24 24 CraftOriginVerb
25 25 } from "../../../shared/items/origin.js";
26 26 import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
27 import { craftDurationMultiplier } from "../../../shared/equipment/jewelryEffects.js";
27 28 import { bagView } from "../items/bags.js";
28 29 import { tileToChunk, tileToLocal } from "../world/coordinates.js";
29 30 import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";
@@ -220,7 +221,11 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
220 221 }
221 222
222 223 const sessions = ensureCraftSessions(world);
223 const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);
224 const equipment = world.ecs.get(handle, Component.equipment);
225 const durationMs = Math.max(
226 1,
227 Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
228 );
224 229 let batchRemaining = 1;
225 230 if (stationId === CraftingStationId.craftingBench)
226 231 {
@@ -435,7 +440,8 @@ export function stepCrafting (world, now)
435 440 const result = applySkillXp(
436 441 skills,
437 442 stationDef.skillId,
438 craftXpForConsumedInputs(recipe.inputs, stationDef.skillId)
443 craftXpForConsumedInputs(recipe.inputs, stationDef.skillId),
444 world.ecs.get(handle, Component.equipment)
439 445 );
440 446 if (result.changed)
441 447 { skillsChanged = true; }
@@ -477,7 +483,11 @@ export function stepCrafting (world, now)
477 483 { dyeColorKey: session.dyeColorKey, dyeSlotIndex: null }
478 484 ))
479 485 {
480 const durationMs = session.durationMs ?? craftDurationMs(recipe, CRAFT_DURATION_MS);
486 const equipment = world.ecs.get(handle, Component.equipment);
487 const durationMs = session.durationMs ?? Math.max(
488 1,
489 Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
490 );
481 491 sessions.set(characterId, {
482 492 ...session,
483 493 recipe,
@@ -24,6 +24,7 @@ import
24 CraftOriginVerb
24 CraftOriginVerb
25} from "../../../shared/items/origin.js";
25} from "../../../shared/items/origin.js";
26import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
26import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
27import { craftDurationMultiplier } from "../../../shared/equipment/jewelryEffects.js";
27import { bagView } from "../items/bags.js";
28import { bagView } from "../items/bags.js";
28import { tileToChunk, tileToLocal } from "../world/coordinates.js";
29import { tileToChunk, tileToLocal } from "../world/coordinates.js";
29import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";
30import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";
@@ -220,7 +221,11 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
220 }
221 }
221
222
222 const sessions = ensureCraftSessions(world);
223 const sessions = ensureCraftSessions(world);
223 const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);
224 const equipment = world.ecs.get(handle, Component.equipment);
225 const durationMs = Math.max(
226 1,
227 Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
228 );
224 let batchRemaining = 1;
229 let batchRemaining = 1;
225 if (stationId === CraftingStationId.craftingBench)
230 if (stationId === CraftingStationId.craftingBench)
226 {
231 {
@@ -435,7 +440,8 @@ export function stepCrafting (world, now)
435 const result = applySkillXp(
440 const result = applySkillXp(
436 skills,
441 skills,
437 stationDef.skillId,
442 stationDef.skillId,
438 craftXpForConsumedInputs(recipe.inputs, stationDef.skillId)
443 craftXpForConsumedInputs(recipe.inputs, stationDef.skillId),
444 world.ecs.get(handle, Component.equipment)
439 );
445 );
440 if (result.changed)
446 if (result.changed)
441 { skillsChanged = true; }
447 { skillsChanged = true; }
@@ -477,7 +483,11 @@ export function stepCrafting (world, now)
477 { dyeColorKey: session.dyeColorKey, dyeSlotIndex: null }
483 { dyeColorKey: session.dyeColorKey, dyeSlotIndex: null }
478 ))
484 ))
479 {
485 {
480 const durationMs = session.durationMs ?? craftDurationMs(recipe, CRAFT_DURATION_MS);
486 const equipment = world.ecs.get(handle, Component.equipment);
487 const durationMs = session.durationMs ?? Math.max(
488 1,
489 Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
490 );
481 sessions.set(characterId, {
491 sessions.set(characterId, {
482 ...session,
492 ...session,
483 recipe,
493 recipe,
server/src/ecs/serialize.js +7 −1
@@ -1,6 +1,6 @@
1 1 import { Component } from "./components.js";
2 2 import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js";
3 import { equippedLightRadiusTiles } from "../../../shared/definitions/items.js";
3 import { equippedLightRadiusTiles, equippedLightIntensity } from "../../../shared/definitions/items.js";
4 4 import {
5 5 statusExtraLightRadius,
6 6 statusVisualScale,
@@ -80,6 +80,7 @@ export function publicEntityView (ecs, entityId)
80 80 const mob = creature ? mobDefinition(creature.mobTypeId) : null;
81 81 const isMob = !!creature && !character;
82 82 const gearLight = equippedLightRadiusTiles(equipment);
83 const gearIntensity = equippedLightIntensity(equipment);
83 84 const effectLight = statusExtraLightRadius(statusEffects, now);
84 85 const creatureLight = creature?.lightRadiusTiles
85 86 ?? (mob?.lightRadiusTiles ?? 0);
@@ -112,6 +113,9 @@ export function publicEntityView (ecs, entityId)
112 113 sprite: layers[0]?.sprite ?? null,
113 114 layers,
114 115 lightRadiusTiles: Math.max(gearLight, effectLight, creatureLight),
116 lightIntensity: Math.max(gearLight, effectLight, creatureLight) > 0
117 ? (gearLight >= effectLight && gearLight >= creatureLight ? gearIntensity : 1)
118 : 1,
115 119 visualScale: statusVisualScale(statusEffects, now),
116 120 statusEffects: publicStatusEffectsView(statusEffects, now)
117 121 };
@@ -154,6 +158,7 @@ export function replicationSpawn (view)
154 158 health: view.health,
155 159 maxHealth: view.maxHealth,
156 160 lightRadiusTiles: view.lightRadiusTiles ?? 0,
161 lightIntensity: view.lightIntensity ?? 1,
157 162 visualScale: view.visualScale ?? 1,
158 163 skullValue: view.skullValue | 0
159 164 };
@@ -189,6 +194,7 @@ export function replicationAppearance (view)
189 194 sprite: view.sprite ?? null,
190 195 layers: view.layers ?? [],
191 196 lightRadiusTiles: view.lightRadiusTiles ?? 0,
197 lightIntensity: view.lightIntensity ?? 1,
192 198 visualScale: view.visualScale ?? 1
193 199 };
194 200 }
@@ -1,6 +1,6 @@
1import { Component } from "./components.js";
1import { Component } from "./components.js";
2import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js";
2import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js";
3import { equippedLightRadiusTiles } from "../../../shared/definitions/items.js";
3import { equippedLightRadiusTiles, equippedLightIntensity } from "../../../shared/definitions/items.js";
4import {
4import {
5 statusExtraLightRadius,
5 statusExtraLightRadius,
6 statusVisualScale,
6 statusVisualScale,
@@ -80,6 +80,7 @@ export function publicEntityView (ecs, entityId)
80 const mob = creature ? mobDefinition(creature.mobTypeId) : null;
80 const mob = creature ? mobDefinition(creature.mobTypeId) : null;
81 const isMob = !!creature && !character;
81 const isMob = !!creature && !character;
82 const gearLight = equippedLightRadiusTiles(equipment);
82 const gearLight = equippedLightRadiusTiles(equipment);
83 const gearIntensity = equippedLightIntensity(equipment);
83 const effectLight = statusExtraLightRadius(statusEffects, now);
84 const effectLight = statusExtraLightRadius(statusEffects, now);
84 const creatureLight = creature?.lightRadiusTiles
85 const creatureLight = creature?.lightRadiusTiles
85 ?? (mob?.lightRadiusTiles ?? 0);
86 ?? (mob?.lightRadiusTiles ?? 0);
@@ -112,6 +113,9 @@ export function publicEntityView (ecs, entityId)
112 sprite: layers[0]?.sprite ?? null,
113 sprite: layers[0]?.sprite ?? null,
113 layers,
114 layers,
114 lightRadiusTiles: Math.max(gearLight, effectLight, creatureLight),
115 lightRadiusTiles: Math.max(gearLight, effectLight, creatureLight),
116 lightIntensity: Math.max(gearLight, effectLight, creatureLight) > 0
117 ? (gearLight >= effectLight && gearLight >= creatureLight ? gearIntensity : 1)
118 : 1,
115 visualScale: statusVisualScale(statusEffects, now),
119 visualScale: statusVisualScale(statusEffects, now),
116 statusEffects: publicStatusEffectsView(statusEffects, now)
120 statusEffects: publicStatusEffectsView(statusEffects, now)
117 };
121 };
@@ -154,6 +158,7 @@ export function replicationSpawn (view)
154 health: view.health,
158 health: view.health,
155 maxHealth: view.maxHealth,
159 maxHealth: view.maxHealth,
156 lightRadiusTiles: view.lightRadiusTiles ?? 0,
160 lightRadiusTiles: view.lightRadiusTiles ?? 0,
161 lightIntensity: view.lightIntensity ?? 1,
157 visualScale: view.visualScale ?? 1,
162 visualScale: view.visualScale ?? 1,
158 skullValue: view.skullValue | 0
163 skullValue: view.skullValue | 0
159 };
164 };
@@ -189,6 +194,7 @@ export function replicationAppearance (view)
189 sprite: view.sprite ?? null,
194 sprite: view.sprite ?? null,
190 layers: view.layers ?? [],
195 layers: view.layers ?? [],
191 lightRadiusTiles: view.lightRadiusTiles ?? 0,
196 lightRadiusTiles: view.lightRadiusTiles ?? 0,
197 lightIntensity: view.lightIntensity ?? 1,
192 visualScale: view.visualScale ?? 1
198 visualScale: view.visualScale ?? 1
193 };
199 };
194}
200}
server/src/firestarting/service.js +6 −1
@@ -360,7 +360,12 @@ function succeedLight (world, handle, entityId, characterId, session, events, pr
360 360 const levelUps = [];
361 361 if (skills?.xp)
362 362 {
363 const result = applySkillXp(skills, SkillId.firestarting, session.difficulty);
363 const result = applySkillXp(
364 skills,
365 SkillId.firestarting,
366 session.difficulty,
367 world.ecs.get(handle, Component.equipment)
368 );
364 369 if (result.changed)
365 370 { skillsChanged = true; }
366 371 if (result.levelUp)
@@ -360,7 +360,12 @@ function succeedLight (world, handle, entityId, characterId, session, events, pr
360 const levelUps = [];
360 const levelUps = [];
361 if (skills?.xp)
361 if (skills?.xp)
362 {
362 {
363 const result = applySkillXp(skills, SkillId.firestarting, session.difficulty);
363 const result = applySkillXp(
364 skills,
365 SkillId.firestarting,
366 session.difficulty,
367 world.ecs.get(handle, Component.equipment)
368 );
364 if (result.changed)
369 if (result.changed)
365 { skillsChanged = true; }
370 { skillsChanged = true; }
366 if (result.levelUp)
371 if (result.levelUp)
server/src/fishing/service.js +22 −5
@@ -27,6 +27,11 @@ import { yarnItemId } from "../../../shared/definitions/clothItems.js";
27 27 import { itemDefinition } from "../../../shared/definitions/items.js";
28 28 import { SkillId, skillLevel } from "../../../shared/definitions/skills.js";
29 29 import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
30 import
31 {
32 gatherDurationMultiplier,
33 harvestYieldMultiplier
34 } from "../../../shared/equipment/jewelryEffects.js";
30 35 import { rollSkill } from "../../../shared/combat/rolls.js";
31 36 import {
32 37 insertStack,
@@ -277,7 +282,10 @@ export function startFish (world, sessionId, characterId, tileX, tileY, now = Da
277 282 attemptsLeft: MAX_FISH_ATTEMPTS,
278 283 attemptStartedAt: now,
279 284 nextShoveAt: now,
280 attemptEndsAt: now + FISH_ATTEMPT_MS
285 attemptEndsAt: now + Math.max(
286 1,
287 Math.floor(FISH_ATTEMPT_MS * gatherDurationMultiplier(equipment))
288 )
281 289 });
282 290
283 291 return {
@@ -326,10 +334,11 @@ function completeCatch (world, handle, entityId, characterId, session, events, p
326 334 const inventory = world.ecs.get(handle, Component.inventory);
327 335 const def = itemDefinition(pick);
328 336 const origin = gatherOrigin(GatherOriginVerb.caught, characterDisplayName(world, handle));
337 const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
329 338 const stack = attachOrigins({
330 339 itemId: pick,
331 quantity: 1,
332 origins: [{ origin, quantity: 1 }]
340 quantity,
341 origins: [{ origin, quantity }]
333 342 });
334 343 const inserted = insertStack(inventory.slots, stack, def);
335 344 if (!inserted.ok || inserted.remainder > 0)
@@ -350,7 +359,12 @@ function completeCatch (world, handle, entityId, characterId, session, events, p
350 359 const levelUps = [];
351 360 if (skills?.xp && xpAmount > 0)
352 361 {
353 const result = applySkillXp(skills, SkillId.fishing, xpAmount);
362 const result = applySkillXp(
363 skills,
364 SkillId.fishing,
365 xpAmount,
366 world.ecs.get(handle, Component.equipment)
367 );
354 368 if (result.changed)
355 369 { skillsChanged = true; }
356 370 if (result.levelUp)
@@ -466,7 +480,10 @@ export function stepFishing (world, now)
466 480
467 481 session.attemptStartedAt = now;
468 482 session.nextShoveAt = now;
469 session.attemptEndsAt = now + FISH_ATTEMPT_MS;
483 session.attemptEndsAt = now + Math.max(
484 1,
485 Math.floor(FISH_ATTEMPT_MS * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
486 );
470 487 }
471 488
472 489 return { events, privates };
@@ -27,6 +27,11 @@ import { yarnItemId } from "../../../shared/definitions/clothItems.js";
27import { itemDefinition } from "../../../shared/definitions/items.js";
27import { itemDefinition } from "../../../shared/definitions/items.js";
28import { SkillId, skillLevel } from "../../../shared/definitions/skills.js";
28import { SkillId, skillLevel } from "../../../shared/definitions/skills.js";
29import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
29import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
30import
31{
32 gatherDurationMultiplier,
33 harvestYieldMultiplier
34} from "../../../shared/equipment/jewelryEffects.js";
30import { rollSkill } from "../../../shared/combat/rolls.js";
35import { rollSkill } from "../../../shared/combat/rolls.js";
31import {
36import {
32 insertStack,
37 insertStack,
@@ -277,7 +282,10 @@ export function startFish (world, sessionId, characterId, tileX, tileY, now = Da
277 attemptsLeft: MAX_FISH_ATTEMPTS,
282 attemptsLeft: MAX_FISH_ATTEMPTS,
278 attemptStartedAt: now,
283 attemptStartedAt: now,
279 nextShoveAt: now,
284 nextShoveAt: now,
280 attemptEndsAt: now + FISH_ATTEMPT_MS
285 attemptEndsAt: now + Math.max(
286 1,
287 Math.floor(FISH_ATTEMPT_MS * gatherDurationMultiplier(equipment))
288 )
281 });
289 });
282
290
283 return {
291 return {
@@ -326,10 +334,11 @@ function completeCatch (world, handle, entityId, characterId, session, events, p
326 const inventory = world.ecs.get(handle, Component.inventory);
334 const inventory = world.ecs.get(handle, Component.inventory);
327 const def = itemDefinition(pick);
335 const def = itemDefinition(pick);
328 const origin = gatherOrigin(GatherOriginVerb.caught, characterDisplayName(world, handle));
336 const origin = gatherOrigin(GatherOriginVerb.caught, characterDisplayName(world, handle));
337 const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
329 const stack = attachOrigins({
338 const stack = attachOrigins({
330 itemId: pick,
339 itemId: pick,
331 quantity: 1,
340 quantity,
332 origins: [{ origin, quantity: 1 }]
341 origins: [{ origin, quantity }]
333 });
342 });
334 const inserted = insertStack(inventory.slots, stack, def);
343 const inserted = insertStack(inventory.slots, stack, def);
335 if (!inserted.ok || inserted.remainder > 0)
344 if (!inserted.ok || inserted.remainder > 0)
@@ -350,7 +359,12 @@ function completeCatch (world, handle, entityId, characterId, session, events, p
350 const levelUps = [];
359 const levelUps = [];
351 if (skills?.xp && xpAmount > 0)
360 if (skills?.xp && xpAmount > 0)
352 {
361 {
353 const result = applySkillXp(skills, SkillId.fishing, xpAmount);
362 const result = applySkillXp(
363 skills,
364 SkillId.fishing,
365 xpAmount,
366 world.ecs.get(handle, Component.equipment)
367 );
354 if (result.changed)
368 if (result.changed)
355 { skillsChanged = true; }
369 { skillsChanged = true; }
356 if (result.levelUp)
370 if (result.levelUp)
@@ -466,7 +480,10 @@ export function stepFishing (world, now)
466
480
467 session.attemptStartedAt = now;
481 session.attemptStartedAt = now;
468 session.nextShoveAt = now;
482 session.nextShoveAt = now;
469 session.attemptEndsAt = now + FISH_ATTEMPT_MS;
483 session.attemptEndsAt = now + Math.max(
484 1,
485 Math.floor(FISH_ATTEMPT_MS * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
486 );
470 }
487 }
471
488
472 return { events, privates };
489 return { events, privates };
server/src/gathering/service.js +47 −12
@@ -35,6 +35,11 @@ import { herbDefinition, isHerbId } from "../../../shared/definitions/herbs.js";
35 35 import { insertStack } from "../../../shared/items/inventory.js";
36 36 import { attachOrigins, GatherOriginVerb, gatherOrigin } from "../../../shared/items/origin.js";
37 37 import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
38 import
39 {
40 gatherDurationMultiplier,
41 harvestYieldMultiplier
42 } from "../../../shared/equipment/jewelryEffects.js";
38 43 import {
39 44 seasonIdAt,
40 45 treeStumpStateForSeason,
@@ -381,7 +386,11 @@ export function startMine (world, sessionId, characterId, tileX, tileY, now)
381 386 if (!pickaxe.ok)
382 387 { throw userError(pickaxe.reason); }
383 388
384 const durationMs = miningDurationMs(materialId, pickaxe.tool.tier);
389 const durationMs = Math.max(
390 1,
391 Math.floor(miningDurationMs(materialId, pickaxe.tool.tier)
392 * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
393 );
385 394 const toolItemId = pickaxe.tool.stack?.itemId ?? null;
386 395 return beginGatherSwing(world, handle, entityId, position, {
387 396 kind: "mining",
@@ -425,7 +434,11 @@ export function startChop (world, sessionId, characterId, tileX, tileY, now)
425 434 if (!axe.ok)
426 435 { throw userError(axe.reason); }
427 436
428 const durationMs = woodcuttingDurationMs(woodTier, axe.tool.tier);
437 const durationMs = Math.max(
438 1,
439 Math.floor(woodcuttingDurationMs(woodTier, axe.tool.tier)
440 * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
441 );
429 442 const toolItemId = axe.tool.stack?.itemId ?? null;
430 443 return beginGatherSwing(world, handle, entityId, position, {
431 444 kind: "woodcutting",
@@ -488,7 +501,11 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)
488 501 }
489 502
490 503 const toolTier = clippers.tool?.tier ?? null;
491 const durationMs = herbalismDurationMs(plant.kind, toolTier, herbTier);
504 const durationMs = Math.max(
505 1,
506 Math.floor(herbalismDurationMs(plant.kind, toolTier, herbTier)
507 * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
508 );
492 509 const toolItemId = clippers.tool?.stack?.itemId ?? null;
493 510 const prefixEvents = [];
494 511 let flowerColorId = null;
@@ -559,10 +576,11 @@ function completeMining (world, handle, entityId, character, gather, events, pri
559 576 return;
560 577 }
561 578 const origin = gatherOrigin(GatherOriginVerb.mined, characterDisplayName(world, handle));
579 const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
562 580 const stack = attachOrigins({
563 581 itemId: oreItemId,
564 quantity: 1,
565 origins: [{ origin, quantity: 1 }]
582 quantity,
583 origins: [{ origin, quantity }]
566 584 });
567 585 const inserted = insertStack(inventory.slots, stack, def);
568 586 if (!inserted.ok || inserted.remainder > 0)
@@ -582,7 +600,12 @@ function completeMining (world, handle, entityId, character, gather, events, pri
582 600 const levelUps = [];
583 601 if (skills?.xp)
584 602 {
585 const result = applySkillXp(skills, SkillId.mining, miningXpForMaterial(gather.materialId));
603 const result = applySkillXp(
604 skills,
605 SkillId.mining,
606 miningXpForMaterial(gather.materialId),
607 world.ecs.get(handle, Component.equipment)
608 );
586 609 if (result.changed)
587 610 { skillsChanged = true; }
588 611 if (result.levelUp)
@@ -628,10 +651,11 @@ function completeWoodcutting (world, handle, entityId, character, gather, events
628 651 return;
629 652 }
630 653 const origin = gatherOrigin(GatherOriginVerb.felled, characterDisplayName(world, handle));
654 const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
631 655 const stack = attachOrigins({
632 656 itemId: logItemId,
633 quantity: 1,
634 origins: [{ origin, quantity: 1 }]
657 quantity,
658 origins: [{ origin, quantity }]
635 659 });
636 660 const inserted = insertStack(inventory.slots, stack, def);
637 661 if (!inserted.ok || inserted.remainder > 0)
@@ -651,7 +675,12 @@ function completeWoodcutting (world, handle, entityId, character, gather, events
651 675 const levelUps = [];
652 676 if (skills?.xp)
653 677 {
654 const result = applySkillXp(skills, SkillId.woodcutting, woodcuttingXpForWood(gather.woodTier));
678 const result = applySkillXp(
679 skills,
680 SkillId.woodcutting,
681 woodcuttingXpForWood(gather.woodTier),
682 world.ecs.get(handle, Component.equipment)
683 );
655 684 if (result.changed)
656 685 { skillsChanged = true; }
657 686 if (result.levelUp)
@@ -740,11 +769,12 @@ function completePlant (world, handle, entityId, character, gather, events, priv
740 769 }
741 770
742 771 const origin = gatherOrigin(GatherOriginVerb.picked, characterDisplayName(world, handle));
772 const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
743 773 const stack = attachOrigins({
744 774 itemId,
745 quantity: 1,
775 quantity,
746 776 instance,
747 origins: [{ origin, quantity: 1 }]
777 origins: [{ origin, quantity }]
748 778 });
749 779 const inserted = insertStack(inventory.slots, stack, def);
750 780 if (!inserted.ok || inserted.remainder > 0)
@@ -764,7 +794,12 @@ function completePlant (world, handle, entityId, character, gather, events, priv
764 794 const levelUps = [];
765 795 if (skills?.xp)
766 796 {
767 const result = applySkillXp(skills, SkillId.herbalism, herbalismXpForPick(gather.plantKind, gather.herbTier));
797 const result = applySkillXp(
798 skills,
799 SkillId.herbalism,
800 herbalismXpForPick(gather.plantKind, gather.herbTier),
801 world.ecs.get(handle, Component.equipment)
802 );
768 803 if (result.changed)
769 804 { skillsChanged = true; }
770 805 if (result.levelUp)
@@ -35,6 +35,11 @@ import { herbDefinition, isHerbId } from "../../../shared/definitions/herbs.js";
35import { insertStack } from "../../../shared/items/inventory.js";
35import { insertStack } from "../../../shared/items/inventory.js";
36import { attachOrigins, GatherOriginVerb, gatherOrigin } from "../../../shared/items/origin.js";
36import { attachOrigins, GatherOriginVerb, gatherOrigin } from "../../../shared/items/origin.js";
37import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
37import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
38import
39{
40 gatherDurationMultiplier,
41 harvestYieldMultiplier
42} from "../../../shared/equipment/jewelryEffects.js";
38import {
43import {
39 seasonIdAt,
44 seasonIdAt,
40 treeStumpStateForSeason,
45 treeStumpStateForSeason,
@@ -381,7 +386,11 @@ export function startMine (world, sessionId, characterId, tileX, tileY, now)
381 if (!pickaxe.ok)
386 if (!pickaxe.ok)
382 { throw userError(pickaxe.reason); }
387 { throw userError(pickaxe.reason); }
383
388
384 const durationMs = miningDurationMs(materialId, pickaxe.tool.tier);
389 const durationMs = Math.max(
390 1,
391 Math.floor(miningDurationMs(materialId, pickaxe.tool.tier)
392 * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
393 );
385 const toolItemId = pickaxe.tool.stack?.itemId ?? null;
394 const toolItemId = pickaxe.tool.stack?.itemId ?? null;
386 return beginGatherSwing(world, handle, entityId, position, {
395 return beginGatherSwing(world, handle, entityId, position, {
387 kind: "mining",
396 kind: "mining",
@@ -425,7 +434,11 @@ export function startChop (world, sessionId, characterId, tileX, tileY, now)
425 if (!axe.ok)
434 if (!axe.ok)
426 { throw userError(axe.reason); }
435 { throw userError(axe.reason); }
427
436
428 const durationMs = woodcuttingDurationMs(woodTier, axe.tool.tier);
437 const durationMs = Math.max(
438 1,
439 Math.floor(woodcuttingDurationMs(woodTier, axe.tool.tier)
440 * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
441 );
429 const toolItemId = axe.tool.stack?.itemId ?? null;
442 const toolItemId = axe.tool.stack?.itemId ?? null;
430 return beginGatherSwing(world, handle, entityId, position, {
443 return beginGatherSwing(world, handle, entityId, position, {
431 kind: "woodcutting",
444 kind: "woodcutting",
@@ -488,7 +501,11 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)
488 }
501 }
489
502
490 const toolTier = clippers.tool?.tier ?? null;
503 const toolTier = clippers.tool?.tier ?? null;
491 const durationMs = herbalismDurationMs(plant.kind, toolTier, herbTier);
504 const durationMs = Math.max(
505 1,
506 Math.floor(herbalismDurationMs(plant.kind, toolTier, herbTier)
507 * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
508 );
492 const toolItemId = clippers.tool?.stack?.itemId ?? null;
509 const toolItemId = clippers.tool?.stack?.itemId ?? null;
493 const prefixEvents = [];
510 const prefixEvents = [];
494 let flowerColorId = null;
511 let flowerColorId = null;
@@ -559,10 +576,11 @@ function completeMining (world, handle, entityId, character, gather, events, pri
559 return;
576 return;
560 }
577 }
561 const origin = gatherOrigin(GatherOriginVerb.mined, characterDisplayName(world, handle));
578 const origin = gatherOrigin(GatherOriginVerb.mined, characterDisplayName(world, handle));
579 const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
562 const stack = attachOrigins({
580 const stack = attachOrigins({
563 itemId: oreItemId,
581 itemId: oreItemId,
564 quantity: 1,
582 quantity,
565 origins: [{ origin, quantity: 1 }]
583 origins: [{ origin, quantity }]
566 });
584 });
567 const inserted = insertStack(inventory.slots, stack, def);
585 const inserted = insertStack(inventory.slots, stack, def);
568 if (!inserted.ok || inserted.remainder > 0)
586 if (!inserted.ok || inserted.remainder > 0)
@@ -582,7 +600,12 @@ function completeMining (world, handle, entityId, character, gather, events, pri
582 const levelUps = [];
600 const levelUps = [];
583 if (skills?.xp)
601 if (skills?.xp)
584 {
602 {
585 const result = applySkillXp(skills, SkillId.mining, miningXpForMaterial(gather.materialId));
603 const result = applySkillXp(
604 skills,
605 SkillId.mining,
606 miningXpForMaterial(gather.materialId),
607 world.ecs.get(handle, Component.equipment)
608 );
586 if (result.changed)
609 if (result.changed)
587 { skillsChanged = true; }
610 { skillsChanged = true; }
588 if (result.levelUp)
611 if (result.levelUp)
@@ -628,10 +651,11 @@ function completeWoodcutting (world, handle, entityId, character, gather, events
628 return;
651 return;
629 }
652 }
630 const origin = gatherOrigin(GatherOriginVerb.felled, characterDisplayName(world, handle));
653 const origin = gatherOrigin(GatherOriginVerb.felled, characterDisplayName(world, handle));
654 const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
631 const stack = attachOrigins({
655 const stack = attachOrigins({
632 itemId: logItemId,
656 itemId: logItemId,
633 quantity: 1,
657 quantity,
634 origins: [{ origin, quantity: 1 }]
658 origins: [{ origin, quantity }]
635 });
659 });
636 const inserted = insertStack(inventory.slots, stack, def);
660 const inserted = insertStack(inventory.slots, stack, def);
637 if (!inserted.ok || inserted.remainder > 0)
661 if (!inserted.ok || inserted.remainder > 0)
@@ -651,7 +675,12 @@ function completeWoodcutting (world, handle, entityId, character, gather, events
651 const levelUps = [];
675 const levelUps = [];
652 if (skills?.xp)
676 if (skills?.xp)
653 {
677 {
654 const result = applySkillXp(skills, SkillId.woodcutting, woodcuttingXpForWood(gather.woodTier));
678 const result = applySkillXp(
679 skills,
680 SkillId.woodcutting,
681 woodcuttingXpForWood(gather.woodTier),
682 world.ecs.get(handle, Component.equipment)
683 );
655 if (result.changed)
684 if (result.changed)
656 { skillsChanged = true; }
685 { skillsChanged = true; }
657 if (result.levelUp)
686 if (result.levelUp)
@@ -740,11 +769,12 @@ function completePlant (world, handle, entityId, character, gather, events, priv
740 }
769 }
741
770
742 const origin = gatherOrigin(GatherOriginVerb.picked, characterDisplayName(world, handle));
771 const origin = gatherOrigin(GatherOriginVerb.picked, characterDisplayName(world, handle));
772 const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
743 const stack = attachOrigins({
773 const stack = attachOrigins({
744 itemId,
774 itemId,
745 quantity: 1,
775 quantity,
746 instance,
776 instance,
747 origins: [{ origin, quantity: 1 }]
777 origins: [{ origin, quantity }]
748 });
778 });
749 const inserted = insertStack(inventory.slots, stack, def);
779 const inserted = insertStack(inventory.slots, stack, def);
750 if (!inserted.ok || inserted.remainder > 0)
780 if (!inserted.ok || inserted.remainder > 0)
@@ -764,7 +794,12 @@ function completePlant (world, handle, entityId, character, gather, events, priv
764 const levelUps = [];
794 const levelUps = [];
765 if (skills?.xp)
795 if (skills?.xp)
766 {
796 {
767 const result = applySkillXp(skills, SkillId.herbalism, herbalismXpForPick(gather.plantKind, gather.herbTier));
797 const result = applySkillXp(
798 skills,
799 SkillId.herbalism,
800 herbalismXpForPick(gather.plantKind, gather.herbTier),
801 world.ecs.get(handle, Component.equipment)
802 );
768 if (result.changed)
803 if (result.changed)
769 { skillsChanged = true; }
804 { skillsChanged = true; }
770 if (result.levelUp)
805 if (result.levelUp)
server/src/items/bags.js +6 −3
@@ -400,7 +400,8 @@ function equipItem (world, sessionId, command)
400 400 }
401 401 inventory.slots = slots;
402 402 equipment.slots[slot] = taken.taken;
403 return { events: [], private: bagView(world.ecs, handle), appearanceChanged: false };
403 syncPlayerHealth(world.ecs, handle);
404 return { events: [], private: bagView(world.ecs, handle), appearanceChanged: false, healthChanged: true };
404 405 }
405 406
406 407 const toEquip = singleItemFromStack(taken.taken);
@@ -419,7 +420,8 @@ function equipItem (world, sessionId, command)
419 420 else
420 421 { inventory.slots = taken.slots; }
421 422 equipment.slots[slot] = toEquip;
422 return { events: [], private: bagView(world.ecs, handle), appearanceChanged: true };
423 syncPlayerHealth(world.ecs, handle);
424 return { events: [], private: bagView(world.ecs, handle), appearanceChanged: true, healthChanged: true };
423 425 }
424 426
425 427 function unequipItem (world, sessionId, command)
@@ -439,8 +441,9 @@ function unequipItem (world, sessionId, command)
439 441 { throw userError("Your inventory cannot hold that."); }
440 442 inventory.slots = inserted.slots;
441 443 equipment.slots[command.equipSlot] = null;
444 syncPlayerHealth(world.ecs, handle);
442 445 const appearanceChanged = def?.equipment?.kind !== EquipmentKind.arrowAmmo;
443 return { events: [], private: bagView(world.ecs, handle), appearanceChanged };
446 return { events: [], private: bagView(world.ecs, handle), appearanceChanged, healthChanged: true };
444 447 }
445 448
446 449 function moveInventorySlotCommand (world, sessionId, command)
@@ -400,7 +400,8 @@ function equipItem (world, sessionId, command)
400 }
400 }
401 inventory.slots = slots;
401 inventory.slots = slots;
402 equipment.slots[slot] = taken.taken;
402 equipment.slots[slot] = taken.taken;
403 return { events: [], private: bagView(world.ecs, handle), appearanceChanged: false };
403 syncPlayerHealth(world.ecs, handle);
404 return { events: [], private: bagView(world.ecs, handle), appearanceChanged: false, healthChanged: true };
404 }
405 }
405
406
406 const toEquip = singleItemFromStack(taken.taken);
407 const toEquip = singleItemFromStack(taken.taken);
@@ -419,7 +420,8 @@ function equipItem (world, sessionId, command)
419 else
420 else
420 { inventory.slots = taken.slots; }
421 { inventory.slots = taken.slots; }
421 equipment.slots[slot] = toEquip;
422 equipment.slots[slot] = toEquip;
422 return { events: [], private: bagView(world.ecs, handle), appearanceChanged: true };
423 syncPlayerHealth(world.ecs, handle);
424 return { events: [], private: bagView(world.ecs, handle), appearanceChanged: true, healthChanged: true };
423}
425}
424
426
425function unequipItem (world, sessionId, command)
427function unequipItem (world, sessionId, command)
@@ -439,8 +441,9 @@ function unequipItem (world, sessionId, command)
439 { throw userError("Your inventory cannot hold that."); }
441 { throw userError("Your inventory cannot hold that."); }
440 inventory.slots = inserted.slots;
442 inventory.slots = inserted.slots;
441 equipment.slots[command.equipSlot] = null;
443 equipment.slots[command.equipSlot] = null;
444 syncPlayerHealth(world.ecs, handle);
442 const appearanceChanged = def?.equipment?.kind !== EquipmentKind.arrowAmmo;
445 const appearanceChanged = def?.equipment?.kind !== EquipmentKind.arrowAmmo;
443 return { events: [], private: bagView(world.ecs, handle), appearanceChanged };
446 return { events: [], private: bagView(world.ecs, handle), appearanceChanged, healthChanged: true };
444}
447}
445
448
446function moveInventorySlotCommand (world, sessionId, command)
449function moveInventorySlotCommand (world, sessionId, command)
server/src/shearing/service.js +1 −1
@@ -251,7 +251,7 @@ function completeShear (world, handle, entityId, characterId, session, events, p
251 251 {
252 252 const result = applySkillXp(skills, SkillId.herbalism, 4 + Math.max(1, Math.floor(
253 253 (clothExhaustDurationMs(session.clothTier) / 10_000)
254 )));
254 )), world.ecs.get(handle, Component.equipment));
255 255 if (result.changed)
256 256 { skillsChanged = true; }
257 257 if (result.levelUp)
@@ -251,7 +251,7 @@ function completeShear (world, handle, entityId, characterId, session, events, p
251 {
251 {
252 const result = applySkillXp(skills, SkillId.herbalism, 4 + Math.max(1, Math.floor(
252 const result = applySkillXp(skills, SkillId.herbalism, 4 + Math.max(1, Math.floor(
253 (clothExhaustDurationMs(session.clothTier) / 10_000)
253 (clothExhaustDurationMs(session.clothTier) / 10_000)
254 )));
254 )), world.ecs.get(handle, Component.equipment));
255 if (result.changed)
255 if (result.changed)
256 { skillsChanged = true; }
256 { skillsChanged = true; }
257 if (result.levelUp)
257 if (result.levelUp)
server/src/skills/service.js +12 −6
@@ -2,6 +2,7 @@ import { Component } from "../ecs/components.js";
2 2 import { SkillId, playerMaxHealth, playerMaxStamina } from "../../../shared/definitions/skills.js";
3 3 import { combatDamageXp, spellCastXpFromDifficulty } from "../../../shared/skills/progression.js";
4 4 import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
5 import { maxHealthMultiplier } from "../../../shared/equipment/jewelryEffects.js";
5 6
6 7 export function syncPlayerHealth (ecs, handle)
7 8 {
@@ -12,7 +13,8 @@ export function syncPlayerHealth (ecs, handle)
12 13 const health = ecs.get(handle, Component.health);
13 14 if (!skills || !health)
14 15 { return; }
15 const max = playerMaxHealth(skills);
16 const equipment = ecs.get(handle, Component.equipment);
17 const max = Math.max(1, Math.floor(playerMaxHealth(skills) * maxHealthMultiplier(equipment)));
16 18 health.max = max;
17 19 health.current = Math.min(health.current | 0, max);
18 20 }
@@ -39,11 +41,12 @@ export function awardCombatHitXp (ecs, attackerHandle, profile, damage)
39 41 const skills = ecs.get(attackerHandle, Component.skills);
40 42 if (!skills?.xp)
41 43 { return null; }
44 const equipment = ecs.get(attackerHandle, Component.equipment);
42 45 const levelUps = [];
43 const hit = applySkillXp(skills, profile.hitSkillId, amount);
46 const hit = applySkillXp(skills, profile.hitSkillId, amount, equipment);
44 47 if (hit.levelUp)
45 48 { levelUps.push(hit.levelUp); }
46 const damageSkill = applySkillXp(skills, profile.damageSkillId, amount);
49 const damageSkill = applySkillXp(skills, profile.damageSkillId, amount, equipment);
47 50 if (damageSkill.levelUp)
48 51 { levelUps.push(damageSkill.levelUp); }
49 52 if (!hit.changed && !damageSkill.changed)
@@ -62,7 +65,8 @@ export function awardSpellCastXp (ecs, casterHandle, spellDifficulty)
62 65 const skills = ecs.get(casterHandle, Component.skills);
63 66 if (!skills?.xp)
64 67 { return null; }
65 const result = applySkillXp(skills, SkillId.magic, amount);
68 const equipment = ecs.get(casterHandle, Component.equipment);
69 const result = applySkillXp(skills, SkillId.magic, amount, equipment);
66 70 if (!result.changed)
67 71 { return null; }
68 72 const character = ecs.get(casterHandle, Component.character);
@@ -89,7 +93,8 @@ export function awardDamageHealthXp (ecs, targetHandle, damage)
89 93 const skills = ecs.get(targetHandle, Component.skills);
90 94 if (!skills?.xp)
91 95 { return null; }
92 const result = applySkillXp(skills, SkillId.health, amount);
96 const equipment = ecs.get(targetHandle, Component.equipment);
97 const result = applySkillXp(skills, SkillId.health, amount, equipment);
93 98 if (!result.changed)
94 99 { return null; }
95 100 syncPlayerHealth(ecs, targetHandle);
@@ -113,7 +118,8 @@ export function awardCombatAvoidanceXp (ecs, targetHandle, skillId, avoidedDamag
113 118 const skills = ecs.get(targetHandle, Component.skills);
114 119 if (!skills?.xp)
115 120 { return null; }
116 const result = applySkillXp(skills, skillId, amount);
121 const equipment = ecs.get(targetHandle, Component.equipment);
122 const result = applySkillXp(skills, skillId, amount, equipment);
117 123 if (!result.changed)
118 124 { return null; }
119 125 return {
@@ -2,6 +2,7 @@ import { Component } from "../ecs/components.js";
2import { SkillId, playerMaxHealth, playerMaxStamina } from "../../../shared/definitions/skills.js";
2import { SkillId, playerMaxHealth, playerMaxStamina } from "../../../shared/definitions/skills.js";
3import { combatDamageXp, spellCastXpFromDifficulty } from "../../../shared/skills/progression.js";
3import { combatDamageXp, spellCastXpFromDifficulty } from "../../../shared/skills/progression.js";
4import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
4import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
5import { maxHealthMultiplier } from "../../../shared/equipment/jewelryEffects.js";
5
6
6export function syncPlayerHealth (ecs, handle)
7export function syncPlayerHealth (ecs, handle)
7{
8{
@@ -12,7 +13,8 @@ export function syncPlayerHealth (ecs, handle)
12 const health = ecs.get(handle, Component.health);
13 const health = ecs.get(handle, Component.health);
13 if (!skills || !health)
14 if (!skills || !health)
14 { return; }
15 { return; }
15 const max = playerMaxHealth(skills);
16 const equipment = ecs.get(handle, Component.equipment);
17 const max = Math.max(1, Math.floor(playerMaxHealth(skills) * maxHealthMultiplier(equipment)));
16 health.max = max;
18 health.max = max;
17 health.current = Math.min(health.current | 0, max);
19 health.current = Math.min(health.current | 0, max);
18}
20}
@@ -39,11 +41,12 @@ export function awardCombatHitXp (ecs, attackerHandle, profile, damage)
39 const skills = ecs.get(attackerHandle, Component.skills);
41 const skills = ecs.get(attackerHandle, Component.skills);
40 if (!skills?.xp)
42 if (!skills?.xp)
41 { return null; }
43 { return null; }
44 const equipment = ecs.get(attackerHandle, Component.equipment);
42 const levelUps = [];
45 const levelUps = [];
43 const hit = applySkillXp(skills, profile.hitSkillId, amount);
46 const hit = applySkillXp(skills, profile.hitSkillId, amount, equipment);
44 if (hit.levelUp)
47 if (hit.levelUp)
45 { levelUps.push(hit.levelUp); }
48 { levelUps.push(hit.levelUp); }
46 const damageSkill = applySkillXp(skills, profile.damageSkillId, amount);
49 const damageSkill = applySkillXp(skills, profile.damageSkillId, amount, equipment);
47 if (damageSkill.levelUp)
50 if (damageSkill.levelUp)
48 { levelUps.push(damageSkill.levelUp); }
51 { levelUps.push(damageSkill.levelUp); }
49 if (!hit.changed && !damageSkill.changed)
52 if (!hit.changed && !damageSkill.changed)
@@ -62,7 +65,8 @@ export function awardSpellCastXp (ecs, casterHandle, spellDifficulty)
62 const skills = ecs.get(casterHandle, Component.skills);
65 const skills = ecs.get(casterHandle, Component.skills);
63 if (!skills?.xp)
66 if (!skills?.xp)
64 { return null; }
67 { return null; }
65 const result = applySkillXp(skills, SkillId.magic, amount);
68 const equipment = ecs.get(casterHandle, Component.equipment);
69 const result = applySkillXp(skills, SkillId.magic, amount, equipment);
66 if (!result.changed)
70 if (!result.changed)
67 { return null; }
71 { return null; }
68 const character = ecs.get(casterHandle, Component.character);
72 const character = ecs.get(casterHandle, Component.character);
@@ -89,7 +93,8 @@ export function awardDamageHealthXp (ecs, targetHandle, damage)
89 const skills = ecs.get(targetHandle, Component.skills);
93 const skills = ecs.get(targetHandle, Component.skills);
90 if (!skills?.xp)
94 if (!skills?.xp)
91 { return null; }
95 { return null; }
92 const result = applySkillXp(skills, SkillId.health, amount);
96 const equipment = ecs.get(targetHandle, Component.equipment);
97 const result = applySkillXp(skills, SkillId.health, amount, equipment);
93 if (!result.changed)
98 if (!result.changed)
94 { return null; }
99 { return null; }
95 syncPlayerHealth(ecs, targetHandle);
100 syncPlayerHealth(ecs, targetHandle);
@@ -113,7 +118,8 @@ export function awardCombatAvoidanceXp (ecs, targetHandle, skillId, avoidedDamag
113 const skills = ecs.get(targetHandle, Component.skills);
118 const skills = ecs.get(targetHandle, Component.skills);
114 if (!skills?.xp)
119 if (!skills?.xp)
115 { return null; }
120 { return null; }
116 const result = applySkillXp(skills, skillId, amount);
121 const equipment = ecs.get(targetHandle, Component.equipment);
122 const result = applySkillXp(skills, skillId, amount, equipment);
117 if (!result.changed)
123 if (!result.changed)
118 { return null; }
124 { return null; }
119 return {
125 return {
server/src/spells/service.js +17 −5
@@ -34,6 +34,13 @@ import { rollSpellDamage } from "../../../shared/combat/rolls.js";
34 34 import { mobDefinition } from "../../../shared/definitions/mobs.js";
35 35 import { awardCombatHitXp, awardDamageHealthXp, awardSpellCastXp, syncPlayerHealth } from "../skills/service.js";
36 36 import { equipmentBonusesFromSlots, effectiveSkillLevel } from "../../../shared/equipment/stats.js";
37 import
38 {
39 attackerSpellCastRng,
40 hitSkillBonus,
41 jewelryDamageAffinities,
42 mergeAffinities
43 } from "../../../shared/equipment/jewelryEffects.js";
37 44 import { statusSkillBonuses, applyStatusEffect, emptyStatusEffects, StatusEffectType, publicStatusEffectsView, hasStatusEffect } from "../../../shared/statusEffects/rules.js";
38 45 import
39 46 {
@@ -274,8 +281,9 @@ function casterMagicLevels (ecs, handle, settings = null)
274 281 const bonuses = equipmentBonusesFromSlots(equipment?.slots, settings);
275 282 const status = statusSkillBonuses(ecs.get(handle, Component.statusEffects), Date.now());
276 283 bonuses[SkillId.mind] = (bonuses[SkillId.mind] ?? 0) + (status.mind ?? 0);
284 const hitBonus = hitSkillBonus(equipment);
277 285 return {
278 magic: effectiveSkillLevel(skills, SkillId.magic, bonuses),
286 magic: effectiveSkillLevel(skills, SkillId.magic, bonuses) + hitBonus,
279 287 mind: effectiveSkillLevel(skills, SkillId.mind, bonuses)
280 288 };
281 289 }
@@ -428,9 +436,11 @@ function executeCast (world, sessionId, characterId, spellId, target, now)
428 436
429 437 const levels = casterMagicLevels(world.ecs, handle, world.settings);
430 438 const difficulty = spellDifficulty(def);
439 const equipment = world.ecs.get(handle, Component.equipment);
431 440 const cast = resolveSpellCast({
432 441 magicSkillLevel: levels.magic,
433 spellDifficulty: difficulty
442 spellDifficulty: difficulty,
443 rng: attackerSpellCastRng(equipment)
434 444 });
435 445
436 446 const events = [];
@@ -564,9 +574,11 @@ function targetAffinitiesForEntity (world, entityId)
564 574 if (handle == null)
565 575 { return {}; }
566 576 const creature = world.ecs.get(handle, Component.creature);
567 if (!creature)
568 { return {}; }
569 return mobDamageAffinities(mobDefinition(creature.mobTypeId));
577 const mobAffinities = creature
578 ? mobDamageAffinities(mobDefinition(creature.mobTypeId))
579 : {};
580 const equipment = world.ecs.get(handle, Component.equipment);
581 return mergeAffinities(mobAffinities, jewelryDamageAffinities(equipment));
570 582 }
571 583
572 584 function applySpellImpact (world, impact, now)
@@ -34,6 +34,13 @@ import { rollSpellDamage } from "../../../shared/combat/rolls.js";
34import { mobDefinition } from "../../../shared/definitions/mobs.js";
34import { mobDefinition } from "../../../shared/definitions/mobs.js";
35import { awardCombatHitXp, awardDamageHealthXp, awardSpellCastXp, syncPlayerHealth } from "../skills/service.js";
35import { awardCombatHitXp, awardDamageHealthXp, awardSpellCastXp, syncPlayerHealth } from "../skills/service.js";
36import { equipmentBonusesFromSlots, effectiveSkillLevel } from "../../../shared/equipment/stats.js";
36import { equipmentBonusesFromSlots, effectiveSkillLevel } from "../../../shared/equipment/stats.js";
37import
38{
39 attackerSpellCastRng,
40 hitSkillBonus,
41 jewelryDamageAffinities,
42 mergeAffinities
43} from "../../../shared/equipment/jewelryEffects.js";
37import { statusSkillBonuses, applyStatusEffect, emptyStatusEffects, StatusEffectType, publicStatusEffectsView, hasStatusEffect } from "../../../shared/statusEffects/rules.js";
44import { statusSkillBonuses, applyStatusEffect, emptyStatusEffects, StatusEffectType, publicStatusEffectsView, hasStatusEffect } from "../../../shared/statusEffects/rules.js";
38import
45import
39{
46{
@@ -274,8 +281,9 @@ function casterMagicLevels (ecs, handle, settings = null)
274 const bonuses = equipmentBonusesFromSlots(equipment?.slots, settings);
281 const bonuses = equipmentBonusesFromSlots(equipment?.slots, settings);
275 const status = statusSkillBonuses(ecs.get(handle, Component.statusEffects), Date.now());
282 const status = statusSkillBonuses(ecs.get(handle, Component.statusEffects), Date.now());
276 bonuses[SkillId.mind] = (bonuses[SkillId.mind] ?? 0) + (status.mind ?? 0);
283 bonuses[SkillId.mind] = (bonuses[SkillId.mind] ?? 0) + (status.mind ?? 0);
284 const hitBonus = hitSkillBonus(equipment);
277 return {
285 return {
278 magic: effectiveSkillLevel(skills, SkillId.magic, bonuses),
286 magic: effectiveSkillLevel(skills, SkillId.magic, bonuses) + hitBonus,
279 mind: effectiveSkillLevel(skills, SkillId.mind, bonuses)
287 mind: effectiveSkillLevel(skills, SkillId.mind, bonuses)
280 };
288 };
281}
289}
@@ -428,9 +436,11 @@ function executeCast (world, sessionId, characterId, spellId, target, now)
428
436
429 const levels = casterMagicLevels(world.ecs, handle, world.settings);
437 const levels = casterMagicLevels(world.ecs, handle, world.settings);
430 const difficulty = spellDifficulty(def);
438 const difficulty = spellDifficulty(def);
439 const equipment = world.ecs.get(handle, Component.equipment);
431 const cast = resolveSpellCast({
440 const cast = resolveSpellCast({
432 magicSkillLevel: levels.magic,
441 magicSkillLevel: levels.magic,
433 spellDifficulty: difficulty
442 spellDifficulty: difficulty,
443 rng: attackerSpellCastRng(equipment)
434 });
444 });
435
445
436 const events = [];
446 const events = [];
@@ -564,9 +574,11 @@ function targetAffinitiesForEntity (world, entityId)
564 if (handle == null)
574 if (handle == null)
565 { return {}; }
575 { return {}; }
566 const creature = world.ecs.get(handle, Component.creature);
576 const creature = world.ecs.get(handle, Component.creature);
567 if (!creature)
577 const mobAffinities = creature
568 { return {}; }
578 ? mobDamageAffinities(mobDefinition(creature.mobTypeId))
569 return mobDamageAffinities(mobDefinition(creature.mobTypeId));
579 : {};
580 const equipment = world.ecs.get(handle, Component.equipment);
581 return mergeAffinities(mobAffinities, jewelryDamageAffinities(equipment));
570}
582}
571
583
572function applySpellImpact (world, impact, now)
584function applySpellImpact (world, impact, now)
shared/definitions/items.js +27 −1
@@ -533,7 +533,7 @@ export function itemEquipSprite (itemId)
533 533 return null;
534 534 }
535 535
536 /** Largest equipped light radius (e.g. lantern in offhand). */
536 /** Largest equipped light radius (e.g. lantern in offhand). Includes opal bracelet night vision. */
537 537 export function equippedLightRadiusTiles (equipment)
538 538 {
539 539 let best = 0;
@@ -544,10 +544,36 @@ export function equippedLightRadiusTiles (equipment)
544 544 const radius = itemDefinition(stack.itemId)?.equipment?.lightRadiusTiles ?? 0;
545 545 if (radius > best)
546 546 { best = radius; }
547 // Opal bracelet: same range as a torch (see OPAL_NIGHT_VISION_RANGE_TILES).
548 if ((stack.itemId | 0) === JewelryItemId.opalBracelet)
549 { best = Math.max(best, 8); }
547 550 }
548 551 return best;
549 552 }
550 553
554 /**
555 * Intensity for the entity light from equipment.
556 * Opal bracelet is half-bright when it is the sole (or stronger) light source.
557 */
558 export function equippedLightIntensity (equipment)
559 {
560 let itemLight = 0;
561 let hasOpal = false;
562 for (const stack of Object.values(equipment?.slots ?? {}))
563 {
564 if (!stack)
565 { continue; }
566 const radius = itemDefinition(stack.itemId)?.equipment?.lightRadiusTiles ?? 0;
567 if (radius > itemLight)
568 { itemLight = radius; }
569 if ((stack.itemId | 0) === JewelryItemId.opalBracelet)
570 { hasOpal = true; }
571 }
572 if (hasOpal && itemLight < 8)
573 { return 0.5; }
574 return 1;
575 }
576
551 577 export function letterVisualState (instance)
552 578 {
553 579 return instance?.opened === false ? "letter-closed" : "letter-opened";
@@ -533,7 +533,7 @@ export function itemEquipSprite (itemId)
533 return null;
533 return null;
534}
534}
535
535
536/** Largest equipped light radius (e.g. lantern in offhand). */
536/** Largest equipped light radius (e.g. lantern in offhand). Includes opal bracelet night vision. */
537export function equippedLightRadiusTiles (equipment)
537export function equippedLightRadiusTiles (equipment)
538{
538{
539 let best = 0;
539 let best = 0;
@@ -544,10 +544,36 @@ export function equippedLightRadiusTiles (equipment)
544 const radius = itemDefinition(stack.itemId)?.equipment?.lightRadiusTiles ?? 0;
544 const radius = itemDefinition(stack.itemId)?.equipment?.lightRadiusTiles ?? 0;
545 if (radius > best)
545 if (radius > best)
546 { best = radius; }
546 { best = radius; }
547 // Opal bracelet: same range as a torch (see OPAL_NIGHT_VISION_RANGE_TILES).
548 if ((stack.itemId | 0) === JewelryItemId.opalBracelet)
549 { best = Math.max(best, 8); }
547 }
550 }
548 return best;
551 return best;
549}
552}
550
553
554/**
555 * Intensity for the entity light from equipment.
556 * Opal bracelet is half-bright when it is the sole (or stronger) light source.
557 */
558export function equippedLightIntensity (equipment)
559{
560 let itemLight = 0;
561 let hasOpal = false;
562 for (const stack of Object.values(equipment?.slots ?? {}))
563 {
564 if (!stack)
565 { continue; }
566 const radius = itemDefinition(stack.itemId)?.equipment?.lightRadiusTiles ?? 0;
567 if (radius > itemLight)
568 { itemLight = radius; }
569 if ((stack.itemId | 0) === JewelryItemId.opalBracelet)
570 { hasOpal = true; }
571 }
572 if (hasOpal && itemLight < 8)
573 { return 0.5; }
574 return 1;
575}
576
551export function letterVisualState (instance)
577export function letterVisualState (instance)
552{
578{
553 return instance?.opened === false ? "letter-closed" : "letter-opened";
579 return instance?.opened === false ? "letter-closed" : "letter-opened";
shared/definitions/jewelryItems.js +61 −10
@@ -140,6 +140,51 @@ function pieceDisplayNoun (piece)
140 140 return "amulet";
141 141 }
142 142
143 const JEWELRY_FLAVOR = Object.freeze({
144 [JewelryItemId.tourmalineRing]:
145 "Silver set with tourmaline. While it rests on the finger, wounds close twice as readily when the fighting has stopped.",
146 [JewelryItemId.tourmalineBracelet]:
147 "Silver and tourmaline upon the wrist. Breath and vigour return twice as swiftly when you stand still.",
148 [JewelryItemId.tourmalineAmulet]:
149 "A tourmaline pendant on cotton yarn. It favours the craft you know least, doubling what you learn of it.",
150 [JewelryItemId.alexandriteRing]:
151 "Silver alexandrite that drinks hostile magic. Spells that strike you bite only half as hard.",
152 [JewelryItemId.alexandriteBracelet]:
153 "Alexandrite at the wrist steadies the hand. Work at the bench finishes in half the time.",
154 [JewelryItemId.alexandriteAmulet]:
155 "An alexandrite charm on wool. Ore, timber, plants, and fish yield to you twice as quickly.",
156 [JewelryItemId.opalRing]:
157 "Silver and opal that turn arrows aside. Piercing shots land with half their usual force.",
158 [JewelryItemId.opalBracelet]:
159 "Opal along the wrist. A soft circle of sight opens about you in the dark, as of a dim torch.",
160 [JewelryItemId.opalAmulet]:
161 "An opal pendant on linen. Blows that reach you answer in kind — a tenth of the hurt returns to the striker.",
162 [JewelryItemId.diamondRing]:
163 "Gold and diamond that harden against steel and fist. Melee wounds fall with half their strength.",
164 [JewelryItemId.diamondBracelet]:
165 "A diamond bracelet that grants luck in battle. Blows and castings find their mark more often.",
166 [JewelryItemId.diamondAmulet]:
167 "A diamond on cashmere yarn. Spoils of creatures you fell gather themselves into your pack.",
168 [JewelryItemId.emeraldRing]:
169 "Gold emerald that casts bad luck upon your foes. Their strikes go astray more often than they should.",
170 [JewelryItemId.emeraldBracelet]:
171 "Emerald at the wrist invites divine intervention. Call upon it to seek the nearest altar.",
172 [JewelryItemId.emeraldAmulet]:
173 "An emerald pendant on silk. Blade, bow, and spell alike find the foe a little more readily.",
174 [JewelryItemId.rubyRing]:
175 "Gold and ruby that know the way to coin and vault. Call upon it to seek the nearest bank.",
176 [JewelryItemId.rubyBracelet]:
177 "A ruby bracelet that thickens the blood. While worn, your body endures a tenth more harm.",
178 [JewelryItemId.rubyAmulet]:
179 "A ruby on fairy-silk yarn. In death your coin stays with you — the amulet falls in its place.",
180 [JewelryItemId.jadeiteRing]:
181 "Electrum and jadeite. Nodes you harvest surrender twice the usual yield.",
182 [JewelryItemId.jadeiteBracelet]:
183 "Jadeite at the wrist. All but the fiercest beasts leave you be until you raise a hand against them.",
184 [JewelryItemId.jadeiteAmulet]:
185 "Jadeite on dragonweave. A fairy companion answers the call, fighting those who share your battle."
186 });
187
143 188 function buildPieceDefinitions (piece, byGem)
144 189 {
145 190 const out = {};
@@ -151,12 +196,25 @@ function buildPieceDefinitions (piece, byGem)
151 196 const metalName = MATERIAL_DISPLAY_NAME[metalId] ?? metalId;
152 197 const gemName = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier;
153 198 const noun = pieceDisplayNoun(piece);
199 const equipment = {
200 slot: pieceEquipSlot(piece),
201 tier: gemTier,
202 kind: EquipmentKind.jewelry,
203 minCombatLevel: tierMinSkillLevel(gemTier),
204 tintFromTier: true,
205 dualTintFromTier: true,
206 equipSprite: equipImageName("item", "jewelery", `${piece}-equip`)
207 };
208 if (itemId === JewelryItemId.opalBracelet)
209 {
210 equipment.lightRadiusTiles = 8;
211 equipment.lightIntensity = 0.5;
212 }
154 213 out[itemId] = Object.freeze({
155 214 itemId,
156 215 key: `${gemTier}-${piece}`,
157 216 displayName: `${metalName} ${gemName.toLowerCase()} ${noun}`,
158 /** Filled when unique worn effects are authored. */
159 description: "",
217 description: JEWELRY_FLAVOR[itemId] ?? "",
160 218 seedValue: tierRank(gemTier) * (piece === JewelryPiece.amulet ? 5 : 4),
161 219 stackable: false,
162 220 maxStackSize: 1,
@@ -171,14 +229,7 @@ function buildPieceDefinitions (piece, byGem)
171 229 tintFromTier: true,
172 230 dualTintFromTier: true,
173 231 jewelryTint: true,
174 equipment: Object.freeze({
175 slot: pieceEquipSlot(piece),
176 tier: gemTier,
177 kind: EquipmentKind.jewelry,
178 tintFromTier: true,
179 dualTintFromTier: true,
180 equipSprite: equipImageName("item", "jewelery", `${piece}-equip`)
181 }),
232 equipment: Object.freeze(equipment),
182 233 npcShopAllowed: true
183 234 });
184 235 }
@@ -140,6 +140,51 @@ function pieceDisplayNoun (piece)
140 return "amulet";
140 return "amulet";
141}
141}
142
142
143const JEWELRY_FLAVOR = Object.freeze({
144 [JewelryItemId.tourmalineRing]:
145 "Silver set with tourmaline. While it rests on the finger, wounds close twice as readily when the fighting has stopped.",
146 [JewelryItemId.tourmalineBracelet]:
147 "Silver and tourmaline upon the wrist. Breath and vigour return twice as swiftly when you stand still.",
148 [JewelryItemId.tourmalineAmulet]:
149 "A tourmaline pendant on cotton yarn. It favours the craft you know least, doubling what you learn of it.",
150 [JewelryItemId.alexandriteRing]:
151 "Silver alexandrite that drinks hostile magic. Spells that strike you bite only half as hard.",
152 [JewelryItemId.alexandriteBracelet]:
153 "Alexandrite at the wrist steadies the hand. Work at the bench finishes in half the time.",
154 [JewelryItemId.alexandriteAmulet]:
155 "An alexandrite charm on wool. Ore, timber, plants, and fish yield to you twice as quickly.",
156 [JewelryItemId.opalRing]:
157 "Silver and opal that turn arrows aside. Piercing shots land with half their usual force.",
158 [JewelryItemId.opalBracelet]:
159 "Opal along the wrist. A soft circle of sight opens about you in the dark, as of a dim torch.",
160 [JewelryItemId.opalAmulet]:
161 "An opal pendant on linen. Blows that reach you answer in kind — a tenth of the hurt returns to the striker.",
162 [JewelryItemId.diamondRing]:
163 "Gold and diamond that harden against steel and fist. Melee wounds fall with half their strength.",
164 [JewelryItemId.diamondBracelet]:
165 "A diamond bracelet that grants luck in battle. Blows and castings find their mark more often.",
166 [JewelryItemId.diamondAmulet]:
167 "A diamond on cashmere yarn. Spoils of creatures you fell gather themselves into your pack.",
168 [JewelryItemId.emeraldRing]:
169 "Gold emerald that casts bad luck upon your foes. Their strikes go astray more often than they should.",
170 [JewelryItemId.emeraldBracelet]:
171 "Emerald at the wrist invites divine intervention. Call upon it to seek the nearest altar.",
172 [JewelryItemId.emeraldAmulet]:
173 "An emerald pendant on silk. Blade, bow, and spell alike find the foe a little more readily.",
174 [JewelryItemId.rubyRing]:
175 "Gold and ruby that know the way to coin and vault. Call upon it to seek the nearest bank.",
176 [JewelryItemId.rubyBracelet]:
177 "A ruby bracelet that thickens the blood. While worn, your body endures a tenth more harm.",
178 [JewelryItemId.rubyAmulet]:
179 "A ruby on fairy-silk yarn. In death your coin stays with you — the amulet falls in its place.",
180 [JewelryItemId.jadeiteRing]:
181 "Electrum and jadeite. Nodes you harvest surrender twice the usual yield.",
182 [JewelryItemId.jadeiteBracelet]:
183 "Jadeite at the wrist. All but the fiercest beasts leave you be until you raise a hand against them.",
184 [JewelryItemId.jadeiteAmulet]:
185 "Jadeite on dragonweave. A fairy companion answers the call, fighting those who share your battle."
186});
187
143function buildPieceDefinitions (piece, byGem)
188function buildPieceDefinitions (piece, byGem)
144{
189{
145 const out = {};
190 const out = {};
@@ -151,12 +196,25 @@ function buildPieceDefinitions (piece, byGem)
151 const metalName = MATERIAL_DISPLAY_NAME[metalId] ?? metalId;
196 const metalName = MATERIAL_DISPLAY_NAME[metalId] ?? metalId;
152 const gemName = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier;
197 const gemName = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier;
153 const noun = pieceDisplayNoun(piece);
198 const noun = pieceDisplayNoun(piece);
199 const equipment = {
200 slot: pieceEquipSlot(piece),
201 tier: gemTier,
202 kind: EquipmentKind.jewelry,
203 minCombatLevel: tierMinSkillLevel(gemTier),
204 tintFromTier: true,
205 dualTintFromTier: true,
206 equipSprite: equipImageName("item", "jewelery", `${piece}-equip`)
207 };
208 if (itemId === JewelryItemId.opalBracelet)
209 {
210 equipment.lightRadiusTiles = 8;
211 equipment.lightIntensity = 0.5;
212 }
154 out[itemId] = Object.freeze({
213 out[itemId] = Object.freeze({
155 itemId,
214 itemId,
156 key: `${gemTier}-${piece}`,
215 key: `${gemTier}-${piece}`,
157 displayName: `${metalName} ${gemName.toLowerCase()} ${noun}`,
216 displayName: `${metalName} ${gemName.toLowerCase()} ${noun}`,
158 /** Filled when unique worn effects are authored. */
217 description: JEWELRY_FLAVOR[itemId] ?? "",
159 description: "",
160 seedValue: tierRank(gemTier) * (piece === JewelryPiece.amulet ? 5 : 4),
218 seedValue: tierRank(gemTier) * (piece === JewelryPiece.amulet ? 5 : 4),
161 stackable: false,
219 stackable: false,
162 maxStackSize: 1,
220 maxStackSize: 1,
@@ -171,14 +229,7 @@ function buildPieceDefinitions (piece, byGem)
171 tintFromTier: true,
229 tintFromTier: true,
172 dualTintFromTier: true,
230 dualTintFromTier: true,
173 jewelryTint: true,
231 jewelryTint: true,
174 equipment: Object.freeze({
232 equipment: Object.freeze(equipment),
175 slot: pieceEquipSlot(piece),
176 tier: gemTier,
177 kind: EquipmentKind.jewelry,
178 tintFromTier: true,
179 dualTintFromTier: true,
180 equipSprite: equipImageName("item", "jewelery", `${piece}-equip`)
181 }),
182 npcShopAllowed: true
233 npcShopAllowed: true
183 });
234 });
184 }
235 }
shared/equipment/stats.js +16 −1
@@ -2,6 +2,8 @@ import { SkillId, skillLevel } from "../definitions/skills.js";
2 2 import { tierMinSkillLevel } from "../definitions/materialTiers.js";
3 3 import { EquipmentKind } from "../definitions/equipmentKinds.js";
4 4 import { itemDefinition } from "../definitions/items.js";
5 import { combatLevelFromSkills } from "../combat/combatLevel.js";
6 import { jewelryMinCombatLevel } from "./jewelryEffects.js";
5 7 import {
6 8 bonusForEquippedItem,
7 9 defaultEquipmentStatBonuses
@@ -40,7 +42,7 @@ export function equipMinSkillId (equipmentDef)
40 42 case EquipmentKind.shears:
41 43 return SkillId.herbalism;
42 44 case EquipmentKind.jewelry:
43 return SkillId.jewelering;
45 return null;
44 46 default:
45 47 return null;
46 48 }
@@ -79,6 +81,19 @@ export function canEquipItem (skills, itemDef)
79 81 const equipment = itemDef?.equipment;
80 82 if (!equipment)
81 83 { return { ok: false, reason: "That item cannot be equipped." }; }
84 if (equipment.kind === EquipmentKind.jewelry)
85 {
86 const required = jewelryMinCombatLevel(itemDef) ?? tierMinSkillLevel(equipment.tier);
87 const level = combatLevelFromSkills(skills);
88 if (level < required)
89 {
90 return {
91 ok: false,
92 reason: `Requires combat level ${required}.`
93 };
94 }
95 return { ok: true };
96 }
82 97 const minSkillId = equipMinSkillId(equipment);
83 98 if (!minSkillId)
84 99 { return { ok: true }; }
@@ -2,6 +2,8 @@ import { SkillId, skillLevel } from "../definitions/skills.js";
2import { tierMinSkillLevel } from "../definitions/materialTiers.js";
2import { tierMinSkillLevel } from "../definitions/materialTiers.js";
3import { EquipmentKind } from "../definitions/equipmentKinds.js";
3import { EquipmentKind } from "../definitions/equipmentKinds.js";
4import { itemDefinition } from "../definitions/items.js";
4import { itemDefinition } from "../definitions/items.js";
5import { combatLevelFromSkills } from "../combat/combatLevel.js";
6import { jewelryMinCombatLevel } from "./jewelryEffects.js";
5import {
7import {
6 bonusForEquippedItem,
8 bonusForEquippedItem,
7 defaultEquipmentStatBonuses
9 defaultEquipmentStatBonuses
@@ -40,7 +42,7 @@ export function equipMinSkillId (equipmentDef)
40 case EquipmentKind.shears:
42 case EquipmentKind.shears:
41 return SkillId.herbalism;
43 return SkillId.herbalism;
42 case EquipmentKind.jewelry:
44 case EquipmentKind.jewelry:
43 return SkillId.jewelering;
45 return null;
44 default:
46 default:
45 return null;
47 return null;
46 }
48 }
@@ -79,6 +81,19 @@ export function canEquipItem (skills, itemDef)
79 const equipment = itemDef?.equipment;
81 const equipment = itemDef?.equipment;
80 if (!equipment)
82 if (!equipment)
81 { return { ok: false, reason: "That item cannot be equipped." }; }
83 { return { ok: false, reason: "That item cannot be equipped." }; }
84 if (equipment.kind === EquipmentKind.jewelry)
85 {
86 const required = jewelryMinCombatLevel(itemDef) ?? tierMinSkillLevel(equipment.tier);
87 const level = combatLevelFromSkills(skills);
88 if (level < required)
89 {
90 return {
91 ok: false,
92 reason: `Requires combat level ${required}.`
93 };
94 }
95 return { ok: true };
96 }
82 const minSkillId = equipMinSkillId(equipment);
97 const minSkillId = equipMinSkillId(equipment);
83 if (!minSkillId)
98 if (!minSkillId)
84 { return { ok: true }; }
99 { return { ok: true }; }
shared/skills/levelUpUnlocks.js +1 −1
@@ -151,7 +151,7 @@ function buildUnlockCatalog ()
151 151 const cut = tierSmeltSkillLevel(gem);
152 152 const equip = tierMinSkillLevel(gem);
153 153 add(SkillId.jewelering, cut, `You can now cut ${name}.`);
154 add(SkillId.jewelering, equip, `You can now craft ${name} jewellery.`);
154 add(SkillId.jewelering, equip, `You can now craft ${name} jewellery (wearable at combat level ${equip}).`);
155 155 }
156 156
157 157 /** @type {Map<number, string[]>} */
@@ -151,7 +151,7 @@ function buildUnlockCatalog ()
151 const cut = tierSmeltSkillLevel(gem);
151 const cut = tierSmeltSkillLevel(gem);
152 const equip = tierMinSkillLevel(gem);
152 const equip = tierMinSkillLevel(gem);
153 add(SkillId.jewelering, cut, `You can now cut ${name}.`);
153 add(SkillId.jewelering, cut, `You can now cut ${name}.`);
154 add(SkillId.jewelering, equip, `You can now craft ${name} jewellery.`);
154 add(SkillId.jewelering, equip, `You can now craft ${name} jewellery (wearable at combat level ${equip}).`);
155 }
155 }
156
156
157 /** @type {Map<number, string[]>} */
157 /** @type {Map<number, string[]>} */
shared/skills/state.js +5 −2
@@ -1,6 +1,7 @@
1 1 import { SkillId, SKILL_DEFINITIONS, ALL_SKILL_IDS, DEFAULT_PLAYER_SKILL_LEVELS } from "../definitions/skills.js";
2 2 import { combatLevelFromSkills } from "../combat/combatLevel.js";
3 3 import { maxTotalSkillXp, totalXpForLevel, xpProgress, MAX_SKILL_LEVEL } from "./progression.js";
4 import { skillXpMultiplier } from "../equipment/jewelryEffects.js";
4 5
5 6 /** Health starts at level 5; Stamina at 5; other skills at level 1. */
6 7 export const STARTING_HEALTH_XP = totalXpForLevel(DEFAULT_PLAYER_SKILL_LEVELS[SkillId.health] ?? 5);
@@ -90,13 +91,15 @@ export function skillLevelUpPayload (skillId, level, previousLevel = null)
90 91 }
91 92
92 93 /** Apply XP and report whether the skill leveled up. */
93 export function applySkillXp (skillsComponent, skillId, amount)
94 export function applySkillXp (skillsComponent, skillId, amount, equipment = null)
94 95 {
95 96 if (!skillsComponent?.xp)
96 97 { return { changed: false, levelUp: null }; }
98 const mult = skillXpMultiplier(equipment, skillsComponent, skillId);
99 const adjusted = Math.max(0, Math.floor((Number(amount) || 0) * mult));
97 100 const before = skillsComponent.xp[skillId] ?? 0;
98 101 const beforeLevel = xpProgress(before).level;
99 const changed = addSkillXp(skillsComponent, skillId, amount);
102 const changed = addSkillXp(skillsComponent, skillId, adjusted);
100 103 if (!changed)
101 104 { return { changed: false, levelUp: null }; }
102 105 const afterLevel = xpProgress(skillsComponent.xp[skillId] ?? 0).level;
@@ -1,6 +1,7 @@
1import { SkillId, SKILL_DEFINITIONS, ALL_SKILL_IDS, DEFAULT_PLAYER_SKILL_LEVELS } from "../definitions/skills.js";
1import { SkillId, SKILL_DEFINITIONS, ALL_SKILL_IDS, DEFAULT_PLAYER_SKILL_LEVELS } from "../definitions/skills.js";
2import { combatLevelFromSkills } from "../combat/combatLevel.js";
2import { combatLevelFromSkills } from "../combat/combatLevel.js";
3import { maxTotalSkillXp, totalXpForLevel, xpProgress, MAX_SKILL_LEVEL } from "./progression.js";
3import { maxTotalSkillXp, totalXpForLevel, xpProgress, MAX_SKILL_LEVEL } from "./progression.js";
4import { skillXpMultiplier } from "../equipment/jewelryEffects.js";
4
5
5/** Health starts at level 5; Stamina at 5; other skills at level 1. */
6/** Health starts at level 5; Stamina at 5; other skills at level 1. */
6export const STARTING_HEALTH_XP = totalXpForLevel(DEFAULT_PLAYER_SKILL_LEVELS[SkillId.health] ?? 5);
7export const STARTING_HEALTH_XP = totalXpForLevel(DEFAULT_PLAYER_SKILL_LEVELS[SkillId.health] ?? 5);
@@ -90,13 +91,15 @@ export function skillLevelUpPayload (skillId, level, previousLevel = null)
90}
91}
91
92
92/** Apply XP and report whether the skill leveled up. */
93/** Apply XP and report whether the skill leveled up. */
93export function applySkillXp (skillsComponent, skillId, amount)
94export function applySkillXp (skillsComponent, skillId, amount, equipment = null)
94{
95{
95 if (!skillsComponent?.xp)
96 if (!skillsComponent?.xp)
96 { return { changed: false, levelUp: null }; }
97 { return { changed: false, levelUp: null }; }
98 const mult = skillXpMultiplier(equipment, skillsComponent, skillId);
99 const adjusted = Math.max(0, Math.floor((Number(amount) || 0) * mult));
97 const before = skillsComponent.xp[skillId] ?? 0;
100 const before = skillsComponent.xp[skillId] ?? 0;
98 const beforeLevel = xpProgress(before).level;
101 const beforeLevel = xpProgress(before).level;
99 const changed = addSkillXp(skillsComponent, skillId, amount);
102 const changed = addSkillXp(skillsComponent, skillId, adjusted);
100 if (!changed)
103 if (!changed)
101 { return { changed: false, levelUp: null }; }
104 { return { changed: false, levelUp: null }; }
102 const afterLevel = xpProgress(skillsComponent.xp[skillId] ?? 0).level;
105 const afterLevel = xpProgress(skillsComponent.xp[skillId] ?? 0).level;