package como.commlet.webcheckers;

import java.awt.*;
import java.io.*;

public class Pion{

  //MEMBRES
  
  public Joueur Player = null;
  private protected int x = 0;
  private protected int y = 0;
  //CONCTRUCTEUR

public Pion(Joueur J){
  Player = J;
  Player.Add_Pion();
}

  //METHODES

public boolean Ennemy(Pion P){
  // le pion P est-il mon ennemi ?
  return (P.Player != Player);
}

public boolean Is_Dame(){
  // suis-je une dame : non!
  return false;
}

public boolean Move_To(Case Dest, boolean Eating){ 
  // ai-je le droit theorique de faire se mouvement ?

  if (!Dest.Is_Empty()) return false;

  int dx = Math.abs(x - Dest.X());
  int dy = Dest.Y() - y;

  if (dx != Math.abs(dy)) return false;

  if (Eating) return ((Math.abs(dy) == 1) || (Math.abs(dy) == 2));

  if (Player.Side == Player.UP) {
    return ((dy == 1) || (dy == 2));
  }
  else return ((dy == -1) || (dy == -2));
}

public void Set_Position(int x,int y){
  // modifie ma position
  this.x = x;
  this.y = y;
}

public void Display(Graphics g,int size){
  // je m'affiche
  int Margin = 5;
  int Diameter = size - 2*Margin;
  g.setColor(Player.color);
  g.fillOval(Margin,Margin,Diameter,Diameter);
}


}
