import java.util.*;
import java.awt.*;
import java.awt.Graphics;
import java.awt.Graphics2D;

public class Board extends PlayableElement {
   private static int id=0;
   private final int x;
   private final int y;
   private Vector2D pos;
   private Piece p;
   public int imagen = 0;
   private BoardView view;
   
   private Board(){   // nobody can create a Receptacle without state
     super(id++);
     x = 0;
     y = 0;
   }
   public Board(int pos_x, int pos_y, Vector2D position){
      super(id++);
      x = pos_x; //coordenadas del espacio
      y = pos_y;
      pos = position; //coordenadas por fila y columna
      Piece p = null;
      view = new BoardView(this);
      
   }
   public Vector2D getPosition(){
      Vector2D posi = new Vector2D(x,y);
		return posi;
	}
   public void paintView(Graphics2D g){
      view.draw(g);
   }
   public void setPosition(Vector2D p) {
   }
   public int getRow(){
		if (pos==null) return 0;
		return pos.getX();
	}
	public int getCol(){
		if (pos==null) return 0;
		return pos.getY();
	}
   public boolean contains (int x, int y) {
      return false;
   }
   
   public Vector2D getColRow(){
      Vector2D p = new Vector2D(this.getCol(),this.getRow());
      return p;
   }
   
   public Piece getPiece(){
      return p;
   }
   
   public void addPiece(Piece piece){
      if (piece!=null) {
         int px = piece.getPosition().getX();
         int py = piece.getPosition().getY();
         int bx = this.getPosition().getX();
         int by = this.getPosition().getY();
         if (px>=bx && px<bx+70 && py>=by && py<by+70){
      p = piece;
      }}
      else p = null;
   }
   
   public void removePiece(){
      p = null;
   }
     
   public void updateImage(int act){
		view.updateImage(act);
		this.imagen = act;
	}
}