prettier board
This commit is contained in:
parent
672f9e09bf
commit
d4e626d13c
1 changed files with 18 additions and 22 deletions
|
|
@ -117,14 +117,6 @@ impl Default for GameState {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
what we're going for:
|
||||
-- -- --
|
||||
| | |P2|
|
||||
-- -- --
|
||||
|P1| | |
|
||||
-- -- --
|
||||
*/
|
||||
impl Display for GameState {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
writeln!(
|
||||
|
|
@ -132,42 +124,46 @@ impl Display for GameState {
|
|||
"P1: {}, P2: {}\n",
|
||||
self.p1.walls_left, self.p2.walls_left
|
||||
)?;
|
||||
writeln!(f, "┏━━┬━━┬━━┬━━┬━━┬━━┬━━┬━━┬━━┓")?;
|
||||
for y in 0..9 {
|
||||
for x in 0..9 {
|
||||
if y > 0 {
|
||||
let wall = if !self.walls.can_walk_between(x, y - 1, x, y) {
|
||||
if y > 0 {
|
||||
write!(f, "├")?;
|
||||
for x in 0..9 {
|
||||
let wall = if self.walls.can_walk_between(x, y - 1, x, y) {
|
||||
' '
|
||||
} else {
|
||||
'-'
|
||||
'━'
|
||||
};
|
||||
write!(f, "{wall}{wall}")?;
|
||||
if x != 8 {
|
||||
write!(f, "╋")?;
|
||||
}
|
||||
}
|
||||
if x != 8 {
|
||||
write!(f, " ")?;
|
||||
}
|
||||
write!(f, "┤\n┃")?;
|
||||
} else {
|
||||
write!(f, "┃")?;
|
||||
}
|
||||
writeln!(f, "")?;
|
||||
for x in 0..9 {
|
||||
if x > 0 {
|
||||
let wall = if !self.walls.can_walk_between(x - 1, y, x, y) {
|
||||
let wall = if self.walls.can_walk_between(x - 1, y, x, y) {
|
||||
' '
|
||||
} else {
|
||||
'|'
|
||||
'┃'
|
||||
};
|
||||
write!(f, "{wall}")?;
|
||||
}
|
||||
let player = if self.p1.x() == x && self.p1.y() == y {
|
||||
let player = if self.p1.x() == x && 8 - self.p1.y() == y {
|
||||
"P1"
|
||||
} else if self.p2.x() == x && self.p2.y() == y {
|
||||
} else if self.p2.x() == x && 8 - self.p2.y() == y {
|
||||
"P2"
|
||||
} else {
|
||||
" "
|
||||
};
|
||||
write!(f, "{player}")?;
|
||||
}
|
||||
writeln!(f, "")?;
|
||||
writeln!(f, "┃")?;
|
||||
}
|
||||
writeln!(f, "")?;
|
||||
writeln!(f, "┗━━┴━━┴━━┴━━┴━━┴━━┴━━┴━━┴━━┛")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue