Compare commits
5 Commits
Main
...
TestingBra
| Author | SHA1 | Date |
|---|---|---|
|
|
18c8e73836 | |
|
|
9df9d5bbe9 | |
|
|
55cb25220e | |
|
|
350a5b43ea | |
|
|
0427a40b47 |
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
||||||
|
|
@ -11,11 +11,12 @@ import javax.swing.BorderFactory;
|
||||||
import com.github.bhlangonijr.chesslib.game.Game;
|
import com.github.bhlangonijr.chesslib.game.Game;
|
||||||
|
|
||||||
import de.hs_mannheim.informatik.chess.model.ChessEngine;
|
import de.hs_mannheim.informatik.chess.model.ChessEngine;
|
||||||
|
import de.hs_mannheim.informatik.chess.model.GameMode;
|
||||||
import de.hs_mannheim.informatik.chess.model.MoveDTO;
|
import de.hs_mannheim.informatik.chess.model.MoveDTO;
|
||||||
import de.hs_mannheim.informatik.chess.model.PieceDTO;
|
import de.hs_mannheim.informatik.chess.model.PieceDTO;
|
||||||
|
import de.hs_mannheim.informatik.chess.model.Timer;
|
||||||
import de.hs_mannheim.informatik.chess.model.BoardDTO;
|
import de.hs_mannheim.informatik.chess.model.BoardDTO;
|
||||||
import de.hs_mannheim.informatik.chess.view.GameGui;
|
import de.hs_mannheim.informatik.chess.view.GameGui;
|
||||||
import de.hs_mannheim.informatik.chess.view.MainGui;
|
|
||||||
|
|
||||||
public class GameController {
|
public class GameController {
|
||||||
GameGui gui;
|
GameGui gui;
|
||||||
|
|
@ -25,13 +26,24 @@ public class GameController {
|
||||||
private boolean gameOver = false;
|
private boolean gameOver = false;
|
||||||
private int selectedRow = -1, selectedCol = -1;
|
private int selectedRow = -1, selectedCol = -1;
|
||||||
private List<int[]> highlightedFields = new ArrayList<>();
|
private List<int[]> highlightedFields = new ArrayList<>();
|
||||||
|
private GameMode gameMode;
|
||||||
|
|
||||||
|
public GameController(GameGui gui, ChessEngine engine, GameEndCallback callback, GameMode gameMode) {
|
||||||
|
this(gui, engine, callback); // ruft anderen Konstruktor auf
|
||||||
|
this.gameMode = gameMode;
|
||||||
|
if (gameMode != null) {
|
||||||
|
engine.initTimers(gameMode.minutes, gameMode.incrementSeconds);
|
||||||
|
time();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Für Creative/PGN-Mode (ohne Zeit)
|
||||||
public GameController(GameGui gui, ChessEngine engine, GameEndCallback callback) {
|
public GameController(GameGui gui, ChessEngine engine, GameEndCallback callback) {
|
||||||
this.gui = gui;
|
this.gui = gui;
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
engine.initTimers(3, 0);
|
this.gameMode = null;
|
||||||
time();
|
// KEINE Timer initialisieren
|
||||||
initListeners();
|
initListeners();
|
||||||
updateGuiBoard();
|
updateGuiBoard();
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +138,6 @@ public class GameController {
|
||||||
// --- AUFGEBEN-BUTTON ---
|
// --- AUFGEBEN-BUTTON ---
|
||||||
gui.getResignButton().addActionListener(e -> {
|
gui.getResignButton().addActionListener(e -> {
|
||||||
if (gameOver) return;
|
if (gameOver) return;
|
||||||
|
|
||||||
int answer = javax.swing.JOptionPane.showConfirmDialog(
|
int answer = javax.swing.JOptionPane.showConfirmDialog(
|
||||||
null,
|
null,
|
||||||
"Willst du wirklich aufgeben?",
|
"Willst du wirklich aufgeben?",
|
||||||
|
|
@ -137,16 +148,14 @@ public class GameController {
|
||||||
gameOver = true;
|
gameOver = true;
|
||||||
String winner = engine.getCurrentPlayer().equals("WHITE") ? "SCHWARZ" : "WEIß";
|
String winner = engine.getCurrentPlayer().equals("WHITE") ? "SCHWARZ" : "WEIß";
|
||||||
gui.displayMessage(winner + " gewinnt durch Aufgabe!");
|
gui.displayMessage(winner + " gewinnt durch Aufgabe!");
|
||||||
engine.getWhiteTimer().stop();
|
if (engine.getWhiteTimer() != null) engine.getWhiteTimer().stop();
|
||||||
engine.getBlackTimer().stop();
|
if (engine.getBlackTimer() != null) engine.getBlackTimer().stop();
|
||||||
askForRestart();
|
askForRestart();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- PATT-/REMIS-BUTTON ---
|
|
||||||
gui.getDrawButton().addActionListener(e -> {
|
gui.getDrawButton().addActionListener(e -> {
|
||||||
if (gameOver) return;
|
if (gameOver) return;
|
||||||
|
|
||||||
int answer = javax.swing.JOptionPane.showConfirmDialog(
|
int answer = javax.swing.JOptionPane.showConfirmDialog(
|
||||||
null,
|
null,
|
||||||
"Remis anbieten? (Das Spiel endet sofort unentschieden)",
|
"Remis anbieten? (Das Spiel endet sofort unentschieden)",
|
||||||
|
|
@ -156,8 +165,8 @@ public class GameController {
|
||||||
if (answer == javax.swing.JOptionPane.YES_OPTION) {
|
if (answer == javax.swing.JOptionPane.YES_OPTION) {
|
||||||
gameOver = true;
|
gameOver = true;
|
||||||
gui.displayMessage("Remis! (durch Einigung)");
|
gui.displayMessage("Remis! (durch Einigung)");
|
||||||
engine.getWhiteTimer().stop();
|
if (engine.getWhiteTimer() != null) engine.getWhiteTimer().stop();
|
||||||
engine.getBlackTimer().stop();
|
if (engine.getBlackTimer() != null) engine.getBlackTimer().stop();
|
||||||
askForRestart();
|
askForRestart();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -279,6 +288,8 @@ public class GameController {
|
||||||
|
|
||||||
updateGuiBoard();
|
updateGuiBoard();
|
||||||
gui.updateMoveList(engine.getMoveListStringsGrouped());
|
gui.updateMoveList(engine.getMoveListStringsGrouped());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ---- HIER ist die Matt/Patt/Remis-Prüfung ----
|
// ---- HIER ist die Matt/Patt/Remis-Prüfung ----
|
||||||
if (engine.isMated()) {
|
if (engine.isMated()) {
|
||||||
|
|
@ -305,12 +316,25 @@ public class GameController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchTimers() {
|
private void switchTimers() {
|
||||||
|
GameMode mode = engine.getGameMode();
|
||||||
|
Timer whiteTimer = engine.getWhiteTimer();
|
||||||
|
Timer blackTimer = engine.getBlackTimer();
|
||||||
|
|
||||||
|
// Wenn KEIN Modus (also kein Timer): NICHTS machen!
|
||||||
|
if (mode == null || whiteTimer == null || blackTimer == null) return;
|
||||||
|
|
||||||
if (engine.getCurrentPlayer().equals("WHITE")) {
|
if (engine.getCurrentPlayer().equals("WHITE")) {
|
||||||
engine.getBlackTimer().stop();
|
if (mode.incrementSeconds > 0) {
|
||||||
engine.getWhiteTimer().start();
|
blackTimer.addSeconds(mode.incrementSeconds);
|
||||||
|
}
|
||||||
|
blackTimer.stop();
|
||||||
|
whiteTimer.start();
|
||||||
} else {
|
} else {
|
||||||
engine.getWhiteTimer().stop();
|
if (mode.incrementSeconds > 0) {
|
||||||
engine.getBlackTimer().start();
|
whiteTimer.addSeconds(mode.incrementSeconds);
|
||||||
|
}
|
||||||
|
whiteTimer.stop();
|
||||||
|
blackTimer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import de.hs_mannheim.informatik.chess.view.PgnGui;
|
||||||
import de.hs_mannheim.informatik.chess.view.PgnSelectionGui;
|
import de.hs_mannheim.informatik.chess.view.PgnSelectionGui;
|
||||||
import de.hs_mannheim.informatik.chess.view.CreativeGui;
|
import de.hs_mannheim.informatik.chess.view.CreativeGui;
|
||||||
import de.hs_mannheim.informatik.chess.view.GameGui;
|
import de.hs_mannheim.informatik.chess.view.GameGui;
|
||||||
|
import de.hs_mannheim.informatik.chess.view.GameModeSelector;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -15,6 +16,7 @@ import javax.swing.JOptionPane;
|
||||||
import com.github.bhlangonijr.chesslib.game.Game;
|
import com.github.bhlangonijr.chesslib.game.Game;
|
||||||
|
|
||||||
import de.hs_mannheim.informatik.chess.model.ChessEngine;
|
import de.hs_mannheim.informatik.chess.model.ChessEngine;
|
||||||
|
import de.hs_mannheim.informatik.chess.model.GameMode;
|
||||||
|
|
||||||
public class MainController {
|
public class MainController {
|
||||||
private MainGui mainGui;
|
private MainGui mainGui;
|
||||||
|
|
@ -28,9 +30,11 @@ public class MainController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startNormalMode() {
|
private void startNormalMode() {
|
||||||
|
|
||||||
|
GameMode mode = GameModeSelector.selectGameMode();
|
||||||
mainGui.close();
|
mainGui.close();
|
||||||
GameGui gameGui = new GameGui();
|
GameGui gameGui = new GameGui();
|
||||||
ChessEngine engine = new ChessEngine();
|
ChessEngine engine = new ChessEngine(mode);
|
||||||
GameEndCallback callback = new GameEndCallback() {
|
GameEndCallback callback = new GameEndCallback() {
|
||||||
public void onNewGameRequested() {
|
public void onNewGameRequested() {
|
||||||
startNormalMode();
|
startNormalMode();
|
||||||
|
|
@ -39,7 +43,7 @@ public class MainController {
|
||||||
new MainController();
|
new MainController();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new GameController(gameGui, engine, callback);
|
new GameController(gameGui, engine, callback,mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startCreativeMode() {
|
private void startCreativeMode() {
|
||||||
|
|
@ -49,21 +53,22 @@ public class MainController {
|
||||||
new CreativeController(creativegui, engine);
|
new CreativeController(creativegui, engine);
|
||||||
|
|
||||||
creativegui.setStartGameCallback(fen -> {
|
creativegui.setStartGameCallback(fen -> {
|
||||||
|
// 1. Modus-Auswahl-Dialog zeigen!
|
||||||
|
GameMode mode = GameModeSelector.selectGameMode(); // (Dialog, wie beim Normal Mode)
|
||||||
|
|
||||||
ChessEngine newEngine = new ChessEngine();
|
if (mode == null) return; // User hat abgebrochen → nichts machen
|
||||||
|
|
||||||
|
|
||||||
|
ChessEngine newEngine = new ChessEngine(mode); // Engine mit Modus (Timer)
|
||||||
newEngine.setPositionFromFEN(fen);
|
newEngine.setPositionFromFEN(fen);
|
||||||
|
|
||||||
GameGui gameGui = new GameGui();
|
GameGui gameGui = new GameGui();
|
||||||
|
|
||||||
GameEndCallback callback = new GameEndCallback() {
|
GameEndCallback callback = new GameEndCallback() {
|
||||||
public void onNewGameRequested() {
|
public void onNewGameRequested() { startCreativeMode(); }
|
||||||
startCreativeMode();
|
public void onReturnToMenu() { new MainController(); }
|
||||||
}
|
|
||||||
public void onReturnToMenu() {
|
|
||||||
new MainController();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
new GameController(gameGui, newEngine, callback);
|
new GameController(gameGui, newEngine, callback, mode); // mit Timer/ohne je nach Modus
|
||||||
|
creativegui.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,5 +91,6 @@ public class MainController {
|
||||||
JOptionPane.showMessageDialog(null, "Fehler beim Laden der PGN-Datei:\n" + ex.getMessage());
|
JOptionPane.showMessageDialog(null, "Fehler beim Laden der PGN-Datei:\n" + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mainGui.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,13 +31,24 @@ public class ChessEngine {
|
||||||
private int currentMoveIndex = 0;
|
private int currentMoveIndex = 0;
|
||||||
private Timer whiteTimer;
|
private Timer whiteTimer;
|
||||||
private Timer blackTimer;
|
private Timer blackTimer;
|
||||||
|
private final GameMode mode;
|
||||||
|
|
||||||
|
|
||||||
private Opening detectedOpening = null;
|
private Opening detectedOpening = null;
|
||||||
|
|
||||||
public ChessEngine() {
|
public ChessEngine() {
|
||||||
|
this.mode = null;
|
||||||
logging();
|
logging();
|
||||||
board = new Board();
|
board = new Board();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChessEngine(GameMode mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
whiteTimer = new Timer(mode.minutes, mode.seconds);
|
||||||
|
blackTimer = new Timer(mode.minutes, mode.seconds);
|
||||||
|
logging();
|
||||||
|
board = new Board();
|
||||||
|
}
|
||||||
public boolean move(MoveDTO move) {
|
public boolean move(MoveDTO move) {
|
||||||
String from = "" + (char)('A' + move.getFromCol()) + (8 - move.getFromRow());
|
String from = "" + (char)('A' + move.getFromCol()) + (8 - move.getFromRow());
|
||||||
String to = "" + (char)('A' + move.getToCol()) + (8 - move.getToRow());
|
String to = "" + (char)('A' + move.getToCol()) + (8 - move.getToRow());
|
||||||
|
|
@ -412,6 +423,17 @@ public class ChessEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timer getWhiteTimer() { return whiteTimer; }
|
public Timer getWhiteTimer() { return whiteTimer; }
|
||||||
|
|
||||||
public Timer getBlackTimer() { return blackTimer; }
|
public Timer getBlackTimer() { return blackTimer; }
|
||||||
|
|
||||||
|
|
||||||
|
public GameMode getGameMode() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package de.hs_mannheim.informatik.chess.model;
|
||||||
|
|
||||||
|
public enum GameMode {
|
||||||
|
CLASSIC(3, 0, 0),
|
||||||
|
RAPID(5, 0, 0),
|
||||||
|
BULLET(1, 0, 10); // 1 Minute + 10 Sek Inkrement
|
||||||
|
|
||||||
|
public final int minutes;
|
||||||
|
public final int seconds;
|
||||||
|
public final int incrementSeconds;
|
||||||
|
|
||||||
|
GameMode(int minutes, int seconds, int incrementSeconds) {
|
||||||
|
this.minutes = minutes;
|
||||||
|
this.seconds = seconds;
|
||||||
|
this.incrementSeconds = incrementSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return switch (this) {
|
||||||
|
case CLASSIC -> "3 Minuten (klassisch)";
|
||||||
|
case RAPID -> "5 Minuten (rapid)";
|
||||||
|
case BULLET -> "1 Minute + 10 Sek Inkrement";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -56,6 +56,10 @@ public class Timer {
|
||||||
public int getSecondsLeft() {
|
public int getSecondsLeft() {
|
||||||
return secondsLeft;
|
return secondsLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSeconds(int seconds) {
|
||||||
|
this.secondsLeft += seconds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ public class CreativeGui {
|
||||||
private JButton updateBtn;
|
private JButton updateBtn;
|
||||||
private JButton flipBoardButton;
|
private JButton flipBoardButton;
|
||||||
|
|
||||||
|
private boolean closedByUser = true;
|
||||||
|
|
||||||
private StartGameCallback startGameCallback;
|
private StartGameCallback startGameCallback;
|
||||||
|
|
||||||
private JButton startGameButton;
|
private JButton startGameButton;
|
||||||
|
|
@ -64,7 +66,16 @@ public class CreativeGui {
|
||||||
gbc.insets = new Insets(5, 0, 5, 5);
|
gbc.insets = new Insets(5, 0, 5, 5);
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
mainPanel.add(fenPanel(), gbc);
|
mainPanel.add(fenPanel(), gbc);
|
||||||
|
|
||||||
|
frame.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosed(java.awt.event.WindowEvent e) {
|
||||||
|
if (closedByUser) {
|
||||||
|
new de.hs_mannheim.informatik.chess.controller.MainController();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
frame.setContentPane(mainPanel);
|
frame.setContentPane(mainPanel);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
@ -207,6 +218,7 @@ public class CreativeGui {
|
||||||
|
|
||||||
startGameButton.addActionListener(e -> {
|
startGameButton.addActionListener(e -> {
|
||||||
if (startGameCallback != null) {
|
if (startGameCallback != null) {
|
||||||
|
setClosedByUser(false);
|
||||||
startGameCallback.onStartGame(getFenText());
|
startGameCallback.onStartGame(getFenText());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -222,6 +234,9 @@ public class CreativeGui {
|
||||||
public JButton getUpdateButton() { return updateBtn; }
|
public JButton getUpdateButton() { return updateBtn; }
|
||||||
public void setSelectedPiece(String piece) { selectedPiece = piece; }
|
public void setSelectedPiece(String piece) { selectedPiece = piece; }
|
||||||
public String getSelectedPiece() { return selectedPiece; }
|
public String getSelectedPiece() { return selectedPiece; }
|
||||||
|
public void setClosedByUser(boolean b) {
|
||||||
|
this.closedByUser = b;
|
||||||
|
}
|
||||||
|
|
||||||
public JButton getStartGameButton() { return startGameButton; }
|
public JButton getStartGameButton() { return startGameButton; }
|
||||||
|
|
||||||
|
|
@ -232,4 +247,8 @@ public class CreativeGui {
|
||||||
public boolean isFlipped() { return isFlipped; }
|
public boolean isFlipped() { return isFlipped; }
|
||||||
public void setFlipped(boolean f) { isFlipped = f; }
|
public void setFlipped(boolean f) { isFlipped = f; }
|
||||||
public JButton getFlipBoardButton() { return flipBoardButton; }
|
public JButton getFlipBoardButton() { return flipBoardButton; }
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
frame.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,8 +254,8 @@ public class GameGui {
|
||||||
JPanel panel = new JPanel(new GridLayout(2, 1));
|
JPanel panel = new JPanel(new GridLayout(2, 1));
|
||||||
panel.setBackground(new Color(0x0d1b2a));
|
panel.setBackground(new Color(0x0d1b2a));
|
||||||
|
|
||||||
whiteTimerLabel = new JLabel("Weiß: 03:00", SwingConstants.CENTER);
|
whiteTimerLabel = new JLabel("Weiß: --:--", SwingConstants.CENTER);
|
||||||
blackTimerLabel = new JLabel("Schwarz: 03:00", SwingConstants.CENTER);
|
blackTimerLabel = new JLabel("Schwarz: --:--", SwingConstants.CENTER);
|
||||||
|
|
||||||
whiteTimerLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
|
whiteTimerLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
|
||||||
whiteTimerLabel.setForeground(Color.WHITE);
|
whiteTimerLabel.setForeground(Color.WHITE);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package de.hs_mannheim.informatik.chess.view;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import de.hs_mannheim.informatik.chess.model.GameMode;
|
||||||
|
|
||||||
|
public class GameModeSelector {
|
||||||
|
|
||||||
|
public static GameMode selectGameMode() {
|
||||||
|
GameMode[] options = GameMode.values();
|
||||||
|
GameMode selected = (GameMode) JOptionPane.showInputDialog(
|
||||||
|
null,
|
||||||
|
"Wähle den Spielmodus:",
|
||||||
|
"Spielmodus auswählen",
|
||||||
|
JOptionPane.QUESTION_MESSAGE,
|
||||||
|
null,
|
||||||
|
options,
|
||||||
|
GameMode.CLASSIC
|
||||||
|
);
|
||||||
|
|
||||||
|
return selected != null ? selected : GameMode.CLASSIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -58,6 +58,12 @@ public class PgnGui {
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(2);
|
frame.setDefaultCloseOperation(2);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
frame.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosed(java.awt.event.WindowEvent e) {
|
||||||
|
new de.hs_mannheim.informatik.chess.controller.MainController();
|
||||||
|
}
|
||||||
|
});
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue