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

import de.farafin.snEADy.player.*;


/**
 * @author roland, lars
 *
 * TODO what does that class do?
 * 
 * @version $Revision: 1.8 $
 */
public final class C_Human extends Player
{
	/** default constructor */
	public C_Human()
	{
		super();
	}
	
	/** new turndirection */
	private int newDirection = TURN_NONE;
	
	/* (non-Javadoc)
	 * @see de.farafin.snEADy.player.Player#setName(java.lang.String)
	 */
	public void setName(String name){super.setName(name);}
	
	/* (non-Javadoc)
	 * @see de.farafin.GameParameter.player.Player#calculate(de.farafin.GameParameter.player.D_PlayerInfo)
	 */
	public void calculate(GameInfo gInfo, LevelInfo lInfo, SnakeInfo []sInfo, OwnSnakeInfo oInfo){
	    int fd=oInfo.headDirection;
	    switch(newDirection){
	    	case (WEST):
	    	    if 		(fd==NORTH)setTurnDirection(TURN_LEFT);
	    	    else if (fd==SOUTH)setTurnDirection(TURN_RIGHT);
	    	    else setTurnDirection(TURN_NONE);
	    	    break;
	    	case (NORTH):
	    	    if 		(fd==EAST)setTurnDirection(TURN_LEFT);
	    	    else if (fd==WEST)setTurnDirection(TURN_RIGHT);
	    	    else setTurnDirection(TURN_NONE);
	    	    break;
	    	case (EAST):
	    	    if 		(fd==SOUTH)setTurnDirection(TURN_LEFT);
	    	    else if (fd==NORTH)setTurnDirection(TURN_RIGHT);
	    	    else setTurnDirection(TURN_NONE);
	    	    break;
	    	case (SOUTH):
	    	    if 		(fd==WEST)setTurnDirection(TURN_LEFT);
	    	    else if (fd==EAST)setTurnDirection(TURN_RIGHT);
	    	    else setTurnDirection(TURN_NONE);
	    	    break;
	    	 default:
	    	 	setTurnDirection(TURN_NONE);
	    }


	}
	
	/* (non-Javadoc)
	 * @see de.farafin.snEADy.player.Player#setTurnDirection(int)
	 */
	public void setNewDirection(int newDirection){this.newDirection=newDirection;}
}
