Fix extent checking direction in move validation.

This commit is contained in:
yukirij 2024-10-11 19:18:55 -07:00
parent 20b2c03c0d
commit d0bad35995

View File

@ -578,18 +578,11 @@ impl Game {
pub fn get_drops(&self, piece:&Piece) -> Vec<Play> pub fn get_drops(&self, piece:&Piece) -> Vec<Play>
{ {
let mut piece = piece.clone();
let mut moves = Vec::new(); let mut moves = Vec::new();
for tile_id in 0..self.board.tiles.len() { for tile_id in 0..self.board.tiles.len() {
let tile = &self.board.tiles[tile_id]; if self.can_drop(&piece, tile_id as u8, flags::NONE) {
moves.push(Play::from_drop(piece.class, tile_id as u8));
if tile.piece.is_none() {
piece.tile = tile_id as u8;
if self.can_drop(&piece, tile_id as u8, flags::NONE) {
moves.push(Play::from_drop(piece.class, tile_id as u8));
}
} }
} }
@ -661,9 +654,9 @@ impl Game {
*/ */
if (flags & flags::IGNORE_EXTENT as u32) == 0 { if (flags & flags::IGNORE_EXTENT as u32) == 0 {
valid = valid && if piece.player == 0 { valid = valid && if piece.player == 0 {
hex.y > self.board.columns[hex.x as usize].extent[1] as i8 hex.y < self.board.columns[hex.x as usize].extent[1] as i8
} else { } else {
hex.y < self.board.columns[hex.x as usize].extent[0] as i8 hex.y > self.board.columns[hex.x as usize].extent[0] as i8
}; };
} }