package communication;

import utilities.Geometrie;

/*
 * Created on Sep 14, 2004
 */
/*
 * Siehe Soccer Manual seite 30, seite 31
 *	:once per cycle
 */
public class Sender {	
	private Communicator com;
	
	public Sender(Communicator com){
		this.com = com;
	}
	
	/* connect, reconnect, disconnect*/	
	public void init(String team){
		com.send("(init "+team+" (version 9))");		
	}
	
	public void init(String team, boolean goalie){
		com.send("(init "+team+" (version 9)" + (goalie?" (goalie)":""));			
	}
	
	public void reconnect(String team, int unum){
		com.send("(reconnect "+team+" "+unum+")");
	}
	
	public void bye(){
		com.send("(bye)");
	}
	
	/*move, say, etc...*/
	public void catchBall(double moment){	
		 com.send("(catch "+Geometrie.normAngle(moment)+")");
	}
	
	public void change_view(String width, String quality){
	    com.send("(change_view "+width+" "+quality+")");
	}
	
	public void dash(int power){
	    power = Math.min(power, 100);
		power = Math.max(power, -100);
		com.send("(dash "+power+")");				
	}
	
	public void kick(double power, double direction){	     	    
		power = Math.min(power, 100);
		power = Math.max(power, -100);
		com.send("(kick "+power+" " + Geometrie.normAngle(direction) + ")");
	}
 
	public void move(double x,double y){
		com.send("(move " + x + " " + y + ")");
	}
	
	// es sind bis zu 10 Zeichen erlaubt zu sagen
	public void say(String message){
	    com.send("(say "+ message+")");
	}				
	
	public void senseBody(){
		com.send("(sense_body)");	
	}
	
	public void score(){
		com.send("(score)");	
	}
	
	public void turn(double moment){     	    	    
	    com.send("(turn " + Geometrie.normAngle(moment) + ")");
	}
		
	public void turnNeck(double degrees){		
		com.send("(turn_neck "+degrees+")");
	}
}
