Fix flipped from and to checks.

This commit is contained in:
yukirij 2024-08-18 18:38:55 -07:00
parent 2d195a7f79
commit a883474609

View File

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