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