@Override protected void onBoardClick( final PositionView positionPrevious, final PositionView positionCurrent) { if (!board.isBoardLocked()) { final Coordinate coordinatePrevious = positionPrevious.getCoordinate(); final Position previous = board.getPosition(coordinatePrevious); positionPrevious.unselect(); final Coordinate coordinateCurrent = positionCurrent.getCoordinate(); final Position current = board.getPosition(coordinateCurrent); if (board.move(previous, current)) { flush(); getSherlockActivity().supportInvalidateOptionsMenu(); final byte boardStatus = ((Board) board).isBoardInCheckOrCheckmate(); switch (boardStatus) { case Board.BOARD_NORMAL: // doing nothing in this case is fine for now break; case Board.BOARD_CHECK: boardIsInCheck(); break; case Board.BOARD_CHECKMATE: boardIsInCheckmate(); break; } } clearSelectedPositions(); } }
@Override protected void onBoardClick(final PositionView positionCurrent) { if (board.isBoardLocked()) { clearSelectedPositions(); } else { final Coordinate coordinateCurrent = positionCurrent.getCoordinate(); final Position current = board.getPosition(coordinateCurrent); if (current.hasPiece() && current.getPiece().isTeamPlayer()) { positionCurrent.select(); } else { clearSelectedPositions(); } } }
@Override protected void flush(final GenericPiece piece, final PositionView positionView) { switch (piece.getType()) { case Piece.TYPE_PAWN: if (piece.isTeamPlayer()) { positionView.setImageDrawable(playerPawn); } else { positionView.setImageDrawable(opponentPawn); } break; case Piece.TYPE_BISHOP: if (piece.isTeamPlayer()) { positionView.setImageDrawable(playerBishop); } else { positionView.setImageDrawable(opponentBishop); } break; case Piece.TYPE_KNIGHT: if (piece.isTeamPlayer()) { positionView.setImageDrawable(playerKnight); } else { positionView.setImageDrawable(opponentKnight); } break; case Piece.TYPE_ROOK: if (piece.isTeamPlayer()) { positionView.setImageDrawable(playerRook); } else { positionView.setImageDrawable(opponentRook); } break; case Piece.TYPE_QUEEN: if (piece.isTeamPlayer()) { positionView.setImageDrawable(playerQueen); } else { positionView.setImageDrawable(opponentQueen); } break; case Piece.TYPE_KING: if (piece.isTeamPlayer()) { positionView.setImageDrawable(playerKing); } else { positionView.setImageDrawable(opponentKing); } break; } }