import java.util.*;

public class Robot extends BoardItem {
  private int id;
  private boolean dead;
  private ArrayList packages;
  private Environment env;

  public Robot(int id, Environment env) {
    super(-1, -1);
    this.id = id;
    this.env = env;
    packages = new ArrayList();
    dead = false;
  }

  public void moveNorth() {
    setY(getY() + 1);
  }

  public void moveEast() {
    setX(getX() + 1);
  }

  public void moveSouth() {
    setY(getY() - 1);
  }

  public void moveWest() {
    setX(getX() - 1);
  }

  public Node getNode() {
    return new Node(getX(), getY(), env);
  }

  public void pickUp(Package p) {
    packages.add(p);
  }

  public Package drop(int id) {
    Package p = (Package) packages.remove(packages.indexOf(
      new Package(id, -1, -1, env)
    ));
    if (p == null)
      return null;
    p.setX(getX());
    p.setY(getY());
    p.drop();
    return p;
  }

  protected ArrayList getPackageList() {
    return packages;
  }
  
  protected Environment getEnvironment() {
    return env;
  }
  
  protected void setDead(boolean dead) {
    this.dead = dead;
  }
  
  public boolean isDead() {
    return dead;
  }
}
