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.
@@ -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 @@ import11
spawnerEquipmentSlot11
spawnerEquipmentSlot12
} from "/shared/definitions/mobs.js";12
} from "/shared/definitions/mobs.js";13
import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";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
import { centralExchangeStaffCount } from "/shared/market/exchange.js";15
import { centralExchangeStaffCount } from "/shared/market/exchange.js";16
import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";16
import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";17
import { listRawFishPickerEntries, normalizeFishingSpotConfig, fishTierRankFromItemId } from "/shared/definitions/fishItems.js";17
import { 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");@@ -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 @@ import17
isTownGuardMob,17
isTownGuardMob,18
isHumanoidMob18
isHumanoidMob19
} from "../../../shared/definitions/mobs.js";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
import { MAGIC_ELEMENT_ORDER, magicElementTint } from "../../../shared/definitions/attackTypes.js";21
import { MAGIC_ELEMENT_ORDER, magicElementTint } from "../../../shared/definitions/attackTypes.js";22
import { essenceElementDisplayName } from "../../../shared/definitions/essenceItems.js";22
import { essenceElementDisplayName } from "../../../shared/definitions/essenceItems.js";23
import { LeatherItemId } from "../../../shared/definitions/leatherItems.js";23
import { 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);@@ -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
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
test("applySkillXp includes previousLevel on level-up", () =>60
test("applySkillXp includes previousLevel on level-up", () =>51
{61
{52
const skills = normalizePlayerSkills(null);62
const skills = normalizePlayerSkills(null);@@ -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 spells113
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 spells122
{ 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
138
test("mobs below spell minMagicLevel do not learn the spell", () =>138
test("mobs below spell minMagicLevel do not learn the spell", () =>