示例#1
0
 public boolean validTake(Point start, Point end) {
   Piece piece = b.get(start);
   Piece ending = b.get(end);
   if (ending != null
       && piece.validCapture(start, end)
       && checkIfPathIsClear(start, end)
       && piece.getColor() != ending.getColor()) {
     return true;
   }
   return false;
 }
示例#2
0
 public boolean takePiece(Point startLocation, Point endLocation) {
   Piece piece = b.get(startLocation);
   Piece ending = b.get(endLocation);
   if (piece.validCapture(startLocation, endLocation)
       && checkIfPathIsClear(startLocation, endLocation)
       && piece.getColor() != ending.getColor()) {
     b.remove(endLocation);
     b.put(endLocation, b.get(startLocation));
     b.remove(startLocation);
     piece.setHasNotMoved(false);
     return true;
   }
   return false;
 }