Пример #1
0
 /**
  * Get the Chesspresso square index of the given location
  *
  * @param loc desired location
  * @return the square index, or Chess.NO_SQUARE if not on the board
  */
 int getSquareAt(Location loc) {
   if (!areaBoard.contains(loc)) {
     return Chess.NO_SQUARE;
   }
   int row = 0, col = 0;
   switch (rotation) {
     case NORTH:
       row = 7 - ((loc.getBlockX() - areaBoard.getLowerX()) / boardStyle.getSquareSize());
       col = 7 - ((loc.getBlockZ() - areaBoard.getLowerZ()) / boardStyle.getSquareSize());
       break;
     case EAST:
       row = 7 - ((loc.getBlockZ() - areaBoard.getLowerZ()) / boardStyle.getSquareSize());
       col = -((areaBoard.getLowerX() - loc.getBlockX()) / boardStyle.getSquareSize());
       break;
     case SOUTH:
       row = -((areaBoard.getLowerX() - loc.getBlockX()) / boardStyle.getSquareSize());
       col = -((areaBoard.getLowerZ() - loc.getBlockZ()) / boardStyle.getSquareSize());
       break;
     case WEST:
       row = -((areaBoard.getLowerZ() - loc.getBlockZ()) / boardStyle.getSquareSize());
       col = 7 - ((loc.getBlockX() - areaBoard.getLowerX()) / boardStyle.getSquareSize());
       break;
   }
   return Chess.coorToSqi(col, row);
 }