add support for custom start positions
parent
a506f2230d
commit
ff893396fe
|
|
@ -33,21 +33,24 @@ public class Game {
|
||||||
private String modus;
|
private String modus;
|
||||||
private boolean rotieren, zuruecknahme;
|
private boolean rotieren, zuruecknahme;
|
||||||
|
|
||||||
private MoveList savestate;
|
|
||||||
|
|
||||||
private MoveList movelist;
|
private MoveList movelist;
|
||||||
|
|
||||||
public Game() {
|
private MoveList savestate;
|
||||||
|
private String startPosFen;
|
||||||
this.board = new Board();
|
|
||||||
this.movelist = new MoveList();
|
|
||||||
clock = new Clock("blitz");
|
|
||||||
clock.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conststructs a new standard GameBoard.
|
* Conststructs a new standard GameBoard.
|
||||||
*/
|
*/
|
||||||
|
public Game() {
|
||||||
|
|
||||||
|
this.board = new Board();
|
||||||
|
this.movelist = new MoveList();
|
||||||
|
this.startPosFen = this.board.getFen();
|
||||||
|
|
||||||
|
clock = new Clock("blitz");
|
||||||
|
clock.start();
|
||||||
|
}
|
||||||
|
|
||||||
public Game(String modus, boolean rotieren, boolean zuruecknahme, String fen) {
|
public Game(String modus, boolean rotieren, boolean zuruecknahme, String fen) {
|
||||||
this.modus = modus;
|
this.modus = modus;
|
||||||
this.rotieren = rotieren;
|
this.rotieren = rotieren;
|
||||||
|
|
@ -60,6 +63,7 @@ public class Game {
|
||||||
|
|
||||||
this.board.loadFromFen(fen);
|
this.board.loadFromFen(fen);
|
||||||
|
|
||||||
|
this.startPosFen = this.board.getFen();
|
||||||
this.movelist = new MoveList();
|
this.movelist = new MoveList();
|
||||||
|
|
||||||
clock = new Clock(modus);
|
clock = new Clock(modus);
|
||||||
|
|
@ -76,6 +80,8 @@ public class Game {
|
||||||
public Game(MoveList movelist) {
|
public Game(MoveList movelist) {
|
||||||
this.board = new Board();
|
this.board = new Board();
|
||||||
|
|
||||||
|
this.startPosFen = this.board.getFen();
|
||||||
|
|
||||||
this.movelist = movelist;
|
this.movelist = movelist;
|
||||||
|
|
||||||
for (Move move : movelist) {
|
for (Move move : movelist) {
|
||||||
|
|
@ -96,6 +102,7 @@ public class Game {
|
||||||
this.board.loadFromFen(fen);
|
this.board.loadFromFen(fen);
|
||||||
|
|
||||||
this.movelist = new MoveList();
|
this.movelist = new MoveList();
|
||||||
|
this.startPosFen = this.board.getFen();
|
||||||
// this.sp = new SpielFrame();
|
// this.sp = new SpielFrame();
|
||||||
|
|
||||||
// this.clockPlayer1 = new Clock();
|
// this.clockPlayer1 = new Clock();
|
||||||
|
|
@ -125,18 +132,30 @@ public class Game {
|
||||||
this.movelist.removeLast();
|
this.movelist.removeLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copys the current move list to the savestate
|
||||||
|
*/
|
||||||
public void quicksave() {
|
public void quicksave() {
|
||||||
logger.info("Quicksaved");
|
// TODO: save the current clocktime
|
||||||
this.savestate = new MoveList(this.movelist);
|
this.savestate = new MoveList(this.movelist);
|
||||||
|
logger.info("Quicksaved");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the save state
|
||||||
|
*
|
||||||
|
* @brief creates a new board with the startPosFen and then plays all the moves
|
||||||
|
* from the savestate
|
||||||
|
*/
|
||||||
public void quickload() {
|
public void quickload() {
|
||||||
logger.info("Quickloaded");
|
|
||||||
|
|
||||||
this.board = new Board();
|
this.board = new Board();
|
||||||
|
this.board.loadFromFen(startPosFen);
|
||||||
|
|
||||||
for (Move move : savestate) {
|
for (Move move : savestate) {
|
||||||
this.playMove(move);
|
this.playMove(move);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("Quickloaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -404,6 +404,7 @@ public class SpielFrame extends JFrame {
|
||||||
|
|
||||||
statistik.add(scrollPane);
|
statistik.add(scrollPane);
|
||||||
|
|
||||||
|
// TODO: Buttons should be somewhere else
|
||||||
JButton quicksave = new JButton();
|
JButton quicksave = new JButton();
|
||||||
quicksave.addActionListener(new ButtonQuicksaveListener(this.game));
|
quicksave.addActionListener(new ButtonQuicksaveListener(this.game));
|
||||||
quicksave.setText("Quicksave");
|
quicksave.setText("Quicksave");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue