fix 2
Co-authored-by: Eirik Witterso <eirikwit@pvv.ntnu.no> Co-authored-by: Adrian Gunnar Lauterer <adriangl@pvv.ntnu.no>
This commit is contained in:
parent
a71e5b180d
commit
7debb20e4c
27
src/azul.rs
27
src/azul.rs
|
@ -129,9 +129,11 @@ impl GameState {
|
||||||
Ok(game)
|
Ok(game)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn set_ready(&mut self, player_name: &PlayerName) -> Result<(), &str> {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +337,8 @@ impl GameState {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
(c, _, Destination::PatternLine(l))
|
(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 =>
|
== true =>
|
||||||
{
|
{
|
||||||
return Err(MoveErr::Dst(
|
return Err(MoveErr::Dst(
|
||||||
|
@ -345,7 +348,11 @@ impl GameState {
|
||||||
(c, s, Destination::PatternLine(p)) => {
|
(c, s, Destination::PatternLine(p)) => {
|
||||||
let amount = self.take_tiles(s, c);
|
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 remaining_capacity = p + 1 - pattern_line.len();
|
||||||
let to_line = usize::min(amount, remaining_capacity);
|
let to_line = usize::min(amount, remaining_capacity);
|
||||||
|
@ -353,14 +360,18 @@ impl GameState {
|
||||||
|
|
||||||
pattern_line.color = Some(c);
|
pattern_line.color = Some(c);
|
||||||
pattern_line.number += to_line;
|
pattern_line.number += to_line;
|
||||||
self.players.get_mut(&self.current_player).unwrap()
|
self.players
|
||||||
|
.get_mut(&self.current_player)
|
||||||
|
.unwrap()
|
||||||
.floor
|
.floor
|
||||||
.add_color(c, to_floor as isize)
|
.add_color(c, to_floor as isize)
|
||||||
.map_err(|e| MoveErr::Other(e))?;
|
.map_err(|e| MoveErr::Other(e))?;
|
||||||
}
|
}
|
||||||
(c, s, Destination::Floor) => {
|
(c, s, Destination::Floor) => {
|
||||||
let amount = self.take_tiles(s, c);
|
let amount = self.take_tiles(s, c);
|
||||||
self.players.get_mut(&self.current_player).unwrap()
|
self.players
|
||||||
|
.get_mut(&self.current_player)
|
||||||
|
.unwrap()
|
||||||
.floor
|
.floor
|
||||||
.add_color(c, amount as isize)
|
.add_color(c, amount as isize)
|
||||||
.map_err(|e| MoveErr::Other(e))?;
|
.map_err(|e| MoveErr::Other(e))?;
|
||||||
|
@ -468,8 +479,8 @@ impl TileSet {
|
||||||
Color::Blue => self.blue,
|
Color::Blue => self.blue,
|
||||||
Color::Yellow => self.yellow,
|
Color::Yellow => self.yellow,
|
||||||
Color::Red => self.red,
|
Color::Red => self.red,
|
||||||
Color::Black => self.white,
|
Color::Black => self.black,
|
||||||
Color::White => self.black,
|
Color::White => self.white,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue