Improve game map formatting

This commit is contained in:
Pierre HUBERT 2022-10-07 10:38:56 +02:00
parent 7178b96077
commit 01ca2f50f4

View File

@ -24,11 +24,37 @@ impl<'a> Widget for GameMapWidget<'a> {
for x in 0..(self.rules.map_width + 1) { for x in 0..(self.rules.map_width + 1) {
let o_x = x as u16 * 2; let o_x = x as u16 * 2;
let o_y = y as u16 * 2; let o_y = y as u16 * 2;
buf.get_mut(o_x, o_y).set_symbol(symbols.cross); buf.get_mut(o_x, o_y).set_symbol(match (x, y) {
(0, 0) => symbols.top_left,
(x, 0) if x == self.rules.map_width => symbols.top_right,
(0, y) if y == self.rules.map_height => symbols.bottom_left,
(0, _) => symbols.vertical_right,
(_, 0) => symbols.horizontal_down,
(x, y) if x == self.rules.map_width && y == self.rules.map_height => {
symbols.bottom_right
}
(x, _) if x == self.rules.map_width => symbols.vertical_left,
(_, y) if y == self.rules.map_height => symbols.horizontal_up,
_ => symbols.cross,
});
if x < self.rules.map_width {
buf.get_mut(o_x + 1, o_y).set_symbol(symbols.horizontal); buf.get_mut(o_x + 1, o_y).set_symbol(symbols.horizontal);
}
if y < self.rules.map_height {
buf.get_mut(o_x, o_y + 1).set_symbol(symbols.vertical); buf.get_mut(o_x, o_y + 1).set_symbol(symbols.vertical);
}
if x < self.rules.map_width && y < self.rules.map_height {
buf.get_mut(o_x + 1, o_y + 1).set_char('.'); buf.get_mut(o_x + 1, o_y + 1).set_char('.');
} }
} }
} }
}
} }