fix
parent
cbad409db7
commit
5e81b65f51
|
|
@ -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);
|
||||
|
||||
|
|
@ -93,7 +94,7 @@ public class Game {
|
|||
this.board.loadFromFen(fen);
|
||||
|
||||
this.movelist = new MoveList();
|
||||
//this.sp = new SpielFrame();
|
||||
// this.sp = new SpielFrame();
|
||||
|
||||
// this.clockPlayer1 = new Clock();
|
||||
// this.clockPlayer2 = new Clock();
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -267,7 +243,7 @@ public class Game {
|
|||
}
|
||||
|
||||
public boolean movesNotNull() {
|
||||
if(movelist.getLast() != null) {
|
||||
if (movelist.getLast() != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,9 +285,8 @@ public class SpielFrame extends JFrame {
|
|||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private int showPromotion() {
|
||||
final int[] result = {-1};
|
||||
|
||||
public int showPromotion() {
|
||||
final int[] result = { -1 };
|
||||
|
||||
JDialog dialog = new JDialog(this, "Wähle eine Figur", true);
|
||||
dialog.setLayout(new GridLayout(2, 2));
|
||||
|
|
@ -315,7 +313,6 @@ public class SpielFrame extends JFrame {
|
|||
return result[0];
|
||||
}
|
||||
|
||||
|
||||
private JPanel getUiPlayerTwo() {
|
||||
|
||||
JPanel playerTwo = new JPanel();
|
||||
|
|
@ -413,19 +410,19 @@ public class SpielFrame extends JFrame {
|
|||
sb.append("\n Bisherige Züge:\n");
|
||||
|
||||
MoveList l = game.getMoveList();
|
||||
for (Move m: l) {
|
||||
sb.append(" "+game.getUnicodeFromMove(m)+": "+m.toString()+"\n");
|
||||
for (Move m : l) {
|
||||
sb.append(" " + game.getUnicodeFromMove(m) + ": " + m.toString() + "\n");
|
||||
}
|
||||
|
||||
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;
|
||||
// es müssen immer mind 5 Zeilen existieren, dass also 1 Zug löschbar ist
|
||||
if (zeilen.length <= 2)
|
||||
return;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < zeilen.length - 1; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue