Handle TileTake messages

This commit is contained in:
2023-03-21 10:22:03 +01:00
parent 5f92bdde4e
commit 5a8d4676f7
3 changed files with 28 additions and 1 deletions

View File

@@ -19,6 +19,10 @@ impl Board {
self.tiles[y * self.width + x] = Some(tile);
}
pub fn take(&mut self, x: usize, y: usize) -> Option<Tile> {
self.tiles[y * self.width + x].take()
}
/// Gets the difference between this board and another.
pub fn difference(&self, other: &Board) -> Vec<Position2d> {
let mut diff = Vec::new();

View File

@@ -49,6 +49,10 @@ impl Hand {
Ok(())
}
pub fn push(&mut self, tile: Tile) {
self.tiles.push(tile);
}
pub fn remove(&mut self, idx: usize) -> Option<Tile> {
if idx < self.tiles.len() {
Some(self.tiles.remove(idx))