All pastes #46496 Raw Edit

Miscellany

public text v1 · immutable
#46496 ·published 2006-03-21 16:36 UTC
rendered paste body
	/**
	* void move(Piece a, int x, int y)
	* This method moves a Chess piece to a desired location
	**/
	public void move(Piece a, int x, int y)
	{
		boardArray[x][y].setIcon(a.createImageIcon(a.getPath())); // Makes a new ImageIcon in the new coordinates.
		boardArray[a.getX()][a.getY()].setIcon(null); // Removes the old ImageIcon.
		pieceArray[x][y] = a;
		pieceArray[x][y].moved(); // Makes sure the Chess piece knows it's been moved.
		
		if(a.getOwner().getName().equals("One"))
		{
			this.currentPlayer = two;
			this.previouslySelected = null;
			currentPlayer.getUI().updateLabel(currentPlayer); // Updates the "Current Player: ..." JLabel. 
		}
		else
		{
			this.currentPlayer = one;
			this.previouslySelected = null;
			currentPlayer.getUI().updateLabel(currentPlayer); // Updates the "Current Player: ..." JLabel. 
		}
		
		pieceArray[x][y].setX(x);
		pieceArray[x][y].setY(y);
		
		System.err.println("After: " + " X " + pieceArray[x][y].getX() + "Y " + pieceArray[x][y].getY());
		pieceArray[a.getX()][a.getY()] = null; 
	}