Added checkmate and stalemate notification through dialog, changed icon
This commit is contained in:
parent
51f3fd8980
commit
490db60d6b
@ -3,6 +3,8 @@ package dev.kske.chess.game;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import dev.kske.chess.board.Board;
|
import dev.kske.chess.board.Board;
|
||||||
import dev.kske.chess.board.GameState;
|
import dev.kske.chess.board.GameState;
|
||||||
import dev.kske.chess.board.Move;
|
import dev.kske.chess.board.Move;
|
||||||
@ -78,7 +80,9 @@ public class Game {
|
|||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
case CHECKMATE:
|
case CHECKMATE:
|
||||||
case STALEMATE:
|
case STALEMATE:
|
||||||
System.out.printf("%s in %s!%n", player.color.opposite(), eventType);
|
String result = String.format("%s in %s!%n", player.color.opposite(), eventType);
|
||||||
|
System.out.print(result);
|
||||||
|
JOptionPane.showMessageDialog(boardComponent, result);
|
||||||
break;
|
break;
|
||||||
case CHECK:
|
case CHECK:
|
||||||
System.out.printf("%s in check!%n", player.color.opposite());
|
System.out.printf("%s in check!%n", player.color.opposite());
|
||||||
|
@ -59,7 +59,7 @@ public class MainWindow {
|
|||||||
mframe.setBounds(100, 100, 494, 565);
|
mframe.setBounds(100, 100, 494, 565);
|
||||||
mframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
mframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
mframe.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/pieces/king_white.png")));
|
mframe.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/pieces/queen_white.png")));
|
||||||
|
|
||||||
boardPane = new BoardPane();
|
boardPane = new BoardPane();
|
||||||
mframe.getContentPane().add(boardPane, BorderLayout.CENTER);
|
mframe.getContentPane().add(boardPane, BorderLayout.CENTER);
|
||||||
|
Reference in New Issue
Block a user