devUi
stuckd 2025-06-24 10:24:42 +02:00
parent cbad409db7
commit 5e81b65f51
2 changed files with 480 additions and 502 deletions

View File

@ -53,7 +53,8 @@ public class Game {
this.board = new Board();
if(fen == null) fen = board.getFen();
if (fen == null)
fen = board.getFen();
this.board.loadFromFen(fen);
@ -116,17 +117,12 @@ public class Game {
* @param origin The square from wich it moves from.
* @param desination The square where it will move to.
*/
public void playMove(Square origin, Square desination) {
Move move = new Move(origin, desination);
this.board.doMove(move);
this.movelist.add(move);
}
public void undo() {
this.board.undoMove();
this.movelist.removeLast();
}
/**
* Plays the move on the board and adds it to the movelist
*
@ -148,21 +144,6 @@ public class Game {
return board.isDraw();
}
public int getActivePlayer() {
if (board.getSideToMove() == Side.WHITE) {
return 1;
}
return 2;
}
public boolean isMate() {
return board.isMated();
}
public boolean isDraw() {
return board.isDraw();
}
public int getActivePlayer() {
if (board.getSideToMove() == Side.WHITE) {
return 1;
@ -249,11 +230,6 @@ public class Game {
playMove(promotionMove);
}
public String toFEN() {
//board.toString();
return board.getFen();
}
public void setModus(String modus) {
this.modus = modus;
}
@ -290,6 +266,7 @@ public class Game {
// TODO Auto-generated method stub
return this.board;
}
public String toFEN() {
board.toString();
return board.getFen();
@ -298,4 +275,8 @@ public class Game {
public Square getSelectedSquare() {
return this.getSelectedSquare();
}
public String getUnicodeFromMove(Move move) {
return board.getPiece(move.getTo()).getFanSymbol().toUpperCase();
}
}

View File

@ -42,7 +42,6 @@ import java.util.HashMap;
import java.util.List;
import java.awt.GridLayout;
public class SpielFrame extends JFrame {
private static final Logger logger = LogManager.getLogger(App.class);
@ -286,10 +285,9 @@ public class SpielFrame extends JFrame {
frame.setVisible(true);
}
private int showPromotion() {
public int showPromotion() {
final int[] result = { -1 };
JDialog dialog = new JDialog(this, "Wähle eine Figur", true);
dialog.setLayout(new GridLayout(2, 2));
dialog.setSize(300, 200);
@ -315,7 +313,6 @@ public class SpielFrame extends JFrame {
return result[0];
}
private JPanel getUiPlayerTwo() {
JPanel playerTwo = new JPanel();
@ -420,12 +417,12 @@ public class SpielFrame extends JFrame {
ausgabe.setText(sb.toString());
}
public void deleteLastAusgabe() {
String[] zeilen = ausgabe.getText().split("\n");
// es müssen immer mind 5 Zeilen existieren, dass also 1 Zug löschbar ist
if (zeilen.length <= 2) return;
if (zeilen.length <= 2)
return;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < zeilen.length - 1; i++) {