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 {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(
@ -132,27 +124,31 @@ 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) {
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, " ")?;
write!(f, "")?;
}
}
writeln!(f, "")?;
write!(f, "\n")?;
} else {
write!(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}")?;
}
@ -165,9 +161,9 @@ impl Display for GameState {
};
write!(f, "{player}")?;
}
writeln!(f, "")?;
writeln!(f, "")?;
}
writeln!(f, "")?;
writeln!(f, "┗━━┴━━┴━━┴━━┴━━┴━━┴━━┴━━┴━━┛")?;
Ok(())
}
}