Fixed Annotations and bound windarrow
- Wind arrow for the bermuda race is bound between 215 and 235 degrees - annotations will not correctly highlight what they are showing #story[877] story[882]
This commit is contained in:
@@ -12,6 +12,7 @@ import seng302.Networking.Messages.Enums.BoatStatusEnum;
|
||||
import seng302.Networking.Messages.Enums.RaceStatusEnum;
|
||||
import seng302.Networking.Messages.Enums.RaceTypeEnum;
|
||||
import seng302.Networking.Messages.RaceStatus;
|
||||
import seng302.Networking.Utils.AC35UnitConverter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -102,8 +103,11 @@ public class Race implements Runnable {
|
||||
*/
|
||||
private double windSpeed;
|
||||
|
||||
private int windDir;
|
||||
private double windDirDegrees;
|
||||
private double windDir;
|
||||
private int changeWind = 4;
|
||||
private static final int windUpperBound = 235;
|
||||
private static final int windLowerBound = 215;
|
||||
|
||||
|
||||
|
||||
@@ -261,7 +265,7 @@ public class Race implements Runnable {
|
||||
//TODO REFACTOR for consistency, could send parameters to mockOutput instead of the whole racestatus. This will also fix the sequence number issue.
|
||||
|
||||
//Convert wind direction and speed to ints. //TODO this conversion should be done inside the racestatus class.
|
||||
int windDirectionInt = BoatLocation.convertHeadingDoubleToInt(this.windDirection.degrees());
|
||||
int windDirectionInt = AC35UnitConverter.encodeHeading(this.windDirection.degrees());
|
||||
int windSpeedInt = (int) (windSpeed * Constants.KnotsToMMPerSecond);
|
||||
|
||||
//Create race status object, and send it.
|
||||
@@ -863,31 +867,31 @@ public class Race implements Runnable {
|
||||
}
|
||||
|
||||
protected void initialiseWindDir(){
|
||||
windDir = new Random().nextInt(65535+1);
|
||||
this.windDirection = new Bearing(BoatLocation.convertHeadingIntToDouble(windDir));
|
||||
windDirDegrees = 225;
|
||||
windDir = AC35UnitConverter.convertHeading(windDirDegrees);
|
||||
/*windDir = new Random().nextInt(65535+1);
|
||||
windDir = BoatLocation.convertHeadingIntToDouble(255);*/
|
||||
this.windDirection = new Bearing((int)windDir);
|
||||
}
|
||||
|
||||
protected void changeWindDir(){
|
||||
int r = new Random().nextInt(changeWind)+1;
|
||||
if(r==1){
|
||||
windDir+=100;
|
||||
windDirDegrees = (0.5 + windDirDegrees) % 360;
|
||||
} else if (r==2){
|
||||
windDir-=100;
|
||||
windDirDegrees = ((windDirDegrees - 0.5) + 360) % 360;///keep the degrees positive when below 0
|
||||
}
|
||||
if (windDir > 65535){
|
||||
windDir -= 65535;
|
||||
if (windDirDegrees > windUpperBound){
|
||||
windDirDegrees = windUpperBound;
|
||||
}
|
||||
if (windDir < 0){
|
||||
windDir += 65535;
|
||||
if (windDirDegrees < windLowerBound){
|
||||
windDirDegrees = windLowerBound;
|
||||
}
|
||||
this.windDirection = new Bearing(BoatLocation.convertHeadingIntToDouble(windDir));
|
||||
}
|
||||
|
||||
protected void setWindDir(int wind){
|
||||
if (wind>=0 && wind<=65535){
|
||||
windDir = wind;
|
||||
this.windDirection = new Bearing(BoatLocation.convertHeadingIntToDouble(windDir));
|
||||
}
|
||||
windDir = AC35UnitConverter.convertHeading(windDirDegrees);
|
||||
|
||||
System.out.println(windDirDegrees + " + " + windDir);
|
||||
this.windDirection = new Bearing(windDirDegrees);
|
||||
}
|
||||
|
||||
protected void setChangeWind(int changeVal){
|
||||
@@ -897,6 +901,6 @@ public class Race implements Runnable {
|
||||
}
|
||||
|
||||
protected int getWind(){
|
||||
return windDir;
|
||||
return (int)windDir;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user