BlueGit

timfa questward

Align spell Magic gates with the seven-tier skill curve.

Unlock toasts and spawner/editor gates now use the same 1/10/20/35/50/70/90 thresholds as gear instead of per-tier level numbers.

timfa Tim Falken · pushed by timfa

Authored 2026-08-30 · 2 months ago

Hash
7ed79f4ee97853cca0bcb9a87202a9827ee7dc3f
Parent
9b426a49
7 files changed +65 −32
client/src/editor/tileConfigModal.js +3 −3
@@ -11,7 +11,7 @@ import
11 11 spawnerEquipmentSlot
12 12 } from "/shared/definitions/mobs.js";
13 13 import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";
14 import { SPELL_DEFINITIONS } from "/shared/definitions/spells.js";
14 import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";
15 15 import { centralExchangeStaffCount } from "/shared/market/exchange.js";
16 16 import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";
17 17 import { listRawFishPickerEntries, normalizeFishingSpotConfig, fishTierRankFromItemId } from "/shared/definitions/fishItems.js";
@@ -888,7 +888,7 @@ export function initTileConfigModal ({
888 888 { continue; }
889 889 const opt = document.createElement("option");
890 890 opt.value = spell.spellId;
891 const minLv = spell.minMagicLevel | 0 || 1;
891 const minLv = spellMinMagicLevel(spell);
892 892 opt.textContent = `${spell.displayName} (Magic ${minLv}+)`;
893 893 if (spell.spellId === line.spellId)
894 894 { opt.selected = true; }
@@ -900,7 +900,7 @@ export function initTileConfigModal ({
900 900 renderSpellsList();
901 901 });
902 902
903 const minLv = def?.minMagicLevel | 0 || 1;
903 const minLv = spellMinMagicLevel(def);
904 904 const tier = def?.tier | 0 || 1;
905 905 const successPct = spellCastSuccessChancePercent(level, tier);
906 906 const chanceLabel = document.createElement("span");
@@ -11,7 +11,7 @@ import
11 spawnerEquipmentSlot
11 spawnerEquipmentSlot
12} from "/shared/definitions/mobs.js";
12} from "/shared/definitions/mobs.js";
13import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";
13import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";
14import { SPELL_DEFINITIONS } from "/shared/definitions/spells.js";
14import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";
15import { centralExchangeStaffCount } from "/shared/market/exchange.js";
15import { centralExchangeStaffCount } from "/shared/market/exchange.js";
16import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";
16import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";
17import { listRawFishPickerEntries, normalizeFishingSpotConfig, fishTierRankFromItemId } from "/shared/definitions/fishItems.js";
17import { listRawFishPickerEntries, normalizeFishingSpotConfig, fishTierRankFromItemId } from "/shared/definitions/fishItems.js";
@@ -888,7 +888,7 @@ export function initTileConfigModal ({
888 { continue; }
888 { continue; }
889 const opt = document.createElement("option");
889 const opt = document.createElement("option");
890 opt.value = spell.spellId;
890 opt.value = spell.spellId;
891 const minLv = spell.minMagicLevel | 0 || 1;
891 const minLv = spellMinMagicLevel(spell);
892 opt.textContent = `${spell.displayName} (Magic ${minLv}+)`;
892 opt.textContent = `${spell.displayName} (Magic ${minLv}+)`;
893 if (spell.spellId === line.spellId)
893 if (spell.spellId === line.spellId)
894 { opt.selected = true; }
894 { opt.selected = true; }
@@ -900,7 +900,7 @@ export function initTileConfigModal ({
900 renderSpellsList();
900 renderSpellsList();
901 });
901 });
902
902
903 const minLv = def?.minMagicLevel | 0 || 1;
903 const minLv = spellMinMagicLevel(def);
904 const tier = def?.tier | 0 || 1;
904 const tier = def?.tier | 0 || 1;
905 const successPct = spellCastSuccessChancePercent(level, tier);
905 const successPct = spellCastSuccessChancePercent(level, tier);
906 const chanceLabel = document.createElement("span");
906 const chanceLabel = document.createElement("span");
server/src/simulation/spawners.js +2 −2
@@ -17,7 +17,7 @@ import
17 17 isTownGuardMob,
18 18 isHumanoidMob
19 19 } from "../../../shared/definitions/mobs.js";
20 import { spellDefinition, SPRITE_BOLT_SPELL_BY_ELEMENT } from "../../../shared/definitions/spells.js";
20 import { spellDefinition, spellMinMagicLevel, SPRITE_BOLT_SPELL_BY_ELEMENT } from "../../../shared/definitions/spells.js";
21 21 import { MAGIC_ELEMENT_ORDER, magicElementTint } from "../../../shared/definitions/attackTypes.js";
22 22 import { essenceElementDisplayName } from "../../../shared/definitions/essenceItems.js";
23 23 import { LeatherItemId } from "../../../shared/definitions/leatherItems.js";
@@ -419,7 +419,7 @@ function normalizeMobSpells (raw, level)
419 419 const def = spellDefinition(spellId);
420 420 if (!def)
421 421 { continue; }
422 const minLevel = Math.max(1, def.minMagicLevel | 0 || 1);
422 const minLevel = spellMinMagicLevel(def);
423 423 if (lv < minLevel)
424 424 { continue; }
425 425 seen.add(spellId);
@@ -17,7 +17,7 @@ import
17 isTownGuardMob,
17 isTownGuardMob,
18 isHumanoidMob
18 isHumanoidMob
19 } from "../../../shared/definitions/mobs.js";
19 } from "../../../shared/definitions/mobs.js";
20import { spellDefinition, SPRITE_BOLT_SPELL_BY_ELEMENT } from "../../../shared/definitions/spells.js";
20import { spellDefinition, spellMinMagicLevel, SPRITE_BOLT_SPELL_BY_ELEMENT } from "../../../shared/definitions/spells.js";
21import { MAGIC_ELEMENT_ORDER, magicElementTint } from "../../../shared/definitions/attackTypes.js";
21import { MAGIC_ELEMENT_ORDER, magicElementTint } from "../../../shared/definitions/attackTypes.js";
22import { essenceElementDisplayName } from "../../../shared/definitions/essenceItems.js";
22import { essenceElementDisplayName } from "../../../shared/definitions/essenceItems.js";
23import { LeatherItemId } from "../../../shared/definitions/leatherItems.js";
23import { LeatherItemId } from "../../../shared/definitions/leatherItems.js";
@@ -419,7 +419,7 @@ function normalizeMobSpells (raw, level)
419 const def = spellDefinition(spellId);
419 const def = spellDefinition(spellId);
420 if (!def)
420 if (!def)
421 { continue; }
421 { continue; }
422 const minLevel = Math.max(1, def.minMagicLevel | 0 || 1);
422 const minLevel = spellMinMagicLevel(def);
423 if (lv < minLevel)
423 if (lv < minLevel)
424 { continue; }
424 { continue; }
425 seen.add(spellId);
425 seen.add(spellId);
server/tests/level-up-unlocks.test.js +10 −0
@@ -47,6 +47,16 @@ test("multi-level jump reports unlocks for every crossed gate", () =>
47 47 assert.ok(lines.some((line) => /equip Iron axes/i.test(line)));
48 48 });
49 49
50 test("magic unlocks use tier skill gates, not every level", () =>
51 {
52 assert.deepEqual(skillUnlockMessages(SkillId.magic, 2, 3), []);
53 const atTen = skillUnlockMessages(SkillId.magic, 9, 10);
54 assert.ok(atTen.some((line) => /cast Dark/i.test(line) || /Birch staves/i.test(line)));
55 const atTwenty = skillUnlockMessages(SkillId.magic, 19, 20);
56 assert.ok(atTwenty.some((line) => /tier 3|Firebolt|Poison|Tinders/i.test(line)));
57 assert.equal(skillUnlockMessages(SkillId.magic, 3, 4).filter((l) => /cast/i.test(l)).length, 0);
58 });
59
50 60 test("applySkillXp includes previousLevel on level-up", () =>
51 61 {
52 62 const skills = normalizePlayerSkills(null);
@@ -47,6 +47,16 @@ test("multi-level jump reports unlocks for every crossed gate", () =>
47 assert.ok(lines.some((line) => /equip Iron axes/i.test(line)));
47 assert.ok(lines.some((line) => /equip Iron axes/i.test(line)));
48});
48});
49
49
50test("magic unlocks use tier skill gates, not every level", () =>
51{
52 assert.deepEqual(skillUnlockMessages(SkillId.magic, 2, 3), []);
53 const atTen = skillUnlockMessages(SkillId.magic, 9, 10);
54 assert.ok(atTen.some((line) => /cast Dark/i.test(line) || /Birch staves/i.test(line)));
55 const atTwenty = skillUnlockMessages(SkillId.magic, 19, 20);
56 assert.ok(atTwenty.some((line) => /tier 3|Firebolt|Poison|Tinders/i.test(line)));
57 assert.equal(skillUnlockMessages(SkillId.magic, 3, 4).filter((l) => /cast/i.test(l)).length, 0);
58});
59
50test("applySkillXp includes previousLevel on level-up", () =>
60test("applySkillXp includes previousLevel on level-up", () =>
51{
61{
52 const skills = normalizePlayerSkills(null);
62 const skills = normalizePlayerSkills(null);
server/tests/spawner-bounty.test.js +8 −8
@@ -113,7 +113,7 @@ test("mob components use spawner level for skills, HP, bounty origin, and spells
113 113 originTileX: 8,
114 114 originTileY: 8,
115 115 wanderRangeTiles: 6,
116 level: 4,
116 level: 20,
117 117 bounty: 12,
118 118 displayName: "Captain",
119 119 sex: "male",
@@ -122,17 +122,17 @@ test("mob components use spawner level for skills, HP, bounty origin, and spells
122 122 { spellId: SpellId.light }
123 123 ]
124 124 });
125 assert.equal(components.creature.level, 4);
126 assert.equal(components.health.max, 14);
127 assert.equal(components.health.current, 14);
128 assert.equal(components.skills.levels[SkillId.magic], 4);
129 assert.equal(components.skills.levels[SkillId.unarmed], 4);
125 assert.equal(components.creature.level, 20);
126 assert.equal(components.health.max, 30);
127 assert.equal(components.health.current, 30);
128 assert.equal(components.skills.levels[SkillId.magic], 20);
129 assert.equal(components.skills.levels[SkillId.unarmed], 20);
130 130 assert.equal(components.spawnOrigin.bounty, 12);
131 131 assert.equal(components.spawnOrigin.townGuard, true);
132 132 assert.ok(components.spells.known.includes(SpellId.firebolt));
133 133 assert.ok(components.spells.known.includes(SpellId.light));
134 assert.equal(components.spells.castChances[SpellId.firebolt], mobSpellCastChancePercent(4));
135 assert.equal(components.spells.castChances[SpellId.light], mobSpellCastChancePercent(4));
134 assert.equal(components.spells.castChances[SpellId.firebolt], mobSpellCastChancePercent(20));
135 assert.equal(components.spells.castChances[SpellId.light], mobSpellCastChancePercent(20));
136 136 });
137 137
138 138 test("mobs below spell minMagicLevel do not learn the spell", () =>
@@ -113,7 +113,7 @@ test("mob components use spawner level for skills, HP, bounty origin, and spells
113 originTileX: 8,
113 originTileX: 8,
114 originTileY: 8,
114 originTileY: 8,
115 wanderRangeTiles: 6,
115 wanderRangeTiles: 6,
116 level: 4,
116 level: 20,
117 bounty: 12,
117 bounty: 12,
118 displayName: "Captain",
118 displayName: "Captain",
119 sex: "male",
119 sex: "male",
@@ -122,17 +122,17 @@ test("mob components use spawner level for skills, HP, bounty origin, and spells
122 { spellId: SpellId.light }
122 { spellId: SpellId.light }
123 ]
123 ]
124 });
124 });
125 assert.equal(components.creature.level, 4);
125 assert.equal(components.creature.level, 20);
126 assert.equal(components.health.max, 14);
126 assert.equal(components.health.max, 30);
127 assert.equal(components.health.current, 14);
127 assert.equal(components.health.current, 30);
128 assert.equal(components.skills.levels[SkillId.magic], 4);
128 assert.equal(components.skills.levels[SkillId.magic], 20);
129 assert.equal(components.skills.levels[SkillId.unarmed], 4);
129 assert.equal(components.skills.levels[SkillId.unarmed], 20);
130 assert.equal(components.spawnOrigin.bounty, 12);
130 assert.equal(components.spawnOrigin.bounty, 12);
131 assert.equal(components.spawnOrigin.townGuard, true);
131 assert.equal(components.spawnOrigin.townGuard, true);
132 assert.ok(components.spells.known.includes(SpellId.firebolt));
132 assert.ok(components.spells.known.includes(SpellId.firebolt));
133 assert.ok(components.spells.known.includes(SpellId.light));
133 assert.ok(components.spells.known.includes(SpellId.light));
134 assert.equal(components.spells.castChances[SpellId.firebolt], mobSpellCastChancePercent(4));
134 assert.equal(components.spells.castChances[SpellId.firebolt], mobSpellCastChancePercent(20));
135 assert.equal(components.spells.castChances[SpellId.light], mobSpellCastChancePercent(4));
135 assert.equal(components.spells.castChances[SpellId.light], mobSpellCastChancePercent(20));
136});
136});
137
137
138test("mobs below spell minMagicLevel do not learn the spell", () =>
138test("mobs below spell minMagicLevel do not learn the spell", () =>
shared/definitions/spells.js +31 −9
@@ -1,5 +1,5 @@
1 1 import { spellDifficultyFromTier } from "../spells/constants.js";
2 import { MATERIAL_TIER_ORDER, tierStatBonus } from "./materialTiers.js";
2 import { MATERIAL_TIER_ORDER, tierStatBonus, tierMinSkillLevel } from "./materialTiers.js";
3 3 import { MagicElement } from "./attackTypes.js";
4 4
5 5 /**
@@ -305,6 +305,28 @@ const ELEMENT_DAMAGE_TREES = Object.freeze([
305 305 })
306 306 ]);
307 307
308 /**
309 * Minimum Magic skill to cast a spell of this tier — same 7-gate curve as gear
310 * (1 / 10 / 20 / 35 / 50 / 70 / 90).
311 * @param {number} tier
312 */
313 export function spellMinMagicLevelFromTier (tier)
314 {
315 const rank = Math.max(1, Math.min(MATERIAL_TIER_ORDER.length, Math.floor(Number(tier) || 1)));
316 return tierMinSkillLevel(MATERIAL_TIER_ORDER[rank - 1]);
317 }
318
319 /**
320 * Authoritative Magic level gate for a spell def (explicit min or tier curve).
321 * @param {SpellDefinition|null|undefined} spellDef
322 */
323 export function spellMinMagicLevel (spellDef)
324 {
325 if (spellDef?.minMagicLevel != null)
326 { return Math.max(1, spellDef.minMagicLevel | 0); }
327 return spellMinMagicLevelFromTier(spellDef?.tier ?? 1);
328 }
329
308 330 function buildDamageTreeDefinitions ()
309 331 {
310 332 const out = {};
@@ -320,7 +342,7 @@ function buildDamageTreeDefinitions ()
320 342 element: tree.element,
321 343 target: "entity",
322 344 autoRepeat: true,
323 minMagicLevel: tier,
345 minMagicLevel: spellMinMagicLevelFromTier(tier),
324 346 projectileSprite: BOLT_PROJECTILE,
325 347 effect: "damage",
326 348 damageTree: true,
@@ -340,7 +362,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
340 362 element: "none",
341 363 target: "tile",
342 364 autoRepeat: false,
343 minMagicLevel: 1,
365 minMagicLevel: spellMinMagicLevelFromTier(1),
344 366 starter: true,
345 367 projectileSprite: LIGHT_PROJECTILE,
346 368 effect: "light",
@@ -353,7 +375,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
353 375 element: MagicElement.dark,
354 376 target: "tile",
355 377 autoRepeat: false,
356 minMagicLevel: 2,
378 minMagicLevel: spellMinMagicLevelFromTier(2),
357 379 projectileSprite: LIGHT_PROJECTILE,
358 380 effect: "dark",
359 381 description: "A pool of shadow that drinks the light from a place, leaving the air thick and dim."
@@ -366,7 +388,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
366 388 element: MagicElement.earth,
367 389 target: "entity",
368 390 autoRepeat: true,
369 minMagicLevel: 3,
391 minMagicLevel: spellMinMagicLevelFromTier(3),
370 392 projectileSprite: BOLT_PROJECTILE,
371 393 effect: "poison",
372 394 description: "A venomous curse that sinks in without a wound, then eats at the body over time."
@@ -378,7 +400,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
378 400 element: MagicElement.dark,
379 401 target: "entity",
380 402 autoRepeat: true,
381 minMagicLevel: 4,
403 minMagicLevel: spellMinMagicLevelFromTier(4),
382 404 projectileSprite: LIGHT_PROJECTILE,
383 405 effect: "drain",
384 406 description: "A hunger that saps a foe's wind, leaving them gasping and slow to recover."
@@ -390,7 +412,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
390 412 element: MagicElement.fire,
391 413 target: "tile",
392 414 autoRepeat: false,
393 minMagicLevel: 3,
415 minMagicLevel: spellMinMagicLevelFromTier(3),
394 416 projectileSprite: BOLT_PROJECTILE,
395 417 effect: "tinders",
396 418 description: "Sparks of will that can coax logs into flame or sear raw meat as a cookfire would."
@@ -402,7 +424,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
402 424 element: MagicElement.dark,
403 425 target: "tile",
404 426 autoRepeat: false,
405 minMagicLevel: 6,
427 minMagicLevel: spellMinMagicLevelFromTier(6),
406 428 projectileSprite: LIGHT_PROJECTILE,
407 429 effect: "shade",
408 430 description: "A summoned shadow that fights beside you until the magic frays."
@@ -414,7 +436,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
414 436 element: "holy",
415 437 target: "entity",
416 438 autoRepeat: false,
417 minMagicLevel: 5,
439 minMagicLevel: spellMinMagicLevelFromTier(5),
418 440 projectileSprite: LIGHT_PROJECTILE,
419 441 effect: "revitalize",
420 442 description: "A gentle current of life that mends wounds one breath at a time."
@@ -1,5 +1,5 @@
1import { spellDifficultyFromTier } from "../spells/constants.js";
1import { spellDifficultyFromTier } from "../spells/constants.js";
2import { MATERIAL_TIER_ORDER, tierStatBonus } from "./materialTiers.js";
2import { MATERIAL_TIER_ORDER, tierStatBonus, tierMinSkillLevel } from "./materialTiers.js";
3import { MagicElement } from "./attackTypes.js";
3import { MagicElement } from "./attackTypes.js";
4
4
5/**
5/**
@@ -305,6 +305,28 @@ const ELEMENT_DAMAGE_TREES = Object.freeze([
305 })
305 })
306]);
306]);
307
307
308/**
309 * Minimum Magic skill to cast a spell of this tier — same 7-gate curve as gear
310 * (1 / 10 / 20 / 35 / 50 / 70 / 90).
311 * @param {number} tier
312 */
313export function spellMinMagicLevelFromTier (tier)
314{
315 const rank = Math.max(1, Math.min(MATERIAL_TIER_ORDER.length, Math.floor(Number(tier) || 1)));
316 return tierMinSkillLevel(MATERIAL_TIER_ORDER[rank - 1]);
317}
318
319/**
320 * Authoritative Magic level gate for a spell def (explicit min or tier curve).
321 * @param {SpellDefinition|null|undefined} spellDef
322 */
323export function spellMinMagicLevel (spellDef)
324{
325 if (spellDef?.minMagicLevel != null)
326 { return Math.max(1, spellDef.minMagicLevel | 0); }
327 return spellMinMagicLevelFromTier(spellDef?.tier ?? 1);
328}
329
308function buildDamageTreeDefinitions ()
330function buildDamageTreeDefinitions ()
309{
331{
310 const out = {};
332 const out = {};
@@ -320,7 +342,7 @@ function buildDamageTreeDefinitions ()
320 element: tree.element,
342 element: tree.element,
321 target: "entity",
343 target: "entity",
322 autoRepeat: true,
344 autoRepeat: true,
323 minMagicLevel: tier,
345 minMagicLevel: spellMinMagicLevelFromTier(tier),
324 projectileSprite: BOLT_PROJECTILE,
346 projectileSprite: BOLT_PROJECTILE,
325 effect: "damage",
347 effect: "damage",
326 damageTree: true,
348 damageTree: true,
@@ -340,7 +362,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
340 element: "none",
362 element: "none",
341 target: "tile",
363 target: "tile",
342 autoRepeat: false,
364 autoRepeat: false,
343 minMagicLevel: 1,
365 minMagicLevel: spellMinMagicLevelFromTier(1),
344 starter: true,
366 starter: true,
345 projectileSprite: LIGHT_PROJECTILE,
367 projectileSprite: LIGHT_PROJECTILE,
346 effect: "light",
368 effect: "light",
@@ -353,7 +375,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
353 element: MagicElement.dark,
375 element: MagicElement.dark,
354 target: "tile",
376 target: "tile",
355 autoRepeat: false,
377 autoRepeat: false,
356 minMagicLevel: 2,
378 minMagicLevel: spellMinMagicLevelFromTier(2),
357 projectileSprite: LIGHT_PROJECTILE,
379 projectileSprite: LIGHT_PROJECTILE,
358 effect: "dark",
380 effect: "dark",
359 description: "A pool of shadow that drinks the light from a place, leaving the air thick and dim."
381 description: "A pool of shadow that drinks the light from a place, leaving the air thick and dim."
@@ -366,7 +388,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
366 element: MagicElement.earth,
388 element: MagicElement.earth,
367 target: "entity",
389 target: "entity",
368 autoRepeat: true,
390 autoRepeat: true,
369 minMagicLevel: 3,
391 minMagicLevel: spellMinMagicLevelFromTier(3),
370 projectileSprite: BOLT_PROJECTILE,
392 projectileSprite: BOLT_PROJECTILE,
371 effect: "poison",
393 effect: "poison",
372 description: "A venomous curse that sinks in without a wound, then eats at the body over time."
394 description: "A venomous curse that sinks in without a wound, then eats at the body over time."
@@ -378,7 +400,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
378 element: MagicElement.dark,
400 element: MagicElement.dark,
379 target: "entity",
401 target: "entity",
380 autoRepeat: true,
402 autoRepeat: true,
381 minMagicLevel: 4,
403 minMagicLevel: spellMinMagicLevelFromTier(4),
382 projectileSprite: LIGHT_PROJECTILE,
404 projectileSprite: LIGHT_PROJECTILE,
383 effect: "drain",
405 effect: "drain",
384 description: "A hunger that saps a foe's wind, leaving them gasping and slow to recover."
406 description: "A hunger that saps a foe's wind, leaving them gasping and slow to recover."
@@ -390,7 +412,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
390 element: MagicElement.fire,
412 element: MagicElement.fire,
391 target: "tile",
413 target: "tile",
392 autoRepeat: false,
414 autoRepeat: false,
393 minMagicLevel: 3,
415 minMagicLevel: spellMinMagicLevelFromTier(3),
394 projectileSprite: BOLT_PROJECTILE,
416 projectileSprite: BOLT_PROJECTILE,
395 effect: "tinders",
417 effect: "tinders",
396 description: "Sparks of will that can coax logs into flame or sear raw meat as a cookfire would."
418 description: "Sparks of will that can coax logs into flame or sear raw meat as a cookfire would."
@@ -402,7 +424,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
402 element: MagicElement.dark,
424 element: MagicElement.dark,
403 target: "tile",
425 target: "tile",
404 autoRepeat: false,
426 autoRepeat: false,
405 minMagicLevel: 6,
427 minMagicLevel: spellMinMagicLevelFromTier(6),
406 projectileSprite: LIGHT_PROJECTILE,
428 projectileSprite: LIGHT_PROJECTILE,
407 effect: "shade",
429 effect: "shade",
408 description: "A summoned shadow that fights beside you until the magic frays."
430 description: "A summoned shadow that fights beside you until the magic frays."
@@ -414,7 +436,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
414 element: "holy",
436 element: "holy",
415 target: "entity",
437 target: "entity",
416 autoRepeat: false,
438 autoRepeat: false,
417 minMagicLevel: 5,
439 minMagicLevel: spellMinMagicLevelFromTier(5),
418 projectileSprite: LIGHT_PROJECTILE,
440 projectileSprite: LIGHT_PROJECTILE,
419 effect: "revitalize",
441 effect: "revitalize",
420 description: "A gentle current of life that mends wounds one breath at a time."
442 description: "A gentle current of life that mends wounds one breath at a time."
shared/skills/levelUpUnlocks.js +9 −8
@@ -19,7 +19,7 @@ import
19 19 } from "../definitions/materialTiers.js";
20 20 import { firestartingDifficulty } from "../definitions/craftingStations.js";
21 21 import { HERB_DEFINITIONS, HERB_GATHER_SKILL_LEVEL } from "../definitions/herbs.js";
22 import { SPELL_DEFINITIONS } from "../definitions/spells.js";
22 import { SPELL_DEFINITIONS, spellMinMagicLevel } from "../definitions/spells.js";
23 23 import { ALCHEMY_POTION_DEFINITIONS } from "../definitions/alchemy.js";
24 24
25 25 /**
@@ -188,23 +188,24 @@ function buildUnlockCatalog ()
188 188 add(SkillId.herbalism, level, `You can now gather ${joinNames(names)}.`);
189 189 }
190 190
191 /** @type {Map<number, string[]>} */
191 /** @type {Map<number, { names: string[], tier: number }>} */
192 192 const spellsByLevel = new Map();
193 193 for (const spell of Object.values(SPELL_DEFINITIONS))
194 194 {
195 195 if (spell.mobOnly || spell.starter)
196 196 { continue; }
197 const level = Math.max(1, spell.minMagicLevel | 0 || spell.tier | 0 || 1);
198 const list = spellsByLevel.get(level) ?? [];
199 list.push(spell.displayName);
200 spellsByLevel.set(level, list);
197 const level = spellMinMagicLevel(spell);
198 const entry = spellsByLevel.get(level) ?? { names: [], tier: spell.tier | 0 || 1 };
199 entry.names.push(spell.displayName);
200 entry.tier = Math.min(entry.tier, spell.tier | 0 || 1);
201 spellsByLevel.set(level, entry);
201 202 }
202 for (const [level, names] of spellsByLevel)
203 for (const [level, { names, tier }] of spellsByLevel)
203 204 {
204 205 if (names.length <= 4)
205 206 { add(SkillId.magic, level, `You can now cast ${joinNames(names)}.`); }
206 207 else
207 { add(SkillId.magic, level, `You can now cast Magic level ${level} spells.`); }
208 { add(SkillId.magic, level, `You can now cast Magic tier ${tier} spells.`); }
208 209 }
209 210
210 211 /** @type {Map<number, string[]>} */
@@ -19,7 +19,7 @@ import
19 } from "../definitions/materialTiers.js";
19 } from "../definitions/materialTiers.js";
20import { firestartingDifficulty } from "../definitions/craftingStations.js";
20import { firestartingDifficulty } from "../definitions/craftingStations.js";
21import { HERB_DEFINITIONS, HERB_GATHER_SKILL_LEVEL } from "../definitions/herbs.js";
21import { HERB_DEFINITIONS, HERB_GATHER_SKILL_LEVEL } from "../definitions/herbs.js";
22import { SPELL_DEFINITIONS } from "../definitions/spells.js";
22import { SPELL_DEFINITIONS, spellMinMagicLevel } from "../definitions/spells.js";
23import { ALCHEMY_POTION_DEFINITIONS } from "../definitions/alchemy.js";
23import { ALCHEMY_POTION_DEFINITIONS } from "../definitions/alchemy.js";
24
24
25/**
25/**
@@ -188,23 +188,24 @@ function buildUnlockCatalog ()
188 add(SkillId.herbalism, level, `You can now gather ${joinNames(names)}.`);
188 add(SkillId.herbalism, level, `You can now gather ${joinNames(names)}.`);
189 }
189 }
190
190
191 /** @type {Map<number, string[]>} */
191 /** @type {Map<number, { names: string[], tier: number }>} */
192 const spellsByLevel = new Map();
192 const spellsByLevel = new Map();
193 for (const spell of Object.values(SPELL_DEFINITIONS))
193 for (const spell of Object.values(SPELL_DEFINITIONS))
194 {
194 {
195 if (spell.mobOnly || spell.starter)
195 if (spell.mobOnly || spell.starter)
196 { continue; }
196 { continue; }
197 const level = Math.max(1, spell.minMagicLevel | 0 || spell.tier | 0 || 1);
197 const level = spellMinMagicLevel(spell);
198 const list = spellsByLevel.get(level) ?? [];
198 const entry = spellsByLevel.get(level) ?? { names: [], tier: spell.tier | 0 || 1 };
199 list.push(spell.displayName);
199 entry.names.push(spell.displayName);
200 spellsByLevel.set(level, list);
200 entry.tier = Math.min(entry.tier, spell.tier | 0 || 1);
201 spellsByLevel.set(level, entry);
201 }
202 }
202 for (const [level, names] of spellsByLevel)
203 for (const [level, { names, tier }] of spellsByLevel)
203 {
204 {
204 if (names.length <= 4)
205 if (names.length <= 4)
205 { add(SkillId.magic, level, `You can now cast ${joinNames(names)}.`); }
206 { add(SkillId.magic, level, `You can now cast ${joinNames(names)}.`); }
206 else
207 else
207 { add(SkillId.magic, level, `You can now cast Magic level ${level} spells.`); }
208 { add(SkillId.magic, level, `You can now cast Magic tier ${tier} spells.`); }
208 }
209 }
209
210
210 /** @type {Map<number, string[]>} */
211 /** @type {Map<number, string[]>} */
shared/spells/state.js +2 −2
@@ -1,4 +1,4 @@
1 import { SpellId, spellDefinition, spellMindPowerFromTier } from "../definitions/spells.js";
1 import { SpellId, spellDefinition, spellMindPowerFromTier, spellMinMagicLevel } from "../definitions/spells.js";
2 2 import { MAX_FAVORITE_SPELLS } from "./constants.js";
3 3 import { skillLevel } from "../definitions/skills.js";
4 4 import { SkillId } from "../definitions/skills.js";
@@ -85,7 +85,7 @@ export function canCastSpell (skills, spells, spellId)
85 85 if (!def || !playerKnowsSpell(spells, spellId))
86 86 { return { ok: false, reason: "You do not know that spell." }; }
87 87 const magicLevel = skillLevel(skills, SkillId.magic);
88 const need = def.minMagicLevel ?? def.tier ?? 1;
88 const need = spellMinMagicLevel(def);
89 89 if (magicLevel < need)
90 90 {
91 91 return { ok: false, reason: `Requires Magic level ${need}.` };
@@ -1,4 +1,4 @@
1import { SpellId, spellDefinition, spellMindPowerFromTier } from "../definitions/spells.js";
1import { SpellId, spellDefinition, spellMindPowerFromTier, spellMinMagicLevel } from "../definitions/spells.js";
2import { MAX_FAVORITE_SPELLS } from "./constants.js";
2import { MAX_FAVORITE_SPELLS } from "./constants.js";
3import { skillLevel } from "../definitions/skills.js";
3import { skillLevel } from "../definitions/skills.js";
4import { SkillId } from "../definitions/skills.js";
4import { SkillId } from "../definitions/skills.js";
@@ -85,7 +85,7 @@ export function canCastSpell (skills, spells, spellId)
85 if (!def || !playerKnowsSpell(spells, spellId))
85 if (!def || !playerKnowsSpell(spells, spellId))
86 { return { ok: false, reason: "You do not know that spell." }; }
86 { return { ok: false, reason: "You do not know that spell." }; }
87 const magicLevel = skillLevel(skills, SkillId.magic);
87 const magicLevel = skillLevel(skills, SkillId.magic);
88 const need = def.minMagicLevel ?? def.tier ?? 1;
88 const need = spellMinMagicLevel(def);
89 if (magicLevel < need)
89 if (magicLevel < need)
90 {
90 {
91 return { ok: false, reason: `Requires Magic level ${need}.` };
91 return { ok: false, reason: `Requires Magic level ${need}.` };