import { cellKey } from './grid';

/** Immutable fog set algebra over the `revealed` cell-key array. */

export function applyReveal(revealed: string[], cells: string[]): string[] {
  return [...new Set([...revealed, ...cells])];
}

export function applyHide(revealed: string[], cells: string[]): string[] {
  const drop = new Set(cells);
  return revealed.filter((k) => !drop.has(k));
}

export function revealAll(cols: number, rows: number): string[] {
  const all: string[] = [];
  for (let c = 0; c < cols; c++) for (let r = 0; r < rows; r++) all.push(cellKey(c, r));
  return all;
}

export function hideAll(): string[] {
  return [];
}
