package com.devinhartzell.chess.pieces;

import java.awt.image.BufferedImage;
import java.util.List;

import com.devinhartzell.chess.board.Board;
import com.devinhartzell.chess.board.Coordinate;

public abstract class ChessPiece {
	
	/*
	 * For type:
	 * p - pawn
	 * r - rook
	 * n - knight
	 * b - bishop
	 * q - queen
	 * k - king
	 * 0 - null
	 */
	public char type;
	
	/*
	 * true = white
	 * false = black
	 */
	public boolean color;
	public boolean isNull = false;
	public int x, y;
	public BufferedImage image;	
	
	// K = x, V = y
	public abstract List<Coordinate> getPossibleMoves();
	
	public abstract boolean isNull();
	
	public boolean getColor()
	{
		return color;
	}
	
	public char getType()
	{
		return type;
	}

	public void move(int new_x, int new_y)
	{
		
		int old_x = this.x;
		int old_y = this.y;
		
		Board.getBoardArray()[old_x][old_y].setPiece(new NullPiece(this.x, this.y));
		Board.getBoardArray()[old_x][old_y].setSelected(false);
		Board.getBoardArray()[new_x][new_y].setPiece(this);
		System.out.println(Board.getBoardArray()[new_x][new_y].getPiece().toString());
		
		
		this.x = new_x;
		this.y = new_y;
		//System.out.println(Board.getBoardArray()[x][y].toString());
		/*
		Board.getBoardArray()[this.x][this.y].setPiece(new NullPiece(this.x, this.y));
		Board.getBoardArray()[this.x][this.y].repaint();
		this.x = x;
		this.y = y;
		Board.getBoardArray()[x][y].setPiece(this);
		Board.getBoardArray()[x][y].repaint();
		*/
	}
	
	public BufferedImage getImage()
	{
		return image;
	}
	
	public void kill()
	{
		this.x = 0;
		this.y = 0;
	}
	
	public boolean checkIfNull()
	{
		return isNull;
	}
	

}

@@ -814,16 +814,176 @@
 s.y;%0A%09%09%0A
+%09%09for (Coordinate s : Board.getBoardArray()%5Bold_x%5D%5Bold_y%5D.getPiece().getPossibleMoves())%0A%09%09%09Board.getBoardArray()%5Bs.getX()%5D%5Bs.getY()%5D.setHighlighted(false);%0A%09%09%0A
 %09%09Board.
@@ -1045,32 +1045,32 @@
 is.x, this.y));%0A
-
 %09%09Board.getBoard
@@ -1249,19 +1249,16 @@
 ());%0A%09%09%0A
-%09%09%0A
 %09%09this.x
@@ -1289,329 +1289,8 @@
 _y;%0A
-%09%09//System.out.println(Board.getBoardArray()%5Bx%5D%5By%5D.toString());%0A%09%09/*%0A%09%09Board.getBoardArray()%5Bthis.x%5D%5Bthis.y%5D.setPiece(new NullPiece(this.x, this.y));%0A%09%09Board.getBoardArray()%5Bthis.x%5D%5Bthis.y%5D.repaint();%0A%09%09this.x = x;%0A%09%09this.y = y;%0A%09%09Board.getBoardArray()%5Bx%5D%5By%5D.setPiece(this);%0A%09%09Board.getBoardArray()%5Bx%5D%5By%5D.repaint();%0A%09%09*/%0A
 %09%7D%0A%09
@@ -1367,19 +1367,22 @@
  kill()%0A
-
 %09%7B%0A
+%09%09%0A
 %09%09this.x

Remove the old highlighted squares after the piece is done moving