almost
This commit is contained in:
@@ -78,8 +78,7 @@ class Board {
|
||||
}
|
||||
|
||||
// Clear moves from screen.
|
||||
void undisplayMoves(Coord coord) {
|
||||
ArrayList<Coord> moves = this.get(coord).moves(coord);
|
||||
void undisplayMoves(ArrayList<Coord> moves) {
|
||||
for (Coord move : moves) this.info.remove(move);
|
||||
}
|
||||
|
||||
|
@@ -10,22 +10,24 @@ class Player extends Actor {
|
||||
|
||||
void click(Coord coord) {
|
||||
if (this.board.get(coord) == null) {
|
||||
if (this.selected == null) return;
|
||||
ArrayList<Coord> moves = this.board.getMoves(this.selected);
|
||||
if (moves.contains(coord)) {
|
||||
this.board.move(this.selected, coord);
|
||||
}
|
||||
this.board.unselect(this.selected);
|
||||
this.board.undisplayMoves(this.selected);
|
||||
this.board.undisplayMoves(moves);
|
||||
this.selected = null;
|
||||
return;
|
||||
};
|
||||
|
||||
// Click while something selected.
|
||||
if (this.selected != null) {
|
||||
System.err.println("here");
|
||||
ArrayList<Coord> moves = this.board.getMoves(this.selected);
|
||||
// Click on same piece -- unselect.
|
||||
if (this.selected.equals(coord)) {
|
||||
} else if (this.board.getMoves(this.selected).contains(coord)) {
|
||||
this.board.move(this.selected, coord);
|
||||
}
|
||||
if (this.selected.equals(coord)) {}
|
||||
this.board.unselect(this.selected);
|
||||
this.board.undisplayMoves(this.selected);
|
||||
this.board.undisplayMoves(moves);
|
||||
this.selected = null;
|
||||
return;
|
||||
} else {
|
||||
@@ -37,7 +39,7 @@ class Player extends Actor {
|
||||
}
|
||||
|
||||
void key(String key) {
|
||||
this.board.undisplayMoves(this.selected);
|
||||
this.board.undisplayMoves(this.board.getMoves(this.selected));
|
||||
this.board.unselect(this.selected);
|
||||
this.selected = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user