149 lines
5.3 KiB
TypeScript
149 lines
5.3 KiB
TypeScript
import { existsSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import {
|
|
getManastormCatalog,
|
|
manastormAffixes,
|
|
manastormGroupModifier,
|
|
manastormScaling,
|
|
setManastormCatalog,
|
|
} from "./manastorm";
|
|
import { INSTALLED_MANASTORM_RUNTIME_CATALOG } from "./manastormInstalledCatalog";
|
|
import runtimeSnapshot from "./generated/manastormRuntimeCatalog.json";
|
|
|
|
describe("installed Manastorm runtime adapter", () => {
|
|
afterEach(() => setManastormCatalog(null));
|
|
|
|
it("uses the complete installed level curve without treating unknown integer fields as multipliers", () => {
|
|
setManastormCatalog(INSTALLED_MANASTORM_RUNTIME_CATALOG);
|
|
expect(getManastormCatalog()).toBe(INSTALLED_MANASTORM_RUNTIME_CATALOG);
|
|
expect(INSTALLED_MANASTORM_RUNTIME_CATALOG.maximumLevel).toBe(16_384);
|
|
expect(manastormScaling(1)).toEqual({
|
|
statMultiplier: 1,
|
|
bonusLootChance: 0,
|
|
experienceMultiplier: 1,
|
|
});
|
|
expect(manastormScaling(2)).toEqual({
|
|
statMultiplier: expect.closeTo(1.003, 5),
|
|
bonusLootChance: 0.03,
|
|
experienceMultiplier: expect.closeTo(1.003, 5),
|
|
});
|
|
});
|
|
|
|
it("retains distinct leveling and end-game modes and all resolved encounter identities", () => {
|
|
expect(runtimeSnapshot.schemaVersion).toBe(2);
|
|
expect(runtimeSnapshot.defaultModeId).toBe(0);
|
|
expect(runtimeSnapshot.modeIds).toEqual([0, 2]);
|
|
expect(runtimeSnapshot.modes.map(({ modeId }) => modeId)).toEqual([0, 2]);
|
|
expect(runtimeSnapshot.encounters).toHaveLength(529);
|
|
expect(runtimeSnapshot.sourceRows).toHaveLength(1_025);
|
|
expect(runtimeSnapshot.encounters.filter(({ modeIds }) => modeIds.includes(0))).toHaveLength(227);
|
|
expect(runtimeSnapshot.encounters.filter(({ modeIds }) => modeIds.includes(2))).toHaveLength(302);
|
|
expect(INSTALLED_MANASTORM_RUNTIME_CATALOG.modifiers).toHaveLength(32_768);
|
|
expect(INSTALLED_MANASTORM_RUNTIME_CATALOG.messages).toHaveLength(291);
|
|
expect(runtimeSnapshot.encounters.find(({ encounterId }) => encounterId === 161))
|
|
.toMatchObject({ creatureId: 644, modeIds: [0] });
|
|
expect(runtimeSnapshot.encounters.find(({ encounterId }) => encounterId === 2161))
|
|
.toMatchObject({ creatureId: 644, modeIds: [2] });
|
|
});
|
|
|
|
it("applies exact installed player-group multipliers for selectable party sizes", () => {
|
|
setManastormCatalog(INSTALLED_MANASTORM_RUNTIME_CATALOG);
|
|
expect(manastormGroupModifier(1)).toMatchObject({
|
|
enemyStatMultiplier: 1,
|
|
rewardMultiplier: 1,
|
|
});
|
|
expect(manastormGroupModifier(5)).toMatchObject({
|
|
enemyStatMultiplier: expect.closeTo(1.4, 5),
|
|
rewardMultiplier: expect.closeTo(1.4, 5),
|
|
});
|
|
expect(manastormGroupModifier(
|
|
5,
|
|
INSTALLED_MANASTORM_RUNTIME_CATALOG,
|
|
2,
|
|
)).toMatchObject({
|
|
enemyStatMultiplier: expect.closeTo(1.4, 5),
|
|
rewardMultiplier: expect.closeTo(1.4, 5),
|
|
sourceModeId: 0,
|
|
appliesToModeIds: [0, 2],
|
|
});
|
|
});
|
|
|
|
it("imports and deterministically rotates the installed affix unlock set", () => {
|
|
setManastormCatalog(INSTALLED_MANASTORM_RUNTIME_CATALOG);
|
|
expect(INSTALLED_MANASTORM_RUNTIME_CATALOG.affixes).toHaveLength(14);
|
|
expect(manastormAffixes(10)).toEqual([]);
|
|
expect(manastormAffixes(11)).toEqual([
|
|
expect.objectContaining({
|
|
id: "manastorm-affix-manabomb",
|
|
name: "Mana Bomb",
|
|
description: expect.stringContaining("mana bomb"),
|
|
}),
|
|
]);
|
|
expect(manastormAffixes(13)).toEqual([
|
|
expect.objectContaining({
|
|
id: "manastorm-affix-lightningrod",
|
|
name: "Lightning Rod",
|
|
}),
|
|
]);
|
|
const replayAffixes = manastormAffixes(
|
|
10,
|
|
INSTALLED_MANASTORM_RUNTIME_CATALOG,
|
|
0,
|
|
101,
|
|
);
|
|
expect(replayAffixes).toHaveLength(1);
|
|
expect(manastormAffixes(
|
|
10,
|
|
INSTALLED_MANASTORM_RUNTIME_CATALOG,
|
|
0,
|
|
101,
|
|
)).toEqual(replayAffixes);
|
|
expect(manastormAffixes(
|
|
13,
|
|
INSTALLED_MANASTORM_RUNTIME_CATALOG,
|
|
0,
|
|
101,
|
|
)).toEqual([
|
|
expect.objectContaining({
|
|
id: "manastorm-affix-lightningrod",
|
|
name: "Lightning Rod",
|
|
}),
|
|
]);
|
|
|
|
const level101Affixes = manastormAffixes(101);
|
|
expect(level101Affixes).toHaveLength(1);
|
|
expect(INSTALLED_MANASTORM_RUNTIME_CATALOG.affixes?.map(({ id }) => id))
|
|
.toContain(level101Affixes[0]?.id);
|
|
for (const affix of INSTALLED_MANASTORM_RUNTIME_CATALOG.affixes ?? []) {
|
|
expect(affix.iconReference, `${affix.name} should retain its installed icon`).toBeTruthy();
|
|
expect(
|
|
existsSync(resolve(
|
|
process.cwd(),
|
|
"public",
|
|
"assets",
|
|
"ui",
|
|
"spells",
|
|
`${affix.iconReference?.toLowerCase()}.png`,
|
|
)),
|
|
`${affix.name} icon should be exported`,
|
|
).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("ships every resolved Manastorm message icon to the browser", () => {
|
|
expect(INSTALLED_MANASTORM_RUNTIME_CATALOG.messages).toHaveLength(291);
|
|
for (const message of INSTALLED_MANASTORM_RUNTIME_CATALOG.messages ?? []) {
|
|
expect(message.iconReference, `${message.title} should retain an installed icon`).toBeTruthy();
|
|
expect(existsSync(resolve(
|
|
process.cwd(),
|
|
"public",
|
|
"assets",
|
|
"ui",
|
|
"spells",
|
|
`${message.iconReference?.toLowerCase()}.png`,
|
|
))).toBe(true);
|
|
}
|
|
});
|
|
});
|