/** * Draw the chess piece represented by stone into the given row and column. The actual blocks * drawn depend on the board's current chess set. * * @param row * @param col * @param stone */ public void paintChessPiece(int row, int col, int stone) { // for entity sets, just check that the entity is still at (row,col) // for block sets, get the stone and paste its data into the region at (row,col) ChessSet cSet = designer != null ? designer.getChessSet() : chessSet; if (cSet.hasMovablePieces()) { // we don't paint movable pieces; moveChessPiece() can handle those return; } Cuboid region = getPieceRegion(row, col); MassBlockUpdate mbu = CraftMassBlockUpdate.createMassBlockUpdater( ChessCraft.getInstance(), getBoard().getWorld()); region.fill(0, (byte) 0, mbu); if (stone != Chess.NO_STONE) { ChessStone cStone = cSet.getStone(stone, getRotation()); if (cStone != null) { cStone.paint(region, mbu); } else { LogUtils.severe("unknown chess stone " + stone); } } region.expand(CuboidDirection.Down, 1).forceLightLevel(boardStyle.getLightLevel()); mbu.notifyClients(); if (ChessCraft.getInstance().getDynmapIntegration() != null) { ChessCraft.getInstance().getDynmapIntegration().triggerUpdate(region); } }
/** * Board constructor. * * @param origin * @param rotation * @param boardStyleName * @param pieceStyleName * @throws ChessException */ public ChessBoard( Location origin, BoardRotation rotation, String boardStyleName, String pieceStyleName) throws ChessException { setBoardStyle(boardStyleName); setPieceStyle(pieceStyleName != null ? pieceStyleName : boardStyle.getPieceStyleName()); this.rotation = rotation; a1Center = new PersistableLocation(origin); a1Corner = initA1Corner(origin, rotation); h8Corner = initH8Corner(a1Corner.getLocation()); board = new Cuboid(a1Corner.getLocation(), h8Corner.getLocation()); areaBoard = board.expand(CuboidDirection.Up, boardStyle.getHeight()); frameBoard = board.outset(CuboidDirection.Horizontal, boardStyle.getFrameWidth()); aboveFullBoard = frameBoard .shift(CuboidDirection.Up, 1) .expand(CuboidDirection.Up, boardStyle.getHeight() - 1); fullBoard = frameBoard.expand(CuboidDirection.Up, boardStyle.getHeight() + 1); validateBoardPosition(); }
/** * Get the Cuboid region for this square <i>of the chessboard itself</i> * * @param row * @param col * @return a Cuboid representing the square */ public Cuboid getSquare(int row, int col) { if (row < 0 || col < 0 || row > 7 || col > 7) { throw new ChessException("ChessBoard: getSquare: bad (row, col): (" + row + "," + col + ")"); } Cuboid sq = new Cuboid(a1Corner.getLocation()); int s = boardStyle.getSquareSize(); CuboidDirection dir = rotation.getDirection(); CuboidDirection dirRight = rotation.getRight().getDirection(); sq = sq.shift(dir, row * s).shift(dirRight, col * s); sq = sq.expand(dir, s - 1).expand(dirRight, s - 1); return sq; }
/** * Draw the chess piece represented by stone into the given row and column. The actual blocks * drawn depend on the board's current chess set. * * @param row * @param col * @param stone */ public void paintChessPiece(int row, int col, int stone) { Cuboid region = getPieceRegion(row, col); MassBlockUpdate mbu = CraftMassBlockUpdate.createMassBlockUpdater(getBoard().getWorld()); region.fill(0, (byte) 0, mbu); ChessSet cSet = designer != null ? designer.getChessSet() : chessPieceSet; if (stone != Chess.NO_STONE) { ChessStone cStone = cSet.getStone(stone, getRotation()); if (cStone != null) { paintChessPiece(region, cStone, mbu); } else { LogUtils.severe("unknown piece: " + stone); } } region.expand(CuboidDirection.Down, 1).forceLightLevel(boardStyle.getLightLevel()); mbu.notifyClients(); }