90 lines
3.5 KiB
TypeScript
90 lines
3.5 KiB
TypeScript
|
|
import { describe, it, expect } from 'vitest';
|
||
|
|
import { generatePointCrawlMap } from '@/samples/slay-the-spire-like/map/generator';
|
||
|
|
import { MapNodeType } from '@/samples/slay-the-spire-like/map/types';
|
||
|
|
|
||
|
|
describe('generatePointCrawlMap', () => {
|
||
|
|
it('should generate a map with 13 layers', () => {
|
||
|
|
const map = generatePointCrawlMap(123);
|
||
|
|
expect(map.layers.length).toBe(13);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should have correct fixed layer types', () => {
|
||
|
|
const map = generatePointCrawlMap(123);
|
||
|
|
const startNode = map.nodes.get('node-0-0');
|
||
|
|
const bossNode = map.nodes.get('node-12-0');
|
||
|
|
|
||
|
|
expect(startNode?.type).toBe(MapNodeType.Start);
|
||
|
|
expect(bossNode?.type).toBe(MapNodeType.Boss);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should assign encounters to nodes based on encounterDesert.csv', () => {
|
||
|
|
const map = generatePointCrawlMap(456);
|
||
|
|
|
||
|
|
// Check that nodes have encounters assigned
|
||
|
|
let combatWithEncounter = 0;
|
||
|
|
let eliteWithEncounter = 0;
|
||
|
|
let bossWithEncounter = 0;
|
||
|
|
let eventWithEncounter = 0;
|
||
|
|
let npcWithEncounter = 0;
|
||
|
|
let shelterWithEncounter = 0;
|
||
|
|
|
||
|
|
for (const node of map.nodes.values()) {
|
||
|
|
if (node.type === MapNodeType.Combat && node.encounter) {
|
||
|
|
combatWithEncounter++;
|
||
|
|
expect(node.encounter.name).toBeTruthy();
|
||
|
|
expect(node.encounter.description).toBeTruthy();
|
||
|
|
}
|
||
|
|
if (node.type === MapNodeType.Elite && node.encounter) {
|
||
|
|
eliteWithEncounter++;
|
||
|
|
expect(node.encounter.name).toBeTruthy();
|
||
|
|
expect(node.encounter.description).toBeTruthy();
|
||
|
|
}
|
||
|
|
if (node.type === MapNodeType.Boss && node.encounter) {
|
||
|
|
bossWithEncounter++;
|
||
|
|
expect(node.encounter.name).toBeTruthy();
|
||
|
|
expect(node.encounter.description).toBeTruthy();
|
||
|
|
}
|
||
|
|
if (node.type === MapNodeType.Event && node.encounter) {
|
||
|
|
eventWithEncounter++;
|
||
|
|
expect(node.encounter.name).toBeTruthy();
|
||
|
|
expect(node.encounter.description).toBeTruthy();
|
||
|
|
}
|
||
|
|
if (node.type === MapNodeType.NPC && node.encounter) {
|
||
|
|
npcWithEncounter++;
|
||
|
|
expect(node.encounter.name).toBeTruthy();
|
||
|
|
expect(node.encounter.description).toBeTruthy();
|
||
|
|
}
|
||
|
|
if (node.type === MapNodeType.Shelter && node.encounter) {
|
||
|
|
shelterWithEncounter++;
|
||
|
|
expect(node.encounter.name).toBeTruthy();
|
||
|
|
expect(node.encounter.description).toBeTruthy();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Should have assigned at least some encounters
|
||
|
|
const totalWithEncounters =
|
||
|
|
combatWithEncounter +
|
||
|
|
eliteWithEncounter +
|
||
|
|
bossWithEncounter +
|
||
|
|
eventWithEncounter +
|
||
|
|
npcWithEncounter +
|
||
|
|
shelterWithEncounter;
|
||
|
|
|
||
|
|
expect(totalWithEncounters).toBeGreaterThan(0);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should use correct encounter types for each node type', () => {
|
||
|
|
const map = generatePointCrawlMap(789);
|
||
|
|
|
||
|
|
for (const node of map.nodes.values()) {
|
||
|
|
if (node.encounter) {
|
||
|
|
// Encounter should match node type conceptually
|
||
|
|
// Combat nodes should have enemy encounters, elites should have elite encounters, etc.
|
||
|
|
if (node.type === MapNodeType.Boss) {
|
||
|
|
expect(node.encounter.description).toContain('Boss');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|