You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.2 KiB
34 lines
1.2 KiB
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 |