//! Frame-granularity input abstraction shared by replay and live play.

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Action {
    MoveLeft,
    MoveRight,
    SoftDrop,
    HardDrop,
    RotateCW,
    RotateCCW,
    Rotate180,
    Hold,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum InputKind {
    Down,
    Up,
}

#[derive(Clone, Copy, Debug)]
pub struct FrameInput {
    pub subframe: f64,
    pub kind: InputKind,
    pub action: Action,
    pub hoisted: bool,
}

/// Supplies the inputs for each frame to the engine.
pub trait InputSource {
    /// All inputs occurring during `frame` (the engine sorts them by subframe).
    fn frame_inputs(&mut self, frame: i32) -> Vec<FrameInput>;
    /// Whether the engine should process `frame` (replay: frame <= total; live: always).
    fn has_frame(&self, frame: i32) -> bool;
}
