UNPKG

@logic-pad/core

Version:
33 lines (32 loc) 965 B
import { State } from '../primitives.js'; import Symbol from './symbol.js'; /** * All symbols which contain a number should extend this class to be compatible with off by X rules. */ export default class NumberSymbol extends Symbol { x; y; number; constructor(x, y, number) { super(x, y); this.x = x; this.y = y; this.number = number; this.number = number; } validateSymbol(grid) { const countResult = this.countTiles(grid); if (countResult === null) return State.Error; const { completed, possible } = countResult; if (completed > this.number || possible < this.number) return State.Error; if (completed === this.number && possible === this.number) return State.Satisfied; return State.Incomplete; } withNumber(number) { return this.copyWith({ number }); } } export const instance = undefined;