Skip to content

Commit

Permalink
feat(cli): add new option to format a maze to game map w/ start and g…
Browse files Browse the repository at this point in the history
…oal points
  • Loading branch information
unrenamed committed May 14, 2023
1 parent c0af057 commit 4784c42
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ enum OutputCommands {
/// ASCII character for a wall
#[arg(long, default_value_t = '#')]
wall: char,

/// With start "S" and goal "G" points randomly spawned on the borders
#[arg(long, default_value_t = false)]
with_start_goal: bool,
},
/// Save to PNG or JPG file
Image {
Expand Down Expand Up @@ -191,11 +195,22 @@ fn main() -> Result<(), maze::MazeSaveError> {
span,
passage,
wall,
with_start_goal,
} => {
result = maze.save(
output_path.as_str(),
maze::GameMap::new().span(span).passage(passage).wall(wall),
);
result = match with_start_goal {
true => maze.save(
output_path.as_str(),
maze::GameMap::new()
.span(span)
.passage(passage)
.wall(wall)
.with_start_goal(),
),
false => maze.save(
output_path.as_str(),
maze::GameMap::new().span(span).passage(passage).wall(wall),
),
};
}
OutputCommands::Image {
output_path,
Expand Down

0 comments on commit 4784c42

Please sign in to comment.