import { Timeline } from "../../../game/player/Tasks"; import { Action } from "./action"; import { LiveGameEventToken } from "../types"; import { GameHistoryManager } from "./gameHistory"; import { StackModel, StackModelRawData } from "./stackModel"; import type { LiveGame } from "../game/liveGame"; export type ActionHistory = any> = { action: Action; timeline?: Timeline; args: T; id: string; undo?: (...args: T) => void; rootStackSnapshot: StackModelRawData; stackModel: StackModel; }; export type ActionHistoryPushOptions = { timeline?: Timeline; stackModel: StackModel; action: Action; }; export declare class ActionHistoryManager { readonly liveGame: LiveGame; private history; private readonly maxHistorySize; private hooks; constructor(maxHistorySize: number | undefined, liveGame: LiveGame); /** * Push an action to the history */ push = Array>(props: ActionHistoryPushOptions, onUndo?: (...args: T) => void, args?: T): { id: string; }; /** * Undo all actions until the given id * * If the given id is not found, nothing will happen * @param id random id generated by push */ undoUntil(id: string): ActionHistory | null; undo(gameHistory: GameHistoryManager): ActionHistory | null; ableToUndo(gameHistory: GameHistoryManager): boolean; onUndo(callback: (affected: ActionHistory[]) => void): LiveGameEventToken; offUndo(callback: (affected: ActionHistory[]) => void): void; getHistory(): ActionHistory[]; onHistoryLimit(callback: (removed: ActionHistory[]) => void): LiveGameEventToken; offHistoryLimit(callback: (removed: ActionHistory[]) => void): void; reset(): void; }