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