Guard source gear namespaces and retain recoverable legacy records (#9)
This commit is contained in:
1 parent
ab37006932
commit
e567910c04
23 files changed
+1203
-66
No files matched your search
@@ -6,6 +6,7 @@ import {
|
||||
equipInventoryItem,
|
||||
equipmentItemLevel,
|
||||
equipmentStats,
|
||||
activeEquipmentStatsForClass,
|
||||
normalizeEquipment,
|
||||
unequipInventorySlot,
|
||||
} from "./equipment";
|
||||
@@ -26,6 +27,7 @@ function item(
|
||||
itemId: 1,
|
||||
itemKey: instanceId,
|
||||
name: instanceId,
|
||||
contentCategory: "wow",
|
||||
quality: "uncommon",
|
||||
inventorySlot,
|
||||
armorType: null,
|
||||
@@ -66,6 +68,56 @@ describe("equipment assignments", () => {
|
||||
expect(classCanEquipItem("warlock", bow)).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects foreign, unresolved, and non-native RoM gear before changing assignments", () => {
|
||||
const wowDagger = item("wow-dagger", "one-hand", { weaponType: "dagger" });
|
||||
const nativeRomDagger = item("rom-dagger", "one-hand", {
|
||||
contentCategory: "rom",
|
||||
weaponType: "dagger",
|
||||
stats: stats({ strength: 12, romNative: { strength: 12 } }),
|
||||
});
|
||||
const unresolvedRomDagger = item("unresolved-rom-dagger", "one-hand", {
|
||||
contentCategory: null,
|
||||
weaponType: "dagger",
|
||||
stats: stats({ strength: 12 }),
|
||||
});
|
||||
const foreign = equipInventoryItem({ player: { back: "kept" } }, [wowDagger], "player", "rom-priest", wowDagger.instanceId);
|
||||
expect(foreign).toEqual({
|
||||
ok: false,
|
||||
assignments: { player: { back: "kept" } },
|
||||
reason: "That item belongs to a different game category.",
|
||||
});
|
||||
expect(equipInventoryItem({}, [nativeRomDagger], "player", "rom-priest", nativeRomDagger.instanceId).ok).toBe(true);
|
||||
expect(equipInventoryItem({}, [unresolvedRomDagger], "player", "rom-priest", unresolvedRomDagger.instanceId).ok).toBe(false);
|
||||
expect(normalizeEquipment({ player: { "main-hand": wowDagger.instanceId } }, [wowDagger], "rom")).toEqual({});
|
||||
|
||||
const forgedCategory = equipInventoryItem(
|
||||
{ player: { back: "kept" } },
|
||||
[wowDagger],
|
||||
"player",
|
||||
"rom-priest",
|
||||
wowDagger.instanceId,
|
||||
{ ownerCategory: "wow" },
|
||||
);
|
||||
expect(forgedCategory.ok).toBe(false);
|
||||
expect(forgedCategory.assignments).toEqual({ player: { back: "kept" } });
|
||||
expect(classCanEquipItem("rom-priest", wowDagger, { ownerCategory: "wow" })).toBe(false);
|
||||
});
|
||||
|
||||
it("does not apply foreign or unresolved items in active equipment stat reads", () => {
|
||||
const romItem = item("rom-native", "back", {
|
||||
contentCategory: "rom",
|
||||
stats: stats({ stamina: 20, romNative: { stamina: 20 } }),
|
||||
});
|
||||
const wowItem = item("wow-foreign", "head", { stats: stats({ stamina: 90 }) });
|
||||
const assignments = { player: { back: romItem.instanceId, head: wowItem.instanceId } };
|
||||
expect(activeEquipmentStatsForClass(assignments, [romItem, wowItem], "player", "rom-priest", "rom"))
|
||||
.toMatchObject({ stamina: 20 });
|
||||
expect(activeEquipmentStatsForClass(assignments, [romItem, wowItem], "player", "rom-priest", "coa"))
|
||||
.toMatchObject({ stamina: 0 });
|
||||
expect(activeEquipmentStatsForClass(assignments, [romItem, wowItem], "player", "rom-priest", "wow"))
|
||||
.toEqual(EMPTY_ITEM_STATS);
|
||||
});
|
||||
|
||||
it("handles two-handed conflicts, unequipping, normalization, and item level", () => {
|
||||
const staff = item("staff", "two-hand", { weaponType: "staff", itemLevel: 18 });
|
||||
const shield = item("shield", "off-hand", { armorType: "shield", itemLevel: 14 });
|
||||
@@ -126,4 +178,21 @@ describe("equipment assignments", () => {
|
||||
expect(deriveRomNativeStats({ classId: "rom-warrior", level: 1, gear: unequipped.romNative }).health.max)
|
||||
.toBe(withoutGear.health.max);
|
||||
});
|
||||
|
||||
it("keeps CoA-tagged direct stats out of the RoM native projection", () => {
|
||||
const coaGear = item("coa-gear", "chest", {
|
||||
contentCategory: "coa",
|
||||
armorType: "plate",
|
||||
stats: stats({ stamina: 7, strength: 3 }),
|
||||
});
|
||||
const active = activeEquipmentStatsForClass(
|
||||
{ player: { chest: coaGear.instanceId } },
|
||||
[coaGear],
|
||||
"player",
|
||||
"guardian",
|
||||
"coa",
|
||||
);
|
||||
expect(active).toMatchObject({ stamina: 7, strength: 3 });
|
||||
expect(active.romNative).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user