@logic-pad/core
Version:
74 lines (73 loc) • 2.27 kB
TypeScript
import { z } from 'zod';
import GridData from './grid.js';
import { GridState, PuzzleType } from './primitives.js';
export type PuzzleMetadata = {
/**
* The title of the puzzle. (required)
*/
title: string;
/**
* The author of the puzzle. (required)
*/
author: string;
/**
* A description of the puzzle. (can be empty)
*/
description: string;
/**
* The difficulty of the puzzle, from 0 to 10. (required)
*
* 0 represents an unrated puzzle, 6-10 represent star difficulties.
*/
difficulty: number;
};
export declare const MetadataSchema: z.ZodObject<{
title: z.ZodString;
author: z.ZodString;
description: z.ZodString;
difficulty: z.ZodNumber;
}, z.core.$strict>;
export declare const PuzzleSchema: z.ZodObject<{
title: z.ZodString;
author: z.ZodString;
description: z.ZodString;
difficulty: z.ZodNumber;
grid: z.ZodCustom<GridData, GridData>;
solution: z.ZodNullable<z.ZodCustom<GridData, GridData>>;
}, z.core.$strict>;
export type PuzzleData = {
/**
* The grid of the puzzle. (required)
*
* You must fix all given cells in the grid. The rest of the cells will be cleared.
*/
grid: GridData;
/**
* The solution to the puzzle. (optional)
*
* You should provide a solution if a rule requires it. Otherwise, the rule can never be satisfied.
*
* If there are no rules that require a solution, this field will be ignored.
*/
solution: GridData | null;
};
export type Puzzle = PuzzleMetadata & PuzzleData;
/**
* Checks if two puzzles are equal.
*/
export declare function puzzleEquals(a: Puzzle, b: Puzzle): boolean;
/**
* Get the types of a puzzle based on its grid properties. The returned types are ordered by their priority.
* The first type is the most important one.
*/
export declare function getPuzzleTypes(grid: GridData): PuzzleType[];
export interface PuzzleChecklistItem {
id: string;
success: boolean;
mandatory: boolean;
}
export interface PuzzleChecklist {
items: PuzzleChecklistItem[];
isValid: boolean;
}
export declare function validatePuzzleChecklist(metadata: PuzzleMetadata, gridWithSolution: GridData, state: GridState): PuzzleChecklist;