package Pieces;

import Main.Board;

import java.util.ArrayList;

public abstract class Piece implements Cloneable {
    private int x;
    private boolean isWhite;
    private int y;
    private Board board;
    public Piece(int x , int y , boolean isWhite , Board board){
        this.x = x;
        this.y = y;
        this.isWhite = isWhite;
        this.board = board;
    }
    public boolean isWhite(){
        return isWhite;
    }
    public boolean isBlack(){
        return !isWhite;
    }
    public int getX() {
        return x;
    }

    public Board getBoard() {
        return board;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
    abstract public boolean isCanMove(int dx,int dy);
    abstract public boolean isValidMove(int dx,int dy);
    abstract public ArrayList<int[]> moves();
    public boolean isOutside(int dx, int dy){
        if (dx < 0 || dx > 8 || dy < 0 || dy > 8)
            return false;
        return true;
    }
    public Object clone(){
        try {
            return super.clone();
        } catch (CloneNotSupportedException e) {
            System.err.println("Clone Error");
            e.printStackTrace();
        }
        return null;
    }
}