package communication;
import BasicDataType.MapUpdate;
/**
*
* @author Marcus Fredriksson
* A Packet with Coordinates in it
*/
public class CoordPacket extends Packet{
/**
*
* @param expvalue exploration value of the coordinate -1 Obstacle 0 Unexplored 1 Free
* @param x coordinate of the square
* @param y coordinate of the square
*/
public CoordPacket(byte expvalue,byte x,byte y){
super(COORD);
data[0] = expvalue;
data[1] = x;
data[2] = y;
}
public CoordPacket(byte[] arr) {
super(arr);
}
/**
*
* @param map creates a CoordPacket from a MapUpdate
*/
public CoordPacket(MapUpdate map) {
this(map.getExpValue(),map.getCoordX(),map.getCoordY());
}
/**
*
* @return the square coordinate x of the CoordPacket
*/
public byte getCoordX(){
return this.data[1];
}
/**
*
* @return the square coordinate y of the CoordPacket
*/
public byte getCoordY(){
return this.data[2];
}
/**
*
* @return the square exploration value of the square
*/
public byte getExpValue(){
return this.data[0];
}
public MapUpdate toMapUpdate() {
return new MapUpdate(data[0], data[1], data[2]);
}
}