@logic-pad/core
Version:
44 lines (43 loc) • 1.73 kB
TypeScript
import { AnyConfig } from '../config.js';
import GridData from '../grid.js';
import { GridState, RuleState, Mode } from '../primitives.js';
import Rule, { SearchVariant } from './rule.js';
import { SetGridHandler } from '../events/onSetGrid.js';
import { FinalValidationHandler } from '../events/onFinalValidation.js';
export default class PerfectionRule extends Rule implements SetGridHandler, FinalValidationHandler {
readonly editor: boolean;
private static readonly EXAMPLE_GRID;
private static readonly SEARCH_VARIANTS;
/**
* **Quest for Perfection: cell colors are final**
*
* @param editor - whether to enable editor mode. This field is automatically set by the editor.
*/
constructor(editor?: boolean);
get id(): string;
get explanation(): string;
get configs(): readonly AnyConfig[] | null;
createExampleGrid(): GridData;
get searchVariants(): SearchVariant[];
get necessaryForCompletion(): boolean;
get isSingleton(): boolean;
modeVariant(mode: Mode): Rule | null;
validateGrid(grid: GridData): RuleState;
/**
* If the grid passes validation but is different from the solution, indicate the error in the final state.
*/
onFinalValidation(grid: GridData, solution: GridData | null, state: GridState): GridState;
private fixTiles;
private isValid;
private findSingleError;
/**
* Force all tiles to be fixed.
*
* If the grid is already wrong, prevent the player from changing it further.
*/
onSetGrid(oldGrid: GridData, newGrid: GridData, solution: GridData | null): GridData;
copyWith({ editor }: {
editor?: boolean;
}): this;
}
export declare const instance: PerfectionRule;