prettier board

This commit is contained in:
Julia Ryan 2025-09-11 11:43:33 -07:00
parent 672f9e09bf
commit 4506001dfc
No known key found for this signature in database

View file

@ -117,14 +117,6 @@ impl Default for GameState {
} }
} }
/*
what we're going for:
-- -- --
| | |P2|
-- -- --
|P1| | |
-- -- --
*/
impl Display for GameState { impl Display for GameState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!( writeln!(
@ -132,27 +124,31 @@ impl Display for GameState {
"P1: {}, P2: {}\n", "P1: {}, P2: {}\n",
self.p1.walls_left, self.p2.walls_left self.p1.walls_left, self.p2.walls_left
)?; )?;
writeln!(f, "┏━━┬━━┬━━┬━━┬━━┬━━┬━━┬━━┬━━┓")?;
for y in 0..9 { for y in 0..9 {
for x in 0..9 { if y > 0 {
if y > 0 { write!(f, "")?;
let wall = if !self.walls.can_walk_between(x, y - 1, x, y) { for x in 0..9 {
let wall = if self.walls.can_walk_between(x, y - 1, x, y) {
' ' ' '
} else { } else {
'-' ''
}; };
write!(f, "{wall}{wall}")?; write!(f, "{wall}{wall}")?;
if x != 8 {
write!(f, "")?;
}
} }
if x != 8 { write!(f, "\n")?;
write!(f, " ")?; } else {
} write!(f, "")?;
} }
writeln!(f, "")?;
for x in 0..9 { for x in 0..9 {
if x > 0 { 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 { } else {
'|' ''
}; };
write!(f, "{wall}")?; write!(f, "{wall}")?;
} }
@ -165,9 +161,9 @@ impl Display for GameState {
}; };
write!(f, "{player}")?; write!(f, "{player}")?;
} }
writeln!(f, "")?; writeln!(f, "")?;
} }
writeln!(f, "")?; writeln!(f, "┗━━┴━━┴━━┴━━┴━━┴━━┴━━┴━━┴━━┛")?;
Ok(()) Ok(())
} }
} }