Skip to content

Commit

Permalink
hasAttackVector supports both colors now
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed Mar 28, 2016
1 parent 97054df commit 28a072a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/model/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ public boolean checkAttackDirection(Piece p, Direction X, Direction Y) {
* Used for validation of moves.
* If returns true after a player chooses a move,
* that move is invalid because the player can keep on attacking.
* We go by the convention that black starts out at the "bottom", and
* red starts out at the "top". Smoke moves before fire.
* @param p
* @return
*/
public boolean hasAttackVector(Piece p) {
boolean can_attack = false;
can_attack |= checkAttackDirection(p, Direction.UP, Direction.LEFT);
can_attack |= checkAttackDirection(p, Direction.UP, Direction.RIGHT);
if(p.getType().equals(Type.KING)) {
if (p.color.equals(Color.BLACK) || p.getType().equals(Type.KING)) {
can_attack |= checkAttackDirection(p, Direction.UP, Direction.LEFT);
can_attack |= checkAttackDirection(p, Direction.UP, Direction.RIGHT);
}
if (p.color.equals(Color.RED) || p.getType().equals(Type.KING)) {
can_attack |= checkAttackDirection(p, Direction.DOWN, Direction.LEFT);
can_attack |= checkAttackDirection(p, Direction.DOWN, Direction.RIGHT);
}
Expand Down

0 comments on commit 28a072a

Please sign in to comment.