Merge remote-tracking branch 'remotes/origin/sprint4_master' into story36

# Conflicts:
#	visualiser/src/main/java/seng302/Controllers/RaceController.java
#	visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java
#story[878]
This commit is contained in:
hba56
2017-05-23 13:19:11 +12:00
14 changed files with 363 additions and 295 deletions
+55 -8
View File
@@ -95,16 +95,19 @@ public class Race implements Runnable {
/**
* Wind direction bearing.
*/
* Wind direction bearing.
*/
private Bearing windDirection;
/**
* Wind speed (knots).
* Convert this to millimeters per second before passing to RaceStatus.
*/
* Wind speed (knots).
* Convert this to millimeters per second before passing to RaceStatus.
*/
private double windSpeed;
private int windDir;
private int changeWind = 4;
/**
@@ -141,6 +144,7 @@ public class Race implements Runnable {
*/
public void run() {
initialiseBoats();
initialiseWindDir();
countdownTimer.start();
}
@@ -303,6 +307,9 @@ public class Race implements Runnable {
//Parse the marks.
parseMarks();
// Change wind direction
changeWindDir();
//Parse the race status.
parseRaceStatus();
@@ -314,7 +321,6 @@ public class Race implements Runnable {
this.stop();
}
//Update the animations timer's time.
currentTime = System.currentTimeMillis();
}
@@ -373,6 +379,9 @@ public class Race implements Runnable {
this.stop();
}
// Change wind direction
changeWindDir();
//Parse the boat locations.
parseBoatLocations();
@@ -828,4 +837,42 @@ public class Race implements Runnable {
public ObservableList<Boat> getBoats() {
return boats;
}
}
protected void initialiseWindDir(){
windDir = new Random().nextInt(65535+1);
this.windDirection = new Bearing(BoatLocation.convertHeadingIntToDouble(windDir));
}
protected void changeWindDir(){
int r = new Random().nextInt(changeWind)+1;
if(r==1){
windDir+=100;
} else if (r==2){
windDir-=100;
}
if (windDir > 65535){
windDir -= 65535;
}
if (windDir < 0){
windDir += 65535;
}
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));
}
}
protected void setChangeWind(int changeVal){
if (changeVal>=0){
changeWind = changeVal;
}
}
protected int getWind(){
return windDir;
}
}
+18 -2
View File
@@ -222,7 +222,6 @@ public class RaceTest{
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
Race testRace = new Race(raceDataSource, mockOutput);
testRace.setDnfChance(0);
assertFalse(testRace.doNotFinish());
@@ -289,12 +288,29 @@ public class RaceTest{
testBoat.setCurrentPosition(ORIGIN.getAverageGPSCoordinate());
testRace.updatePosition(testBoat, 100, 100);
assertFalse(testBoat.getCurrentPosition() == ORIGIN.getAverageGPSCoordinate());
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
e.printStackTrace();
fail();
}
}
@Ignore
@Test
public void windDirectionCorrectValues(){
// try {
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
// BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml");
// RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
// Race testRace = new Race(raceDataSource, mockOutput);
// testRace.setChangeWind(1);
// testRace.setWindDir(65535);
// testRace.changeWindDir();
// assertEquals(100, testRace.getWind());
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
// e.printStackTrace();
// fail();
// }
}
}