fix
parent
cbad409db7
commit
5e81b65f51
|
|
@ -24,109 +24,105 @@ import de.mannheim.th.chess.utl.Clock;
|
||||||
* Steuerung davon.
|
* Steuerung davon.
|
||||||
*/
|
*/
|
||||||
public class Game {
|
public class Game {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(App.class);
|
|
||||||
|
|
||||||
private Board board;
|
private static final Logger logger = LogManager.getLogger(App.class);
|
||||||
private Clock clock;
|
|
||||||
private SpielFrame sp;
|
|
||||||
private String modus;
|
|
||||||
private boolean rotieren, zuruecknahme;
|
|
||||||
|
|
||||||
private MoveList movelist;
|
private Board board;
|
||||||
|
private Clock clock;
|
||||||
public Game() {
|
private SpielFrame sp;
|
||||||
|
private String modus;
|
||||||
this.board = new Board();
|
private boolean rotieren, zuruecknahme;
|
||||||
this.movelist = new MoveList();
|
|
||||||
clock = new Clock("blitz");
|
|
||||||
clock.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private MoveList movelist;
|
||||||
* Conststructs a new standard GameBoard.
|
|
||||||
*/
|
|
||||||
public Game(String modus, boolean rotieren, boolean zuruecknahme, String fen) {
|
|
||||||
this.modus = modus;
|
|
||||||
this.rotieren = rotieren;
|
|
||||||
this.zuruecknahme = zuruecknahme;
|
|
||||||
|
|
||||||
this.board = new Board();
|
|
||||||
|
|
||||||
if(fen == null) fen = board.getFen();
|
|
||||||
|
|
||||||
this.board.loadFromFen(fen);
|
|
||||||
|
|
||||||
this.movelist = new MoveList();
|
public Game() {
|
||||||
|
|
||||||
clock = new Clock(modus);
|
|
||||||
|
|
||||||
sp = new SpielFrame(this);
|
|
||||||
|
|
||||||
}
|
this.board = new Board();
|
||||||
|
this.movelist = new MoveList();
|
||||||
|
clock = new Clock("blitz");
|
||||||
|
clock.start();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new standard GameBoard and applies the provides moves.
|
* Conststructs a new standard GameBoard.
|
||||||
*
|
*/
|
||||||
* @param movelist The list of moves that get played.
|
public Game(String modus, boolean rotieren, boolean zuruecknahme, String fen) {
|
||||||
*/
|
this.modus = modus;
|
||||||
public Game(MoveList movelist) {
|
this.rotieren = rotieren;
|
||||||
this.board = new Board();
|
this.zuruecknahme = zuruecknahme;
|
||||||
|
|
||||||
this.movelist = movelist;
|
this.board = new Board();
|
||||||
|
|
||||||
for (Move move : movelist) {
|
if (fen == null)
|
||||||
this.board.doMove(move);
|
fen = board.getFen();
|
||||||
}
|
|
||||||
|
|
||||||
// this.clockPlayer1 = new Clock();
|
this.board.loadFromFen(fen);
|
||||||
// this.clockPlayer2 = new Clock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
this.movelist = new MoveList();
|
||||||
* Constructs a new GameBoard with the provided fen String as the positions.
|
|
||||||
*
|
|
||||||
* @param fen The fen String that provides the customs formation.
|
|
||||||
*/
|
|
||||||
public Game(String fen) {
|
|
||||||
this.board = new Board();
|
|
||||||
this.board.loadFromFen(fen);
|
|
||||||
|
|
||||||
this.movelist = new MoveList();
|
clock = new Clock(modus);
|
||||||
//this.sp = new SpielFrame();
|
|
||||||
|
|
||||||
// this.clockPlayer1 = new Clock();
|
sp = new SpielFrame(this);
|
||||||
// this.clockPlayer2 = new Clock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
}
|
||||||
* Plays the move on the board and adds it to the movelist
|
|
||||||
*
|
|
||||||
* @param move the move to be played
|
|
||||||
*/
|
|
||||||
public void playMove(Move move) {
|
|
||||||
this.board.doMove(move);
|
|
||||||
this.movelist.add(move);
|
|
||||||
clock.pressClock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays the move on the board and adds it to the movelist
|
* Constructs a new standard GameBoard and applies the provides moves.
|
||||||
*
|
*
|
||||||
* @param origin The square from wich it moves from.
|
* @param movelist The list of moves that get played.
|
||||||
* @param desination The square where it will move to.
|
*/
|
||||||
*/
|
public Game(MoveList movelist) {
|
||||||
public void playMove(Square origin, Square desination) {
|
this.board = new Board();
|
||||||
Move move = new Move(origin, desination);
|
|
||||||
this.board.doMove(move);
|
this.movelist = movelist;
|
||||||
this.movelist.add(move);
|
|
||||||
|
for (Move move : movelist) {
|
||||||
|
this.board.doMove(move);
|
||||||
|
}
|
||||||
|
|
||||||
|
// this.clockPlayer1 = new Clock();
|
||||||
|
// this.clockPlayer2 = new Clock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new GameBoard with the provided fen String as the positions.
|
||||||
|
*
|
||||||
|
* @param fen The fen String that provides the customs formation.
|
||||||
|
*/
|
||||||
|
public Game(String fen) {
|
||||||
|
this.board = new Board();
|
||||||
|
this.board.loadFromFen(fen);
|
||||||
|
|
||||||
|
this.movelist = new MoveList();
|
||||||
|
// this.sp = new SpielFrame();
|
||||||
|
|
||||||
|
// this.clockPlayer1 = new Clock();
|
||||||
|
// this.clockPlayer2 = new Clock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the move on the board and adds it to the movelist
|
||||||
|
*
|
||||||
|
* @param move the move to be played
|
||||||
|
*/
|
||||||
|
public void playMove(Move move) {
|
||||||
|
this.board.doMove(move);
|
||||||
|
this.movelist.add(move);
|
||||||
|
clock.pressClock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the move on the board and adds it to the movelist
|
||||||
|
*
|
||||||
|
* @param origin The square from wich it moves from.
|
||||||
|
* @param desination The square where it will move to.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void undo() {
|
||||||
|
this.board.undoMove();
|
||||||
|
this.movelist.removeLast();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void undo() {
|
|
||||||
this.board.undoMove();
|
|
||||||
this.movelist.removeLast();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Plays the move on the board and adds it to the movelist
|
* Plays the move on the board and adds it to the movelist
|
||||||
*
|
*
|
||||||
|
|
@ -155,30 +151,15 @@ public class Game {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMate() {
|
/**
|
||||||
return board.isMated();
|
* Retrieves a list of legal moves originating from the specified square.
|
||||||
}
|
*
|
||||||
|
* @param square The square from which to retrieve legal moves.
|
||||||
public boolean isDraw() {
|
*
|
||||||
return board.isDraw();
|
* @return A list of legal moves that originate from the specified square.
|
||||||
}
|
*/
|
||||||
|
public List<Move> getLegalMoves(Square square) {
|
||||||
public int getActivePlayer() {
|
return this.board.legalMoves().stream().filter(move -> move.getFrom() == square).collect(Collectors.toList());
|
||||||
if (board.getSideToMove() == Side.WHITE) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a list of legal moves originating from the specified square.
|
|
||||||
*
|
|
||||||
* @param square The square from which to retrieve legal moves.
|
|
||||||
*
|
|
||||||
* @return A list of legal moves that originate from the specified square.
|
|
||||||
*/
|
|
||||||
public List<Move> getLegalMoves(Square square) {
|
|
||||||
return this.board.legalMoves().stream().filter(move -> move.getFrom() == square).collect(Collectors.toList());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,14 +172,14 @@ public class Game {
|
||||||
(board.getPiece(move.getFrom()) == Piece.BLACK_PAWN || board.getPiece(move.getFrom()) == Piece.WHITE_PAWN));
|
(board.getPiece(move.getFrom()) == Piece.BLACK_PAWN || board.getPiece(move.getFrom()) == Piece.WHITE_PAWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a list of all legal moveable squares from the current board state.
|
* Retrieves a list of all legal moveable squares from the current board state.
|
||||||
*
|
*
|
||||||
* @return a List of Square objects representing all legal moveable squares.
|
* @return a List of Square objects representing all legal moveable squares.
|
||||||
*/
|
*/
|
||||||
public List<Square> getAllLegalMoveableSquares() {
|
public List<Square> getAllLegalMoveableSquares() {
|
||||||
return this.board.legalMoves().stream().map(move -> move.getFrom()).distinct().collect(Collectors.toList());
|
return this.board.legalMoves().stream().map(move -> move.getFrom()).distinct().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a list of legal moveable squares for a given square.
|
* Retrieves a list of legal moveable squares for a given square.
|
||||||
|
|
@ -249,47 +230,43 @@ public class Game {
|
||||||
playMove(promotionMove);
|
playMove(promotionMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFEN() {
|
public void setModus(String modus) {
|
||||||
//board.toString();
|
this.modus = modus;
|
||||||
return board.getFen();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setModus(String modus) {
|
public Clock getClock() {
|
||||||
this.modus = modus;
|
return this.clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Clock getClock() {
|
public boolean isZuruecknahme() {
|
||||||
return this.clock;
|
return zuruecknahme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isZuruecknahme() {
|
public boolean movesNotNull() {
|
||||||
return zuruecknahme;
|
if (movelist.getLast() != null) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
public boolean movesNotNull() {
|
return false;
|
||||||
if(movelist.getLast() != null) {
|
}
|
||||||
return true;
|
|
||||||
}
|
public String getFen() {
|
||||||
return false;
|
return this.board.getFen();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFen() {
|
public Move getLastMove() {
|
||||||
return this.board.getFen();
|
logger.info(this.movelist.getLast().toString());
|
||||||
}
|
return this.movelist.getLast();
|
||||||
|
}
|
||||||
public Move getLastMove() {
|
|
||||||
logger.info(this.movelist.getLast().toString());
|
public MoveList getMoveList() {
|
||||||
return this.movelist.getLast();
|
return this.movelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MoveList getMoveList() {
|
public Board getBoard() {
|
||||||
return this.movelist;
|
// TODO Auto-generated method stub
|
||||||
}
|
return this.board;
|
||||||
|
}
|
||||||
|
|
||||||
public Board getBoard() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return this.board;
|
|
||||||
}
|
|
||||||
public String toFEN() {
|
public String toFEN() {
|
||||||
board.toString();
|
board.toString();
|
||||||
return board.getFen();
|
return board.getFen();
|
||||||
|
|
@ -298,4 +275,8 @@ public class Game {
|
||||||
public Square getSelectedSquare() {
|
public Square getSelectedSquare() {
|
||||||
return this.getSelectedSquare();
|
return this.getSelectedSquare();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUnicodeFromMove(Move move) {
|
||||||
|
return board.getPiece(move.getTo()).getFanSymbol().toUpperCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,201 +42,200 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
|
||||||
|
|
||||||
public class SpielFrame extends JFrame {
|
public class SpielFrame extends JFrame {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(App.class);
|
private static final Logger logger = LogManager.getLogger(App.class);
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private ArrayList<JButton> buttons = new ArrayList<>();
|
private ArrayList<JButton> buttons = new ArrayList<>();
|
||||||
private HashMap<JButton, String> belegungen = new HashMap<>();
|
private HashMap<JButton, String> belegungen = new HashMap<>();
|
||||||
private JPanel panelLinks, panelRechts, contentPane;
|
private JPanel panelLinks, panelRechts, contentPane;
|
||||||
private JButton undo, undo2;
|
private JButton undo, undo2;
|
||||||
private JTextArea ausgabe;
|
private JTextArea ausgabe;
|
||||||
private Game game;
|
private Game game;
|
||||||
private Clock clock;
|
private Clock clock;
|
||||||
|
|
||||||
private BoardMode mode;
|
private BoardMode mode;
|
||||||
private Square selectedSquare;
|
private Square selectedSquare;
|
||||||
|
|
||||||
public enum BoardMode {
|
public enum BoardMode {
|
||||||
normal, pieceSelected, finished
|
normal, pieceSelected, finished
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
public SpielFrame(Game game) {
|
public SpielFrame(Game game) {
|
||||||
|
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.clock = game.getClock();
|
this.clock = game.getClock();
|
||||||
this.clock.start();
|
this.clock.start();
|
||||||
|
|
||||||
mode = BoardMode.normal;
|
mode = BoardMode.normal;
|
||||||
|
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 1920, 1080);
|
setBounds(100, 100, 1920, 1080);
|
||||||
setTitle("Schach");
|
setTitle("Schach");
|
||||||
setAlwaysOnTop(true);
|
setAlwaysOnTop(true);
|
||||||
|
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setLayout(new BorderLayout());
|
contentPane.setLayout(new BorderLayout());
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
|
|
||||||
// Linkes Panel mit GridLayout 8x8 für Schachbrett
|
// Linkes Panel mit GridLayout 8x8 für Schachbrett
|
||||||
panelLinks = new JPanel(new GridLayout(8, 8));
|
panelLinks = new JPanel(new GridLayout(8, 8));
|
||||||
|
|
||||||
erstelleBrett();
|
erstelleBrett();
|
||||||
|
|
||||||
// Rechtes Panel für Steuerung oder zusätzliche Eingaben
|
// Rechtes Panel für Steuerung oder zusätzliche Eingaben
|
||||||
panelRechts = new JPanel();
|
panelRechts = new JPanel();
|
||||||
panelRechts.setBackground(new Color(90, 90, 90));
|
panelRechts.setBackground(new Color(90, 90, 90));
|
||||||
panelRechts.setLayout(new BoxLayout(panelRechts, BoxLayout.Y_AXIS));
|
panelRechts.setLayout(new BoxLayout(panelRechts, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
// Panel für alle Eingaben von Player 2
|
// Panel für alle Eingaben von Player 2
|
||||||
panelRechts.add(getUiPlayerTwo());
|
panelRechts.add(getUiPlayerTwo());
|
||||||
|
|
||||||
// Panel für Statistikanzeigen
|
// Panel für Statistikanzeigen
|
||||||
panelRechts.add(getUiStatistik());
|
panelRechts.add(getUiStatistik());
|
||||||
|
|
||||||
// Panel für alle Eingaben von Player 1
|
// Panel für alle Eingaben von Player 1
|
||||||
panelRechts.add(getUiPlayerOne());
|
panelRechts.add(getUiPlayerOne());
|
||||||
|
|
||||||
// JSplitPane horizontal (linke und rechte Hälfte)
|
// JSplitPane horizontal (linke und rechte Hälfte)
|
||||||
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panelLinks, panelRechts);
|
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panelLinks, panelRechts);
|
||||||
splitPane.setResizeWeight(0.75);
|
splitPane.setResizeWeight(0.75);
|
||||||
splitPane.setBackground(Color.BLACK);
|
splitPane.setBackground(Color.BLACK);
|
||||||
splitPane.setDividerSize(1);
|
splitPane.setDividerSize(1);
|
||||||
splitPane.setEnabled(false);
|
splitPane.setEnabled(false);
|
||||||
|
|
||||||
contentPane.add(splitPane, BorderLayout.CENTER);
|
contentPane.add(splitPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Erstellt alle Buttons und fügt sie dem Frame hinzu.
|
* Erstellt alle Buttons und fügt sie dem Frame hinzu.
|
||||||
*/
|
*/
|
||||||
public void erstelleBrett() {
|
public void erstelleBrett() {
|
||||||
|
|
||||||
this.clearButtons();
|
this.clearButtons();
|
||||||
this.setDefaultBackground();
|
this.setDefaultBackground();
|
||||||
this.setButtonsActions();
|
this.setButtonsActions();
|
||||||
|
|
||||||
ladeBrett();
|
ladeBrett();
|
||||||
|
|
||||||
panelLinks.revalidate();
|
panelLinks.revalidate();
|
||||||
panelLinks.repaint();
|
panelLinks.repaint();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int mirrowedGrid(int i) {
|
private int mirrowedGrid(int i) {
|
||||||
return 63 - (((i / 8) * 8) + (7 - i % 8));
|
return 63 - (((i / 8) * 8) + (7 - i % 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* holt sich FEN-Zeichenkette und extrahiert daraus die Positionen der Figuren
|
* holt sich FEN-Zeichenkette und extrahiert daraus die Positionen der Figuren
|
||||||
*/
|
*/
|
||||||
private void ladeBrett() {
|
private void ladeBrett() {
|
||||||
// System.out.println(game.toFEN());
|
// System.out.println(game.toFEN());
|
||||||
|
|
||||||
char[] fen = game.toFEN().replaceAll("/", "").split(" ")[0].toCharArray();
|
char[] fen = game.toFEN().replaceAll("/", "").split(" ")[0].toCharArray();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (int j = 0; j < fen.length; j++) {
|
for (int j = 0; j < fen.length; j++) {
|
||||||
if (Character.isDigit(fen[j])) {
|
if (Character.isDigit(fen[j])) {
|
||||||
int leerfelder = Character.getNumericValue(fen[j]);
|
int leerfelder = Character.getNumericValue(fen[j]);
|
||||||
for (int k = 0; k < leerfelder; k++) {
|
for (int k = 0; k < leerfelder; k++) {
|
||||||
belegungen.put(buttons.get(i), "n-n");
|
belegungen.put(buttons.get(i), "n-n");
|
||||||
// buttons.get(i).setEnabled(false); // erstmal deaktivieren, weil leere Felder
|
// buttons.get(i).setEnabled(false); // erstmal deaktivieren, weil leere Felder
|
||||||
// nicht ckickbar sein sollten.
|
// nicht ckickbar sein sollten.
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else if (fen[j] >= 65 && fen[j] <= 90) { // ein Großbuchstabe, also
|
} else if (fen[j] >= 65 && fen[j] <= 90) { // ein Großbuchstabe, also
|
||||||
belegungen.put(buttons.get(i), "w-" + fen[j]);
|
belegungen.put(buttons.get(i), "w-" + fen[j]);
|
||||||
} else if (fen[j] >= 97 && fen[j] <= 122) { // ein Kleinbuchstabe, also
|
} else if (fen[j] >= 97 && fen[j] <= 122) { // ein Kleinbuchstabe, also
|
||||||
belegungen.put(buttons.get(i), "b-" + fen[j]);
|
belegungen.put(buttons.get(i), "b-" + fen[j]);
|
||||||
// buttons.get(i).setEnabled(false); // erstmal deaktivieren, damit weiß
|
// buttons.get(i).setEnabled(false); // erstmal deaktivieren, damit weiß
|
||||||
// beginnen kann
|
// beginnen kann
|
||||||
}
|
}
|
||||||
buttons.get(i).setIcon(new ImageIcon("src/main/resources/" + (int) fen[j] + ".png"));
|
buttons.get(i).setIcon(new ImageIcon("src/main/resources/" + (int) fen[j] + ".png"));
|
||||||
buttons.get(i).setDisabledIcon(new ImageIcon("src/main/resources/" + (int) fen[j] + ".png"));
|
buttons.get(i).setDisabledIcon(new ImageIcon("src/main/resources/" + (int) fen[j] + ".png"));
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the existing buttons from the button list, panellinks and fills them
|
* Clears the existing buttons from the button list, panellinks and fills them
|
||||||
* with new blank ones.
|
* with new blank ones.
|
||||||
*/
|
*/
|
||||||
private void clearButtons() {
|
private void clearButtons() {
|
||||||
|
|
||||||
buttons.clear();
|
buttons.clear();
|
||||||
panelLinks.removeAll();
|
panelLinks.removeAll();
|
||||||
|
|
||||||
for (int i = 0; i < 64; i++) {
|
for (int i = 0; i < 64; i++) {
|
||||||
JButton b = new JButton();
|
JButton b = new JButton();
|
||||||
|
|
||||||
b.setEnabled(false);
|
b.setEnabled(false);
|
||||||
|
|
||||||
// style
|
// style
|
||||||
b.setFocusPainted(false);
|
b.setFocusPainted(false);
|
||||||
b.setFont(new Font("Arial", Font.PLAIN, 30));
|
b.setFont(new Font("Arial", Font.PLAIN, 30));
|
||||||
b.setForeground(Color.WHITE);
|
b.setForeground(Color.WHITE);
|
||||||
b.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
b.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||||
b.setName(i + "");
|
b.setName(i + "");
|
||||||
|
|
||||||
buttons.add(b);
|
buttons.add(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default background color for the buttons in the grid.
|
* Sets the default background color for the buttons in the grid.
|
||||||
*/
|
*/
|
||||||
private void setDefaultBackground() {
|
private void setDefaultBackground() {
|
||||||
for (int i = 0; i < 64; i++) {
|
for (int i = 0; i < 64; i++) {
|
||||||
JButton b = buttons.get(i);
|
JButton b = buttons.get(i);
|
||||||
if ((i / 8 + i % 8) % 2 == 0) {
|
if ((i / 8 + i % 8) % 2 == 0) {
|
||||||
// logger.info("Helles Feld erstellt." + i);
|
// logger.info("Helles Feld erstellt." + i);
|
||||||
b.setBackground(new Color(90, 90, 90));
|
b.setBackground(new Color(90, 90, 90));
|
||||||
} else {
|
} else {
|
||||||
// logger.info("Dunkles Feld erstellt." + i);
|
// logger.info("Dunkles Feld erstellt." + i);
|
||||||
b.setBackground(new Color(65, 65, 65));
|
b.setBackground(new Color(65, 65, 65));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Switches the button actions depending on the boardmode
|
* Switches the button actions depending on the boardmode
|
||||||
*/
|
*/
|
||||||
private void setButtonsActions() {
|
private void setButtonsActions() {
|
||||||
|
|
||||||
List<Square> selectables;
|
List<Square> selectables;
|
||||||
|
|
||||||
switch (this.mode) {
|
switch (this.mode) {
|
||||||
case BoardMode.normal:
|
case BoardMode.normal:
|
||||||
|
|
||||||
selectables = game.getAllLegalMoveableSquares();
|
selectables = game.getAllLegalMoveableSquares();
|
||||||
|
|
||||||
for (Square square : selectables) {
|
for (Square square : selectables) {
|
||||||
JButton b = buttons.get(mirrowedGrid(square.ordinal()));
|
JButton b = buttons.get(mirrowedGrid(square.ordinal()));
|
||||||
b.setEnabled(true);
|
b.setEnabled(true);
|
||||||
// b.setBackground(Color.green);
|
// b.setBackground(Color.green);
|
||||||
b.addActionListener(new ButtonSelectPieceListener(this, square));
|
b.addActionListener(new ButtonSelectPieceListener(this, square));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BoardMode.pieceSelected:
|
case BoardMode.pieceSelected:
|
||||||
|
|
||||||
JButton s = buttons.get(mirrowedGrid(selectedSquare.ordinal()));
|
JButton s = buttons.get(mirrowedGrid(selectedSquare.ordinal()));
|
||||||
s.setEnabled(true);
|
s.setEnabled(true);
|
||||||
s.setBackground(new Color(165, 42, 42));
|
s.setBackground(new Color(165, 42, 42));
|
||||||
s.addActionListener(new ButtonToNormalListener(this));
|
s.addActionListener(new ButtonToNormalListener(this));
|
||||||
|
|
||||||
selectables = game.getLegalMoveableSquares(selectedSquare);
|
selectables = game.getLegalMoveableSquares(selectedSquare);
|
||||||
|
|
||||||
for (Square square : selectables) {
|
for (Square square : selectables) {
|
||||||
JButton b = buttons.get(mirrowedGrid(square.ordinal()));
|
JButton b = buttons.get(mirrowedGrid(square.ordinal()));
|
||||||
|
|
@ -252,47 +251,46 @@ public class SpielFrame extends JFrame {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (JButton b : buttons) {
|
for (JButton b : buttons) {
|
||||||
panelLinks.add(b);
|
panelLinks.add(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDraw() {
|
public void showDraw() {
|
||||||
JFrame frame = new JFrame("Result");
|
JFrame frame = new JFrame("Result");
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.setSize(300, 150);
|
frame.setSize(300, 150);
|
||||||
frame.setLayout(null);
|
frame.setLayout(null);
|
||||||
|
|
||||||
JLabel jl = new JLabel("1/2 - 1/2");
|
JLabel jl = new JLabel("1/2 - 1/2");
|
||||||
jl.setBounds(50, 30, 200, 25);
|
jl.setBounds(50, 30, 200, 25);
|
||||||
jl.setFont(new Font("Tahoma", Font.BOLD, 20));
|
jl.setFont(new Font("Tahoma", Font.BOLD, 20));
|
||||||
frame.add(jl);
|
frame.add(jl);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showWin(int player) {
|
public void showWin(int player) {
|
||||||
JFrame frame = new JFrame("Result");
|
JFrame frame = new JFrame("Result");
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.setSize(300, 150);
|
frame.setSize(300, 150);
|
||||||
frame.setLayout(null);
|
frame.setLayout(null);
|
||||||
|
|
||||||
JLabel jl = new JLabel(String.format("%d - %d", player / 2, player % 2));
|
JLabel jl = new JLabel(String.format("%d - %d", player / 2, player % 2));
|
||||||
jl.setBounds(50, 30, 200, 25);
|
jl.setBounds(50, 30, 200, 25);
|
||||||
jl.setFont(new Font("Tahoma", Font.BOLD, 20));
|
jl.setFont(new Font("Tahoma", Font.BOLD, 20));
|
||||||
frame.add(jl);
|
frame.add(jl);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int showPromotion() {
|
|
||||||
final int[] result = {-1};
|
|
||||||
|
|
||||||
|
public int showPromotion() {
|
||||||
JDialog dialog = new JDialog(this, "Wähle eine Figur", true);
|
final int[] result = { -1 };
|
||||||
dialog.setLayout(new GridLayout(2, 2));
|
|
||||||
dialog.setSize(300, 200);
|
JDialog dialog = new JDialog(this, "Wähle eine Figur", true);
|
||||||
|
dialog.setLayout(new GridLayout(2, 2));
|
||||||
|
dialog.setSize(300, 200);
|
||||||
|
|
||||||
int[] pictures = { 81, 82, 66, 78, 113, 114, 98, 110 };
|
int[] pictures = { 81, 82, 66, 78, 113, 114, 98, 110 };
|
||||||
|
|
||||||
|
|
@ -312,224 +310,223 @@ public class SpielFrame extends JFrame {
|
||||||
dialog.setLocationRelativeTo(null);
|
dialog.setLocationRelativeTo(null);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
|
|
||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel getUiPlayerTwo() {
|
private JPanel getUiPlayerTwo() {
|
||||||
|
|
||||||
JPanel playerTwo = new JPanel();
|
JPanel playerTwo = new JPanel();
|
||||||
playerTwo.setBackground(new Color(90, 90, 90));
|
playerTwo.setBackground(new Color(90, 90, 90));
|
||||||
playerTwo.setLayout(new BoxLayout(playerTwo, BoxLayout.Y_AXIS));
|
playerTwo.setLayout(new BoxLayout(playerTwo, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
playerTwo.add(Box.createVerticalStrut(15));
|
playerTwo.add(Box.createVerticalStrut(15));
|
||||||
|
|
||||||
JLabel pl2 = new JLabel("Player 2:");
|
JLabel pl2 = new JLabel("Player 2:");
|
||||||
pl2.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
|
pl2.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
|
||||||
pl2.setFont(new Font("Calibri", Font.BOLD, 35));
|
pl2.setFont(new Font("Calibri", Font.BOLD, 35));
|
||||||
pl2.setForeground(Color.BLACK);
|
pl2.setForeground(Color.BLACK);
|
||||||
pl2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
pl2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
playerTwo.add(pl2);
|
playerTwo.add(pl2);
|
||||||
|
|
||||||
playerTwo.add(Box.createVerticalStrut(10));
|
playerTwo.add(Box.createVerticalStrut(10));
|
||||||
|
|
||||||
JLabel clock1 = clock.getClock2();
|
JLabel clock1 = clock.getClock2();
|
||||||
playerTwo.add(clock1);
|
playerTwo.add(clock1);
|
||||||
|
|
||||||
playerTwo.add(Box.createVerticalStrut(10));
|
playerTwo.add(Box.createVerticalStrut(10));
|
||||||
|
|
||||||
// Button zurücknahme und aufgeben für Player 2
|
// Button zurücknahme und aufgeben für Player 2
|
||||||
JPanel aufgebenUndo = new JPanel();
|
JPanel aufgebenUndo = new JPanel();
|
||||||
aufgebenUndo.setBackground(new Color(90, 90, 90));
|
aufgebenUndo.setBackground(new Color(90, 90, 90));
|
||||||
aufgebenUndo.setLayout(new BoxLayout(aufgebenUndo, BoxLayout.X_AXIS));
|
aufgebenUndo.setLayout(new BoxLayout(aufgebenUndo, BoxLayout.X_AXIS));
|
||||||
|
|
||||||
if (game.isZuruecknahme()) {
|
if (game.isZuruecknahme()) {
|
||||||
undo = new JButton("Zug zurücknehmen");
|
undo = new JButton("Zug zurücknehmen");
|
||||||
undo.setBackground(Color.LIGHT_GRAY);
|
undo.setBackground(Color.LIGHT_GRAY);
|
||||||
undo.setForeground(Color.BLACK);
|
undo.setForeground(Color.BLACK);
|
||||||
undo.setFont(new Font("Tahoma", Font.BOLD, 16));
|
undo.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
undo.setAlignmentX(Component.CENTER_ALIGNMENT);
|
undo.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
aufgebenUndo.add(undo);
|
aufgebenUndo.add(undo);
|
||||||
|
|
||||||
// Button-Listener
|
// Button-Listener
|
||||||
undo.addActionListener(new ButtonUndoMoveListener(this, this.game));
|
undo.addActionListener(new ButtonUndoMoveListener(this, this.game));
|
||||||
}
|
}
|
||||||
|
|
||||||
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
||||||
|
|
||||||
JButton aufgeben = new JButton("Aufgeben");
|
JButton aufgeben = new JButton("Aufgeben");
|
||||||
aufgeben.setBackground(Color.LIGHT_GRAY);
|
aufgeben.setBackground(Color.LIGHT_GRAY);
|
||||||
aufgeben.setForeground(Color.BLACK);
|
aufgeben.setForeground(Color.BLACK);
|
||||||
aufgeben.setFont(new Font("Tahoma", Font.BOLD, 16));
|
aufgeben.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
aufgeben.setAlignmentX(Component.CENTER_ALIGNMENT);
|
aufgeben.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
aufgebenUndo.add(aufgeben);
|
aufgebenUndo.add(aufgeben);
|
||||||
|
|
||||||
// Button-Listener
|
// Button-Listener
|
||||||
aufgeben.addActionListener(new ButtonAufgebenListener());
|
aufgeben.addActionListener(new ButtonAufgebenListener());
|
||||||
|
|
||||||
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
||||||
|
|
||||||
JButton safe = new JButton("Spielstand sichern");
|
JButton safe = new JButton("Spielstand sichern");
|
||||||
safe.setBackground(Color.LIGHT_GRAY);
|
safe.setBackground(Color.LIGHT_GRAY);
|
||||||
safe.setForeground(Color.BLACK);
|
safe.setForeground(Color.BLACK);
|
||||||
safe.setFont(new Font("Tahoma", Font.BOLD, 16));
|
safe.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
safe.setAlignmentX(Component.CENTER_ALIGNMENT);
|
safe.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
aufgebenUndo.add(safe);
|
aufgebenUndo.add(safe);
|
||||||
|
|
||||||
// Button-Listener
|
// Button-Listener
|
||||||
safe.addActionListener(new ButtonFileSaverListener(this, this.game));
|
safe.addActionListener(new ButtonFileSaverListener(this, this.game));
|
||||||
|
|
||||||
playerTwo.add(aufgebenUndo);
|
playerTwo.add(aufgebenUndo);
|
||||||
|
|
||||||
playerTwo.add(Box.createVerticalStrut(10));
|
playerTwo.add(Box.createVerticalStrut(10));
|
||||||
|
|
||||||
return playerTwo;
|
return playerTwo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel getUiStatistik() {
|
private JPanel getUiStatistik() {
|
||||||
|
|
||||||
JPanel statistik = new JPanel();
|
JPanel statistik = new JPanel();
|
||||||
statistik.setBackground(new Color(90, 90, 90));
|
statistik.setBackground(new Color(90, 90, 90));
|
||||||
statistik.setLayout(new BoxLayout(statistik, BoxLayout.Y_AXIS));
|
statistik.setLayout(new BoxLayout(statistik, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
ausgabe = new JTextArea();
|
ausgabe = new JTextArea();
|
||||||
ausgabe.setEditable(false);
|
ausgabe.setEditable(false);
|
||||||
ausgabe.setBackground(new Color(75, 75, 75));
|
ausgabe.setBackground(new Color(75, 75, 75));
|
||||||
ausgabe.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
ausgabe.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||||
ausgabe.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 20));
|
ausgabe.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 20));
|
||||||
ausgabe.setForeground(Color.BLACK);
|
ausgabe.setForeground(Color.BLACK);
|
||||||
ausgabe.setText("\n Bisherige Züge:\n");
|
ausgabe.setText("\n Bisherige Züge:\n");
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane(ausgabe);
|
JScrollPane scrollPane = new JScrollPane(ausgabe);
|
||||||
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
|
|
||||||
statistik.add(scrollPane);
|
statistik.add(scrollPane);
|
||||||
|
|
||||||
return statistik;
|
return statistik;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void aktualisiereAusgabe() {
|
public void aktualisiereAusgabe() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("\n Bisherige Züge:\n");
|
sb.append("\n Bisherige Züge:\n");
|
||||||
|
|
||||||
MoveList l = game.getMoveList();
|
MoveList l = game.getMoveList();
|
||||||
for (Move m: l) {
|
for (Move m : l) {
|
||||||
sb.append(" "+game.getUnicodeFromMove(m)+": "+m.toString()+"\n");
|
sb.append(" " + game.getUnicodeFromMove(m) + ": " + m.toString() + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ausgabe.setText(sb.toString());
|
ausgabe.setText(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteLastAusgabe() {
|
||||||
|
String[] zeilen = ausgabe.getText().split("\n");
|
||||||
|
|
||||||
public void deleteLastAusgabe() {
|
// es müssen immer mind 5 Zeilen existieren, dass also 1 Zug löschbar ist
|
||||||
String[] zeilen = ausgabe.getText().split("\n");
|
if (zeilen.length <= 2)
|
||||||
|
return;
|
||||||
|
|
||||||
//es müssen immer mind 5 Zeilen existieren, dass also 1 Zug löschbar ist
|
StringBuilder sb = new StringBuilder();
|
||||||
if (zeilen.length <= 2) return;
|
for (int i = 0; i < zeilen.length - 1; i++) {
|
||||||
|
sb.append(zeilen[i]).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
ausgabe.setText(sb.toString());
|
||||||
for (int i = 0; i < zeilen.length - 1; i++) {
|
}
|
||||||
sb.append(zeilen[i]).append("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
ausgabe.setText(sb.toString());
|
private JPanel getUiPlayerOne() {
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel getUiPlayerOne() {
|
JPanel playerOne = new JPanel();
|
||||||
|
playerOne.setBackground(new Color(90, 90, 90));
|
||||||
|
playerOne.setLayout(new BoxLayout(playerOne, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
JPanel playerOne = new JPanel();
|
playerOne.add(Box.createVerticalStrut(10));
|
||||||
playerOne.setBackground(new Color(90, 90, 90));
|
|
||||||
playerOne.setLayout(new BoxLayout(playerOne, BoxLayout.Y_AXIS));
|
|
||||||
|
|
||||||
playerOne.add(Box.createVerticalStrut(10));
|
// Button zurücknahme und aufgeben für Player 1
|
||||||
|
JPanel aufgebenUndo = new JPanel();
|
||||||
|
aufgebenUndo.setBackground(new Color(90, 90, 90));
|
||||||
|
aufgebenUndo.setLayout(new BoxLayout(aufgebenUndo, BoxLayout.X_AXIS));
|
||||||
|
|
||||||
// Button zurücknahme und aufgeben für Player 1
|
if (game.isZuruecknahme()) {
|
||||||
JPanel aufgebenUndo = new JPanel();
|
undo2 = new JButton("Zug zurücknehmen");
|
||||||
aufgebenUndo.setBackground(new Color(90, 90, 90));
|
undo2.setBackground(Color.LIGHT_GRAY);
|
||||||
aufgebenUndo.setLayout(new BoxLayout(aufgebenUndo, BoxLayout.X_AXIS));
|
undo2.setForeground(Color.BLACK);
|
||||||
|
undo2.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
|
undo2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
aufgebenUndo.add(undo2);
|
||||||
|
|
||||||
if (game.isZuruecknahme()) {
|
// Button-Listener
|
||||||
undo2 = new JButton("Zug zurücknehmen");
|
undo2.addActionListener(new ButtonUndoMoveListener(this, this.game));
|
||||||
undo2.setBackground(Color.LIGHT_GRAY);
|
|
||||||
undo2.setForeground(Color.BLACK);
|
|
||||||
undo2.setFont(new Font("Tahoma", Font.BOLD, 16));
|
|
||||||
undo2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
||||||
aufgebenUndo.add(undo2);
|
|
||||||
|
|
||||||
// Button-Listener
|
}
|
||||||
undo2.addActionListener(new ButtonUndoMoveListener(this, this.game));
|
|
||||||
|
|
||||||
}
|
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
||||||
|
|
||||||
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
JButton aufgeben = new JButton("Aufgeben");
|
||||||
|
aufgeben.setBackground(Color.LIGHT_GRAY);
|
||||||
|
aufgeben.setForeground(Color.BLACK);
|
||||||
|
aufgeben.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
|
aufgeben.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
aufgebenUndo.add(aufgeben);
|
||||||
|
|
||||||
JButton aufgeben = new JButton("Aufgeben");
|
// Button-Listener
|
||||||
aufgeben.setBackground(Color.LIGHT_GRAY);
|
aufgeben.addActionListener(new ButtonAufgebenListener());
|
||||||
aufgeben.setForeground(Color.BLACK);
|
|
||||||
aufgeben.setFont(new Font("Tahoma", Font.BOLD, 16));
|
|
||||||
aufgeben.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
||||||
aufgebenUndo.add(aufgeben);
|
|
||||||
|
|
||||||
// Button-Listener
|
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
||||||
aufgeben.addActionListener(new ButtonAufgebenListener());
|
|
||||||
|
|
||||||
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
JButton safe = new JButton("Spielstand sichern");
|
||||||
|
safe.setBackground(Color.LIGHT_GRAY);
|
||||||
|
safe.setForeground(Color.BLACK);
|
||||||
|
safe.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
|
safe.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
aufgebenUndo.add(safe);
|
||||||
|
|
||||||
JButton safe = new JButton("Spielstand sichern");
|
// Button-Listener
|
||||||
safe.setBackground(Color.LIGHT_GRAY);
|
safe.addActionListener(new ButtonFileSaverListener(this, this.game));
|
||||||
safe.setForeground(Color.BLACK);
|
|
||||||
safe.setFont(new Font("Tahoma", Font.BOLD, 16));
|
|
||||||
safe.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
||||||
aufgebenUndo.add(safe);
|
|
||||||
|
|
||||||
// Button-Listener
|
playerOne.add(aufgebenUndo);
|
||||||
safe.addActionListener(new ButtonFileSaverListener(this, this.game));
|
|
||||||
|
|
||||||
playerOne.add(aufgebenUndo);
|
playerOne.add(Box.createVerticalStrut(15));
|
||||||
|
|
||||||
playerOne.add(Box.createVerticalStrut(15));
|
JLabel clock1 = clock.getClock1();
|
||||||
|
playerOne.add(clock1);
|
||||||
|
|
||||||
JLabel clock1 = clock.getClock1();
|
playerOne.add(Box.createVerticalStrut(10));
|
||||||
playerOne.add(clock1);
|
|
||||||
|
|
||||||
playerOne.add(Box.createVerticalStrut(10));
|
JLabel pl2 = new JLabel("Player 1:");
|
||||||
|
pl2.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
|
||||||
|
pl2.setFont(new Font("Calibri", Font.BOLD, 35));
|
||||||
|
pl2.setForeground(Color.BLACK);
|
||||||
|
pl2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
playerOne.add(pl2);
|
||||||
|
|
||||||
JLabel pl2 = new JLabel("Player 1:");
|
return playerOne;
|
||||||
pl2.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
|
}
|
||||||
pl2.setFont(new Font("Calibri", Font.BOLD, 35));
|
|
||||||
pl2.setForeground(Color.BLACK);
|
|
||||||
pl2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
||||||
playerOne.add(pl2);
|
|
||||||
|
|
||||||
return playerOne;
|
public void setBoardMode(BoardMode bm) {
|
||||||
}
|
this.mode = bm;
|
||||||
|
}
|
||||||
|
|
||||||
public void setBoardMode(BoardMode bm) {
|
public void setSelectedSquare(Square sq) {
|
||||||
this.mode = bm;
|
this.selectedSquare = sq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedSquare(Square sq) {
|
public HashMap<JButton, String> getBelegung() {
|
||||||
this.selectedSquare = sq;
|
return this.belegungen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<JButton, String> getBelegung() {
|
public JButton getUndo() {
|
||||||
return this.belegungen;
|
return undo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JButton getUndo() {
|
public JButton getUndo2() {
|
||||||
return undo;
|
return undo2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JButton getUndo2() {
|
public BoardMode getMode() {
|
||||||
return undo2;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoardMode getMode() {
|
public Clock getClock() {
|
||||||
return mode;
|
return clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Clock getClock() {
|
|
||||||
return clock;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue