Fix bad promotion check.

This commit is contained in:
yukirij 2024-08-18 18:36:45 -07:00
parent e55a6cb258
commit 2d195a7f79

View File

@ -73,7 +73,7 @@ impl Game {
// Check for target promotion. // Check for target promotion.
let hex = Hex::from_tile(play.to); let hex = Hex::from_tile(play.to);
if !target.promoted && !Hex::is_back(hex.x, hex.y, target.player) { if !target.promoted && Hex::is_back(hex.x, hex.y, target.player) {
println!("promotion {} {} ({}, {})", target.class, play.to, hex.x, hex.y); println!("promotion {} {} ({}, {})", target.class, play.to, hex.x, hex.y);
target.promoted = true; target.promoted = true;
} }
@ -102,7 +102,7 @@ impl Game {
// Check for piece promotion. // Check for piece promotion.
let hex = Hex::from_tile(play.from); let hex = Hex::from_tile(play.from);
if !piece.promoted && !Hex::is_back(hex.x, hex.y, piece.player) { if !piece.promoted && Hex::is_back(hex.x, hex.y, piece.player) {
println!("promotion {} {} ({}, {})", piece.class, play.to, hex.x, hex.y); println!("promotion {} {} ({}, {})", piece.class, play.to, hex.x, hex.y);
if let Some(piece) = &mut self.board.pieces[pid as usize] { if let Some(piece) = &mut self.board.pieces[pid as usize] {
piece.promoted = true; piece.promoted = true;