kida fixed promotion
parent
8cb621d804
commit
64cf321511
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ public class Game {
|
||||||
public void doPromotionMove(int piece, Square origin, Square destination) {
|
public void doPromotionMove(int piece, Square origin, Square destination) {
|
||||||
System.out.println(piece);
|
System.out.println(piece);
|
||||||
Piece promotedTo;
|
Piece promotedTo;
|
||||||
switch(piece) {
|
switch (piece) {
|
||||||
case 7:
|
case 7:
|
||||||
promotedTo = Piece.BLACK_KNIGHT;
|
promotedTo = Piece.BLACK_KNIGHT;
|
||||||
break;
|
break;
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue