Skip to content

Commit

Permalink
Inline Direction::gen
Browse files Browse the repository at this point in the history
  • Loading branch information
lunacookies committed Oct 16, 2023
1 parent f22b4a6 commit 6daf854
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
12 changes: 0 additions & 12 deletions crates/model/src/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,3 @@ impl TurnDirection {
}
}
}

impl Direction {
pub(crate) fn gen() -> Self {
match rng::gen_range(0..4) {
0 => Direction::Up,
1 => Direction::Down,
2 => Direction::Left,
3 => Direction::Right,
_ => unreachable!(),
}
}
}
9 changes: 8 additions & 1 deletion crates/model/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ impl Pipe {
}

fn gen_random_direction_and_position((columns, rows): (u16, u16)) -> (Direction, Position) {
let direction = Direction::gen();
let direction = match rng::gen_range(0..4) {
0 => Direction::Up,
1 => Direction::Down,
2 => Direction::Left,
3 => Direction::Right,
_ => unreachable!(),
};

let position = match direction {
Direction::Up => Position {
x: rng::gen_range_16(0..columns),
Expand Down

0 comments on commit 6daf854

Please sign in to comment.