Compare commits

..

2 Commits

Author SHA1 Message Date
Haoming Yin 7022be1979 Fixed unit test which failed due to the change of configure file.
#story[445]
2017-03-30 16:16:30 +13:00
Haoming Yin 971a3920a3 Fixed race timer to display real race time, and made race time scalable.
#story[445]
2017-03-30 16:12:01 +13:00
6 changed files with 15 additions and 13 deletions
@@ -150,7 +150,7 @@ public class CanvasController {
*/ */
private void drawWake(GraphicsContext gc, double x, double y, double speed, Color color, double heading){ private void drawWake(GraphicsContext gc, double x, double y, double speed, Color color, double heading){
double angle = Math.toRadians(heading); double angle = Math.toRadians(heading);
speed = speed * 10; speed = speed * 2;
Point newP = new Point(0, speed); Point newP = new Point(0, speed);
newP.rotate(angle); newP.rotate(angle);
@@ -127,7 +127,7 @@ public class RaceViewController {
for (Event event : events) { for (Event event : events) {
if (event.getIsFinishingEvent()) { if (event.getIsFinishingEvent()) {
keyFrames.add( keyFrames.add(
new KeyFrame(Duration.seconds(event.getTime() / 60 / 60 / 5), new KeyFrame(Duration.seconds(event.getTime()),
onFinished -> {race.setBoatFinished(boat); handleEvent(event);}, onFinished -> {race.setBoatFinished(boat); handleEvent(event);},
new KeyValue(x, event.getThisMark().getLatitude()), new KeyValue(x, event.getThisMark().getLatitude()),
new KeyValue(y, event.getThisMark().getLongitude()) new KeyValue(y, event.getThisMark().getLongitude())
@@ -135,7 +135,7 @@ public class RaceViewController {
); );
} else { } else {
keyFrames.add( keyFrames.add(
new KeyFrame(Duration.seconds(event.getTime() / 60 / 60 / 5), new KeyFrame(Duration.seconds(event.getTime()),
onFinished ->{ onFinished ->{
handleEvent(event); handleEvent(event);
boat.setHeading(event.getBoatHeading()); boat.setHeading(event.getBoatHeading());
+4 -2
View File
@@ -88,7 +88,7 @@ public class Race {
int numberOfMarks = this.course.size(); int numberOfMarks = this.course.size();
for (int i = 0; i < numberOfMarks; i++) { for (int i = 0; i < numberOfMarks; i++) {
Double time = (1000 * totalDistance / boat.getVelocity()); Double time = (totalDistance / boat.getVelocity() / timeScale);
// If there are singleMarks after this event // If there are singleMarks after this event
if (i < numberOfMarks - 1) { if (i < numberOfMarks - 1) {
@@ -101,6 +101,8 @@ public class Race {
events.put(boat, new ArrayList<>(Arrays.asList(event))); events.put(boat, new ArrayList<>(Arrays.asList(event)));
} }
totalDistance += event.getDistanceBetweenMarks(); totalDistance += event.getDistanceBetweenMarks();
System.out.println(totalDistance);
System.out.println(boat.getVelocity());
} }
// There are no more marks after this event // There are no more marks after this event
@@ -190,6 +192,6 @@ public class Race {
* Increment the race time by one second * Increment the race time by one second
*/ */
public void incrementRaceTime(){ public void incrementRaceTime(){
this.raceTime ++; this.raceTime += this.timeScale;
} }
} }
+1 -1
View File
@@ -3,7 +3,7 @@
<configurations> <configurations>
<race-name>AC35</race-name> <race-name>AC35</race-name>
<race-size>6</race-size> <race-size>6</race-size>
<time-scale>1.0</time-scale> <time-scale>10.0</time-scale>
<wind-direction>135</wind-direction> <wind-direction>135</wind-direction>
</configurations> </configurations>
+6 -6
View File
@@ -4,31 +4,31 @@
<team> <team>
<name>Oracle Team USA</name> <name>Oracle Team USA</name>
<alias>USA</alias> <alias>USA</alias>
<velocity>1</velocity> <velocity>12.9</velocity>
</team> </team>
<team> <team>
<name>Artemis Racing</name> <name>Artemis Racing</name>
<alias>ART</alias> <alias>ART</alias>
<velocity>1.1</velocity> <velocity>13.1</velocity>
</team> </team>
<team> <team>
<name>Emirates Team New Zealand</name> <name>Emirates Team New Zealand</name>
<alias>NZL</alias> <alias>NZL</alias>
<velocity>2</velocity> <velocity>15.6</velocity>
</team> </team>
<team> <team>
<name>Land Rover BAR</name> <name>Land Rover BAR</name>
<alias>BAR</alias> <alias>BAR</alias>
<velocity>1.3</velocity> <velocity>13.3</velocity>
</team> </team>
<team> <team>
<name>SoftBank Team Japan</name> <name>SoftBank Team Japan</name>
<alias>JAP</alias> <alias>JAP</alias>
<velocity>1.7</velocity> <velocity>14.7</velocity>
</team> </team>
<team> <team>
<name>Groupama Team France</name> <name>Groupama Team France</name>
<alias>FRC</alias> <alias>FRC</alias>
<velocity>1.4</velocity> <velocity>11.4</velocity>
</team> </team>
</teams> </teams>
@@ -24,7 +24,7 @@ public class ConfigParserTest {
@Test @Test
public void getTimeScale() throws Exception { public void getTimeScale() throws Exception {
assertEquals(1.0, cp.getTimeScale(), 1e-10); assertEquals(10.0, cp.getTimeScale(), 1e-10);
} }
@Test @Test