Skip to main content

sokoban_elements/saved_game/
step.rs

1use crate::Direction;
2
3/// Single step of a pusher.
4#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum Step {
7    Move(Direction),
8    PushOrPull(Direction),
9    Jump(Direction),
10    PusherChange(Direction),
11}
12
13impl Step {
14    pub fn direction(&self) -> Direction {
15        match *self {
16            Step::Move(direction)
17            | Step::PushOrPull(direction)
18            | Step::PusherChange(direction)
19            | Step::Jump(direction) => direction,
20        }
21    }
22}