use super::parser::Parser;
use crate::Direction;
pub(super) fn direction_to_char(direction: Direction, is_box_pushed: bool) -> char {
match (direction, is_box_pushed) {
(Direction::Left, true) => Parser::UPPER_L,
(Direction::Left, false) => Parser::LOWER_L,
(Direction::Up, true) => Parser::UPPER_U,
(Direction::Up, false) => Parser::LOWER_U,
(Direction::Right, true) => Parser::UPPER_R,
(Direction::Right, false) => Parser::LOWER_R,
(Direction::Down, true) => Parser::UPPER_D,
(Direction::Down, false) => Parser::LOWER_D,
(Direction::NorthWest, true) => Parser::UPPER_W,
(Direction::NorthWest, false) => Parser::LOWER_W,
(Direction::SouthEast, true) => Parser::UPPER_E,
(Direction::SouthEast, false) => Parser::LOWER_E,
(Direction::NorthEast, true) => Parser::UPPER_N,
(Direction::NorthEast, false) => Parser::LOWER_N,
(Direction::SouthWest, true) => Parser::UPPER_S,
(Direction::SouthWest, false) => Parser::LOWER_S,
}
}
pub(super) fn char_to_direction(move_char: char) -> Option<Direction> {
match move_char {
Parser::LOWER_L | Parser::UPPER_L => Some(Direction::Left),
Parser::LOWER_U | Parser::UPPER_U => Some(Direction::Up),
Parser::LOWER_R | Parser::UPPER_R => Some(Direction::Right),
Parser::LOWER_D | Parser::UPPER_D => Some(Direction::Down),
Parser::LOWER_W | Parser::UPPER_W => Some(Direction::NorthWest),
Parser::LOWER_E | Parser::UPPER_E => Some(Direction::SouthEast),
Parser::LOWER_N | Parser::UPPER_N => Some(Direction::NorthEast),
Parser::LOWER_S | Parser::UPPER_S => Some(Direction::SouthWest),
_ => None,
}
}