test: refactor slay-the-spire-like combat tests

Update combat effect tests to use the new transform offset structure
and fix type mismatches in entity and inventory creation.
This commit is contained in:
hypercross 2026-04-20 11:37:18 +08:00
parent 90cb97e0ae
commit 88d31430a6
1 changed files with 7 additions and 14 deletions

View File

@ -40,14 +40,14 @@ function createRunContext(
return {
getItemData(id: string): ItemData | null {
const item = items.get(id);
return item?.meta.itemData ?? null;
return item?.meta?.itemData ?? null;
},
getNeighborItems(_id: string): Iterable<string> {
return [];
},
getConsumedUses(id: string): number {
const item = items.get(id);
return item?.meta.consumedUses ?? 0;
return item?.meta?.consumedUses ?? 0;
},
setConsumedUsesAsync(id: string, uses: number): Promise<void> {
const item = items.get(id);
@ -94,9 +94,7 @@ function createItem(
id: itemId,
shape: { id: "1x1", cells: [{ x: 0, y: 0 }] } as unknown as ParsedShape,
transform: {
x: 0,
y: 0,
rotation: 0,
offset: { x: 0, y: 0 },
flipX: false,
flipY: false,
} as unknown as Transform2D,
@ -123,13 +121,14 @@ function createInventory(
const occupied = new Set<CellKey>();
for (const item of items) {
map.set(item.id, item);
occupied.add(`${item.transform.x},${item.transform.y}`);
occupied.add(`${item.transform.offset.x},${item.transform.offset.y}`);
}
return { width: 6, height: 4, items: map, occupiedCells: occupied };
}
function createCombatEntity(hp = 10, maxHp = 10): CombatEntity {
return {
id: "",
effects: {},
hp,
maxHp,
@ -159,9 +158,9 @@ function createEnemyEntity(id: string, hp = 10, maxHp = 10): EnemyEntity {
return {
...createCombatEntity(hp, maxHp),
id,
enemy: { id, name: id, description: "" },
enemy: { id, name: id, description: "", intents: null! },
intents: {},
currentIntentId: "",
currentIntent: null!,
};
}
@ -172,12 +171,6 @@ function createCombatState(
return {
player: createPlayerEntity(playerHp),
enemies,
inventory: {
width: 6,
height: 4,
items: new Map(),
occupiedCells: new Set(),
},
phase: "playerTurn",
turnNumber: 1,
result: null,