All checks were successful
Deploy to Pages / build (push) Successful in 26s
61 lines
2.4 KiB
TypeScript
61 lines
2.4 KiB
TypeScript
import { defaultProject, fireplace, rectangle } from '../src/lib/defaults';
|
|
import type { Project, Room } from '../src/lib/types';
|
|
import angled from '../tests/fixtures/angled-room.json';
|
|
import angledF8 from '../tests/fixtures/angled-room-f8.json';
|
|
|
|
export interface PlannerCase {
|
|
name: string;
|
|
project: Project;
|
|
}
|
|
|
|
const room = (width: number, height: number, id = 'room-1'): Room => {
|
|
const result = rectangle(id, id, width, height);
|
|
result.walls.forEach((wall) => (wall.doors = []));
|
|
return result;
|
|
};
|
|
|
|
export function plannerCases(): PlannerCase[] {
|
|
const cases: PlannerCase[] = [];
|
|
const add = (name: string, rooms: Room[], changes: Partial<Project['flooring']> = {}) => {
|
|
const project = defaultProject();
|
|
project.rooms = rooms;
|
|
project.flooring = { ...project.flooring, pattern: 'random', ...changes };
|
|
cases.push({ name, project });
|
|
};
|
|
for (const pattern of ['brick', 'random'] as const) {
|
|
add(`rectangle-${pattern}`, [rectangle()], { pattern });
|
|
add(`fireplace-${pattern}`, [fireplace('room-2', 'Fireplace')], { pattern });
|
|
add(`rotated-${pattern}`, [{ ...fireplace('room-2', 'Fireplace'), direction: 90 }], {
|
|
pattern,
|
|
});
|
|
}
|
|
// Fixed arithmetic sequences cover a range of remainders without runtime randomness.
|
|
for (let i = 0; i < 45; i++) {
|
|
add(`rectangle-${i + 1}`, [room(1620 + ((i * 733) % 3800), 620 + ((i * 379) % 1900))], {
|
|
width: 200,
|
|
});
|
|
}
|
|
for (let i = 0; i < 12; i++) {
|
|
const rooms = [
|
|
room(1320 + ((i * 271) % 1900), 620 + ((i * 317) % 1200), 'r0'),
|
|
room(1420 + ((i * 653) % 2100), 820 + ((i * 211) % 1200), 'r1'),
|
|
];
|
|
add(`two-rooms-${i + 1}`, rooms, { width: 200 });
|
|
add(`two-rooms-reversed-${i + 1}`, [...rooms].reverse(), { width: 200 });
|
|
}
|
|
add('balanced-edges', [room(4020, 2050)], { width: 200 });
|
|
add('tight-offsets', [room(4020, 2220)], { minOffset: 250, maxOffset: 450 });
|
|
add('exact-offset', [room(4020, 2220)], { minOffset: 400, maxOffset: 400 });
|
|
add('forced-alternation', [room(2420, 1620)], { width: 200, minLength: 600 });
|
|
add('fractional-stock', [room(620, 420, 'r0'), room(617.2, 420, 'r1')], {
|
|
length: 1200.2,
|
|
width: 200,
|
|
});
|
|
add('large-rectangle', [room(14020, 8020)]);
|
|
add('long-room', [room(30020, 1820)]);
|
|
cases.push(
|
|
{ name: 'angled', project: angled.project as Project },
|
|
{ name: 'angled-f8', project: angledF8.project as Project },
|
|
);
|
|
return cases;
|
|
}
|