fix
parent
cbad409db7
commit
5e81b65f51
|
|
@ -53,7 +53,8 @@ public class Game {
|
||||||
|
|
||||||
this.board = new Board();
|
this.board = new Board();
|
||||||
|
|
||||||
if(fen == null) fen = board.getFen();
|
if (fen == null)
|
||||||
|
fen = board.getFen();
|
||||||
|
|
||||||
this.board.loadFromFen(fen);
|
this.board.loadFromFen(fen);
|
||||||
|
|
||||||
|
|
@ -93,7 +94,7 @@ public class Game {
|
||||||
this.board.loadFromFen(fen);
|
this.board.loadFromFen(fen);
|
||||||
|
|
||||||
this.movelist = new MoveList();
|
this.movelist = new MoveList();
|
||||||
//this.sp = new SpielFrame();
|
// this.sp = new SpielFrame();
|
||||||
|
|
||||||
// this.clockPlayer1 = new Clock();
|
// this.clockPlayer1 = new Clock();
|
||||||
// this.clockPlayer2 = new Clock();
|
// this.clockPlayer2 = new Clock();
|
||||||
|
|
@ -116,17 +117,12 @@ public class Game {
|
||||||
* @param origin The square from wich it moves from.
|
* @param origin The square from wich it moves from.
|
||||||
* @param desination The square where it will move to.
|
* @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() {
|
public void undo() {
|
||||||
this.board.undoMove();
|
this.board.undoMove();
|
||||||
this.movelist.removeLast();
|
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
|
||||||
*
|
*
|
||||||
|
|
@ -148,21 +144,6 @@ public class Game {
|
||||||
return board.isDraw();
|
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() {
|
public int getActivePlayer() {
|
||||||
if (board.getSideToMove() == Side.WHITE) {
|
if (board.getSideToMove() == Side.WHITE) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -249,11 +230,6 @@ public class Game {
|
||||||
playMove(promotionMove);
|
playMove(promotionMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFEN() {
|
|
||||||
//board.toString();
|
|
||||||
return board.getFen();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModus(String modus) {
|
public void setModus(String modus) {
|
||||||
this.modus = modus;
|
this.modus = modus;
|
||||||
}
|
}
|
||||||
|
|
@ -267,7 +243,7 @@ public class Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean movesNotNull() {
|
public boolean movesNotNull() {
|
||||||
if(movelist.getLast() != null) {
|
if (movelist.getLast() != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -290,6 +266,7 @@ public class Game {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return this.board;
|
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,7 +42,6 @@ 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);
|
||||||
|
|
@ -286,9 +285,8 @@ public class SpielFrame extends JFrame {
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int showPromotion() {
|
public int showPromotion() {
|
||||||
final int[] result = {-1};
|
final int[] result = { -1 };
|
||||||
|
|
||||||
|
|
||||||
JDialog dialog = new JDialog(this, "Wähle eine Figur", true);
|
JDialog dialog = new JDialog(this, "Wähle eine Figur", true);
|
||||||
dialog.setLayout(new GridLayout(2, 2));
|
dialog.setLayout(new GridLayout(2, 2));
|
||||||
|
|
@ -315,7 +313,6 @@ public class SpielFrame extends JFrame {
|
||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel getUiPlayerTwo() {
|
private JPanel getUiPlayerTwo() {
|
||||||
|
|
||||||
JPanel playerTwo = new JPanel();
|
JPanel playerTwo = new JPanel();
|
||||||
|
|
@ -413,19 +410,19 @@ public class SpielFrame extends JFrame {
|
||||||
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() {
|
public void deleteLastAusgabe() {
|
||||||
String[] zeilen = ausgabe.getText().split("\n");
|
String[] zeilen = ausgabe.getText().split("\n");
|
||||||
|
|
||||||
//es müssen immer mind 5 Zeilen existieren, dass also 1 Zug löschbar ist
|
// 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();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < zeilen.length - 1; i++) {
|
for (int i = 0; i < zeilen.length - 1; i++) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue