feat: add gameplay assists and variant generator

This commit is contained in:
2026-08-30 17:47:10 +02:00
parent 659640b231
commit 4a9869baa0
29 changed files with 2899 additions and 110 deletions
@@ -0,0 +1,37 @@
import { describe, expect, it } from "vitest";
import type { VariantConstraint } from "../../src/domain";
import {
removeKillerCagesAtCells,
replaceOverlappingKillerCages,
selectionTouchesKillerCage,
} from "../../src/components/constraintEditing";
const constraints: VariantConstraint[] = [
{ type: "killer-cage", cells: [0, 1], sum: 3 },
{ type: "killer-cage", cells: [2, 3], sum: 7 },
{ type: "thermo", cells: [0, 4] },
];
describe("setter cage editing", () => {
it("replaces every overlapping cage while preserving other rules", () => {
expect(
replaceOverlappingKillerCages(constraints, {
type: "killer-cage",
cells: [1, 2],
sum: 5,
}),
).toEqual([
{ type: "thermo", cells: [0, 4] },
{ type: "killer-cage", cells: [1, 2], sum: 5 },
]);
});
it("removes cages by any selected member cell", () => {
expect(removeKillerCagesAtCells(constraints, [1])).toEqual([
{ type: "killer-cage", cells: [2, 3], sum: 7 },
{ type: "thermo", cells: [0, 4] },
]);
expect(selectionTouchesKillerCage(constraints, [1])).toBe(true);
expect(selectionTouchesKillerCage(constraints, [4])).toBe(false);
});
});