Files
healer-man/src/game/romHeirloomReference.test.ts
T

56 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from "vitest";
import { classById } from "../app/characterCatalog";
import {
romHeirloomReference,
romSourceReferenceItem,
ROM_HEIRLOOM_REFERENCE_CLASSES,
ROM_HEIRLOOM_REFERENCE_SLOTS,
} from "./romHeirloomReference";
describe("RoM source-backed heirloom references", () => {
it("provides finite native stats and source item IDs at every level from 1 through 79", () => {
for (const classId of ROM_HEIRLOOM_REFERENCE_CLASSES) {
for (const slot of ROM_HEIRLOOM_REFERENCE_SLOTS) {
const first = romHeirloomReference(classId, slot, 1);
if (!first) continue;
for (let level = 1; level <= 79; level += 1) {
const reference = romHeirloomReference(classId, slot, level)!;
expect(reference.level).toBe(level);
expect(reference.referenceItemIds.length).toBeGreaterThan(0);
expect(Object.values(reference.stats).length).toBeGreaterThan(0);
for (const value of Object.values(reference.stats)) {
expect(Number.isFinite(value)).toBe(true);
expect(value).toBeGreaterThanOrEqual(0);
}
for (const itemId of reference.referenceItemIds) {
expect(romSourceReferenceItem(itemId)?.quality).toBe(2);
}
}
}
}
});
it("uses source package suit anchors and a leather reference for the Scout", () => {
expect(romHeirloomReference("rom-knight", "chest", 50)?.packageId).toBe(240384);
expect(romHeirloomReference("rom-scout", "chest", 60)?.packageId).toBe(240347);
expect(romHeirloomReference("rom-priest", "chest", 65)?.packageId).toBe(240313);
expect(classById("rom-scout").armor).toBe("leather");
const scoutChest = romHeirloomReference("rom-scout", "chest", 65)!;
expect(scoutChest.referenceItemIds.some((id) => romSourceReferenceItem(id)?.type === 2)).toBe(true);
expect(romHeirloomReference("rom-priest", "off-hand", 65)).toBeNull();
expect(romSourceReferenceItem(213416)?.stats).toMatchObject({ magicalWeaponDamage: 1094, wisdom: 56 });
expect(romSourceReferenceItem(229164)?.stats).toMatchObject({
physicalDefense: 1029,
magicalDefense: 1655,
health: 273,
magicalAttack: 290,
});
});
it("clamps queries to the designed 1–79 heirloom interval", () => {
expect(romHeirloomReference("rom-mage", "main-hand", -20)?.level).toBe(1);
expect(romHeirloomReference("rom-mage", "main-hand", 80)?.level).toBe(79);
expect(romHeirloomReference("rom-mage", "off-hand", 40)).toBeNull();
});
});