dyske style base24 checkers

master
Ondřej Hruška 5 years ago
parent 185158cf7b
commit 4c795da09b
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 43
      src/main.rs

@ -53,29 +53,44 @@ impl Default for Game {
impl Display for Game { impl Display for Game {
fn fmt(&self, f : &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f : &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, " ")?; for n in (13..=24) {
for n in (13..=24) { write!(f, " {:2}", n)?; } write!(f, "{} ", ('D' as u8 + (n - 13) as u8) as char)?;
write!(f, "\n╭")?; }
write!(f, "\n")?;
for b in &self.bins[12..=23] { for (i, b) in (&self.bins[12..=23]).iter().enumerate() {
match *b { match *b {
Bin::Empty => write!(f, " ┈┈")?, Bin::Empty => {
Bin::Black(n) => write!(f, "{:2}#", n)?, if i%2==0 {
Bin::White(n) => write!(f, "{:2}:", n)? write!(f, "░░")?
} else {
write!(f, "▒▒")?
}
},
Bin::Black(n) => write!(f, "{:X}#", n)?,
Bin::White(n) => write!(f, "{:X}:", n)?
} }
} }
write!(f, " > {}:\n╰", self.players[Side::Black as usize].born_off)?; write!(f, "|:{}\n", self.players[Side::Black as usize].born_off)?;
for b in (&self.bins[0..=11]).iter().rev() { for (i, b) in (&self.bins[0..=11]).iter().rev().enumerate() {
match *b { match *b {
Bin::Empty => write!(f, " ┈┈")?, Bin::Empty => {
Bin::Black(n) => write!(f, "{:2}#", n)?, //█ if i%2==0 {
Bin::White(n) => write!(f, "{:2}:", n)? //░ write!(f, "░░")?
} else {
write!(f, "▒▒")?
}
},
Bin::Black(n) => write!(f, "{:X}#", n)?, //█
Bin::White(n) => write!(f, "{:X}:", n)? //░
} }
} }
write!(f, " > {}#\n ", self.players[Side::Black as usize].born_off)?; write!(f, "|#{}\n", self.players[Side::Black as usize].born_off)?;
for n in (1..=12).rev() { write!(f, " {:2}", n)?; } for n in (1..=12).rev() {
write!(f, "{:X} ", n)?;
}
write!(f, "\n")?; write!(f, "\n")?;
Ok(()) Ok(())

Loading…
Cancel
Save