chore: non-combat tests update
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { generatePointCrawlMap, hasPath } from '@/samples/slay-the-spire-like/map/generator';
|
||||
import { MapNodeType, MapLayerType } from '@/samples/slay-the-spire-like/map/types';
|
||||
import { generatePointCrawlMap, hasPath } from '@/samples/slay-the-spire-like/system/map/generator';
|
||||
import { MapNodeType, MapLayerType } from '@/samples/slay-the-spire-like/system/map/types';
|
||||
import { createRNG } from '@/utils/rng';
|
||||
import { encounters } from '@/samples/slay-the-spire-like/data/desert';
|
||||
|
||||
describe('generatePointCrawlMap', () => {
|
||||
it('should generate a map with 10 layers', () => {
|
||||
const map = generatePointCrawlMap(123);
|
||||
const map = generatePointCrawlMap(createRNG(123), encounters);
|
||||
expect(map.layers.length).toBe(10);
|
||||
});
|
||||
|
||||
it('should have correct layer structure', () => {
|
||||
const map = generatePointCrawlMap(123);
|
||||
const map = generatePointCrawlMap(createRNG(123), encounters);
|
||||
const expectedStructure = [
|
||||
'start',
|
||||
MapLayerType.Wild,
|
||||
@@ -29,7 +31,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have correct node counts per layer', () => {
|
||||
const map = generatePointCrawlMap(123);
|
||||
const map = generatePointCrawlMap(createRNG(123), encounters);
|
||||
const expectedCounts = [1, 3, 3, 4, 3, 3, 4, 3, 3, 1];
|
||||
|
||||
for (let i = 0; i < expectedCounts.length; i++) {
|
||||
@@ -38,7 +40,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have Start and End nodes with correct types', () => {
|
||||
const map = generatePointCrawlMap(123);
|
||||
const map = generatePointCrawlMap(createRNG(123), encounters);
|
||||
const startNode = map.nodes.get('node-0-0');
|
||||
const endNode = map.nodes.get('node-9-0');
|
||||
|
||||
@@ -47,7 +49,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have wild layers with minion/elite/event types', () => {
|
||||
const map = generatePointCrawlMap(123);
|
||||
const map = generatePointCrawlMap(createRNG(123), encounters);
|
||||
const wildLayerIndices = [1, 2, 4, 5, 7, 8];
|
||||
const validWildTypes = new Set([MapNodeType.Minion, MapNodeType.Elite, MapNodeType.Event]);
|
||||
|
||||
@@ -62,7 +64,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have settlement layers with at least 1 camp, 1 shop, 1 curio', () => {
|
||||
const map = generatePointCrawlMap(123);
|
||||
const map = generatePointCrawlMap(createRNG(123), encounters);
|
||||
const settlementLayerIndices = [3, 6];
|
||||
|
||||
for (const layerIdx of settlementLayerIndices) {
|
||||
@@ -77,7 +79,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have Start connected to all 3 wild nodes', () => {
|
||||
const map = generatePointCrawlMap(42);
|
||||
const map = generatePointCrawlMap(createRNG(42), encounters);
|
||||
const startNode = map.nodes.get('node-0-0');
|
||||
const wildLayer = map.layers[1];
|
||||
|
||||
@@ -86,7 +88,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have each wild node connect to 1 wild node in wild→wild layers', () => {
|
||||
const map = generatePointCrawlMap(42);
|
||||
const map = generatePointCrawlMap(createRNG(42), encounters);
|
||||
const wildToWildTransitions = [
|
||||
{ src: 1, tgt: 2 },
|
||||
{ src: 4, tgt: 5 },
|
||||
@@ -105,7 +107,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have each wild node connect to 2 settlement nodes in wild→settlement layers', () => {
|
||||
const map = generatePointCrawlMap(42);
|
||||
const map = generatePointCrawlMap(createRNG(42), encounters);
|
||||
const wildToSettlementTransitions = [
|
||||
{ src: 2, tgt: 3 },
|
||||
{ src: 5, tgt: 6 },
|
||||
@@ -125,7 +127,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have settlement nodes connect correctly (1-2-2-1 pattern)', () => {
|
||||
const map = generatePointCrawlMap(42);
|
||||
const map = generatePointCrawlMap(createRNG(42), encounters);
|
||||
const settlementToWildTransitions = [
|
||||
{ src: 3, tgt: 4 },
|
||||
{ src: 6, tgt: 7 },
|
||||
@@ -153,7 +155,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have all 3 wild nodes connect to End', () => {
|
||||
const map = generatePointCrawlMap(42);
|
||||
const map = generatePointCrawlMap(createRNG(42), encounters);
|
||||
const lastWildLayer = map.layers[8];
|
||||
const endNode = map.nodes.get('node-9-0');
|
||||
|
||||
@@ -164,7 +166,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should have all nodes reachable from Start and can reach End', () => {
|
||||
const map = generatePointCrawlMap(123);
|
||||
const map = generatePointCrawlMap(createRNG(123), encounters);
|
||||
const startId = 'node-0-0';
|
||||
const endId = 'node-9-0';
|
||||
|
||||
@@ -176,7 +178,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should not have crossing edges in wild→wild transitions', () => {
|
||||
const map = generatePointCrawlMap(12345);
|
||||
const map = generatePointCrawlMap(createRNG(12345), encounters);
|
||||
const wildToWildTransitions = [
|
||||
{ src: 1, tgt: 2 },
|
||||
{ src: 4, tgt: 5 },
|
||||
@@ -214,7 +216,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should not have crossing edges in wild→settlement transitions', () => {
|
||||
const map = generatePointCrawlMap(12345);
|
||||
const map = generatePointCrawlMap(createRNG(12345), encounters);
|
||||
const wildToSettlementTransitions = [
|
||||
{ src: 2, tgt: 3 },
|
||||
{ src: 5, tgt: 6 },
|
||||
@@ -251,7 +253,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should not have crossing edges in settlement→wild transitions', () => {
|
||||
const map = generatePointCrawlMap(12345);
|
||||
const map = generatePointCrawlMap(createRNG(12345), encounters);
|
||||
const settlementToWildTransitions = [
|
||||
{ src: 3, tgt: 4 },
|
||||
{ src: 6, tgt: 7 },
|
||||
@@ -288,7 +290,7 @@ describe('generatePointCrawlMap', () => {
|
||||
});
|
||||
|
||||
it('should assign encounters to all non-Start/End nodes', () => {
|
||||
const map = generatePointCrawlMap(456);
|
||||
const map = generatePointCrawlMap(createRNG(456), encounters);
|
||||
|
||||
for (const node of map.nodes.values()) {
|
||||
if (node.type === MapNodeType.Start || node.type === MapNodeType.End) {
|
||||
@@ -306,7 +308,7 @@ describe('generatePointCrawlMap', () => {
|
||||
it('should assign encounters to all nodes across multiple seeds', () => {
|
||||
// Test multiple seeds to ensure no random failure
|
||||
for (let seed = 0; seed < 20; seed++) {
|
||||
const map = generatePointCrawlMap(seed);
|
||||
const map = generatePointCrawlMap(createRNG(seed), encounters);
|
||||
|
||||
for (const node of map.nodes.values()) {
|
||||
if (node.type === MapNodeType.Start || node.type === MapNodeType.End) {
|
||||
@@ -321,7 +323,7 @@ describe('generatePointCrawlMap', () => {
|
||||
|
||||
it('should minimize same-layer repetitions in wild layer pairs', () => {
|
||||
// Test that wild layers in pairs (1-2, 4-5, 7-8) have minimal duplicate types within each layer
|
||||
const map = generatePointCrawlMap(12345);
|
||||
const map = generatePointCrawlMap(createRNG(12345), encounters);
|
||||
const wildPairIndices = [
|
||||
[1, 2],
|
||||
[4, 5],
|
||||
@@ -351,7 +353,7 @@ describe('generatePointCrawlMap', () => {
|
||||
|
||||
it('should minimize adjacent repetitions in wild→wild connections', () => {
|
||||
// Test that wild nodes connected by wild→wild edges have different types
|
||||
const map = generatePointCrawlMap(12345);
|
||||
const map = generatePointCrawlMap(createRNG(12345), encounters);
|
||||
const wildToWildPairs = [
|
||||
{ src: 1, tgt: 2 },
|
||||
{ src: 4, tgt: 5 },
|
||||
|
||||
Reference in New Issue
Block a user