kida fixed promotion

buttonActions
dstuck 2025-06-21 16:09:55 +02:00
parent 8cb621d804
commit 64cf321511
2 changed files with 58 additions and 51 deletions

View File

@ -22,7 +22,11 @@ public class ButtonMovePieceListener implements ActionListener {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (game.isPromotionMove(this.mv))
game.doPromotionMove(this.sf.showPromotion(), mv.getFrom(), mv.getTo());
else
this.game.playMove(this.mv); this.game.playMove(this.mv);
if (this.game.isDraw()) { if (this.game.isDraw()) {
this.game.stopClock(); this.game.stopClock();
this.sf.setBoardMode(BoardMode.finished); this.sf.setBoardMode(BoardMode.finished);

View File

@ -191,12 +191,15 @@ public class Game {
promotedTo = Piece.WHITE_QUEEN; promotedTo = Piece.WHITE_QUEEN;
} }
Move promotionMove = new Move(origin, destination, promotedTo); Move promotionMove = new Move(origin, destination, promotedTo);
board.doMove(promotionMove); playMove(promotionMove);
movelist.add(promotionMove);
} }
public String toFEN() { public String toFEN() {
board.toString(); board.toString();
return board.getFen(); return board.getFen();
} }
public Square getSelectedSquare() {
return this.getSelectedSquare();
}
} }