/*
 * Created on 28.12.2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package de.farafin.snEADy.world;

import de.farafin.snEADy.communication.D_Vec2D;
import de.farafin.snEADy.communication.RingVector;
import de.farafin.snEADy.GameParameter;

/**
 * @author lars, roland
 *
 * TODO what does that class do?
 * 
 */
public abstract class C_Goody extends C_GameObject
{

	/** default constructor */
	protected C_Goody()
	{
		super();
	}
	
	
	/** constructor
	 * 
	 * @param parameter
	 */
	protected C_Goody(GameParameter parameter)
	{
		super(parameter);
	}
	
	
	
	/**
	 * @param headPosition
	 * @param faceDirection
	 * @param ownChar
	 * @param waitCycles
	 * @param parameter
	 */
	protected C_Goody(D_Vec2D headPosition, int faceDirection, char ownChar, long waitCycles, GameParameter parameter)
	{
		super(headPosition, faceDirection, ownChar, waitCycles, parameter);
		// TODO Auto-generated constructor stub
	}
	/**
	 * @param headPosition
	 * @param faceDirection
	 * @param objPositions
	 * @param ownChar
	 * @param waitCycles
	 * @param parameter
	 */
	protected C_Goody(D_Vec2D headPosition, int faceDirection, RingVector objPositions, char ownChar, long waitCycles, GameParameter parameter)
	{
		super(headPosition, faceDirection, objPositions, ownChar, waitCycles, parameter);
		// TODO Auto-generated constructor stub
	}
	/* (non-Javadoc)
	 * @see de.farafin.GameParameter.world.C_GameObject#jumpTo(de.farafin.GameParameter.communication.D_Vec2D)
	 */
	protected void jumpTo(D_Vec2D pos, C_Arena arena)
	{
		arena.setFree(this.headPosition);
		super.jumpHeadPos(pos);
		arena.setCharOnPosition(this.headPosition, this.ownChar);
	}

	/* (non-Javadoc)
	 * @see de.farafin.GameParameter.world.C_GameObject#getAllPosSorted(int)
	 */
	protected D_Vec2D[] getAllPosSorted(int sort)
	{
		return new D_Vec2D[]{this.headPosition};
	} 

	/* (non-Javadoc)
	 * @see de.farafin.GameParameter.world.C_GameObject#update(de.farafin.GameParameter.world.C_Arena)
	 */
	protected abstract void update(C_Arena arena);

	/** this method describes what happends to the snake if the goody was eaten.
	 * dont call this method from out of the goody-line. it is not good
	 * because the goody is not delated from the arena if this one is called.
	 * @param snake the snake that ate the goody
	 */
	protected abstract void wasEatenBy(C_Snake snake);
	
	/** this method is called when the goody was eaten by a snake. The object
	 * will be delated from the arena
	 * please use this method out of the snake if you want to describe the eating process.
	 * 
	 * @param snake the snae that ate the goody
	 * @param arena the arena the goody was eaten in
	 */
	protected void wasEaten(C_Snake snake, C_Arena arena)
	{
		this.wasEatenBy(snake);
		arena.objectDel(this);
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public abstract String toString();

	protected abstract Object clone();

}
