From 7debb20e4ca2a9dd9fb75d21be7aa39c64c07413 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sat, 24 Feb 2024 22:16:20 +0100 Subject: [PATCH] fix 2 Co-authored-by: Eirik Witterso Co-authored-by: Adrian Gunnar Lauterer --- src/azul.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/azul.rs b/src/azul.rs index 4bb24f7..62d1b89 100644 --- a/src/azul.rs +++ b/src/azul.rs @@ -129,9 +129,11 @@ impl GameState { Ok(game) } - pub fn set_ready(&mut self, player_name: &PlayerName) -> Result<(), &str> { - self.players.get_mut(player_name).ok_or("That player is not part of this game")?.ready = true; + self.players + .get_mut(player_name) + .ok_or("That player is not part of this game")? + .ready = true; Ok(()) } @@ -335,7 +337,8 @@ impl GameState { )) } (c, _, Destination::PatternLine(l)) - if self.players[&self.current_player].wall[l][Player::get_wall_index(l, c).unwrap()] + if self.players[&self.current_player].wall[l] + [Player::get_wall_index(l, c).unwrap()] == true => { return Err(MoveErr::Dst( @@ -345,7 +348,11 @@ impl GameState { (c, s, Destination::PatternLine(p)) => { let amount = self.take_tiles(s, c); - let pattern_line = &mut self.players.get_mut(&self.current_player).unwrap().pattern_lines[p]; + let pattern_line = &mut self + .players + .get_mut(&self.current_player) + .unwrap() + .pattern_lines[p]; let remaining_capacity = p + 1 - pattern_line.len(); let to_line = usize::min(amount, remaining_capacity); @@ -353,14 +360,18 @@ impl GameState { pattern_line.color = Some(c); pattern_line.number += to_line; - self.players.get_mut(&self.current_player).unwrap() + self.players + .get_mut(&self.current_player) + .unwrap() .floor .add_color(c, to_floor as isize) .map_err(|e| MoveErr::Other(e))?; } (c, s, Destination::Floor) => { let amount = self.take_tiles(s, c); - self.players.get_mut(&self.current_player).unwrap() + self.players + .get_mut(&self.current_player) + .unwrap() .floor .add_color(c, amount as isize) .map_err(|e| MoveErr::Other(e))?; @@ -468,8 +479,8 @@ impl TileSet { Color::Blue => self.blue, Color::Yellow => self.yellow, Color::Red => self.red, - Color::Black => self.white, - Color::White => self.black, + Color::Black => self.black, + Color::White => self.white, } }