import {BaseAction} from "./BaseAction"; import {StorageCoordinates} from "../state/Coordinates"; import {AppAction} from "./AppAction"; export const CELL_COLOR = "CELL_COLOR" /** Sets the given tile to the given color, or erases it entirely. */ export interface CellColorAction extends BaseAction { readonly type: typeof CELL_COLOR /** The staggered (storage) coordinates of the tile to have its color changed */ readonly at: StorageCoordinates /** A color in #RRGGBBAA format. */ readonly color: string } export function isCellColorAction(action: AppAction): action is CellColorAction { return action.type === CELL_COLOR } export const CELL_REMOVE = "CELL_REMOVE" export interface CellRemoveAction extends BaseAction { readonly type: typeof CELL_REMOVE /** The staggered (storage) coordinates of the tile to be removed */ readonly at: StorageCoordinates } export function isRemoveCellAction(action: AppAction): action is CellRemoveAction { return action.type === CELL_REMOVE } export function isCellAction(action: AppAction): action is CellAction { return isRemoveCellAction(action) || isCellColorAction(action); } export type CellAction = CellColorAction | CellRemoveAction