Compare commits
2 Commits
634f932871
...
c57a0a8056
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c57a0a8056 | ||
![]() |
151f8d241d |
@@ -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,23 +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) {
|
||||
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)) {
|
||||
System.out.println("HHHHHHHHHHERE");
|
||||
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 {
|
||||
@@ -38,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