mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge branch 'develop' into MessageExtensions
This commit is contained in:
@@ -32,8 +32,6 @@ public class Yacht {
|
|||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(Yacht.class);
|
private Logger logger = LoggerFactory.getLogger(Yacht.class);
|
||||||
|
|
||||||
|
|
||||||
private static final Integer SPEED_MULTIPLIER = 4;
|
|
||||||
private static final Double ROUNDING_DISTANCE = 50d; // TODO: 3/08/17 wmu16 - Look into this value further
|
private static final Double ROUNDING_DISTANCE = 50d; // TODO: 3/08/17 wmu16 - Look into this value further
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +104,7 @@ public class Yacht {
|
|||||||
Double windSpeedKnots = GameState.getWindSpeedKnots();
|
Double windSpeedKnots = GameState.getWindSpeedKnots();
|
||||||
Double trueWindAngle = Math.abs(GameState.getWindDirection() - heading);
|
Double trueWindAngle = Math.abs(GameState.getWindDirection() - heading);
|
||||||
Double boatSpeedInKnots = PolarTable.getBoatSpeed(windSpeedKnots, trueWindAngle);
|
Double boatSpeedInKnots = PolarTable.getBoatSpeed(windSpeedKnots, trueWindAngle);
|
||||||
Double maxBoatSpeed = boatSpeedInKnots / 1.943844492 * 1000 * SPEED_MULTIPLIER;
|
Double maxBoatSpeed = boatSpeedInKnots / 1.943844492 * 1000;
|
||||||
if (sailIn && velocity <= maxBoatSpeed && maxBoatSpeed != 0d) {
|
if (sailIn && velocity <= maxBoatSpeed && maxBoatSpeed != 0d) {
|
||||||
|
|
||||||
if (velocity < maxBoatSpeed) {
|
if (velocity < maxBoatSpeed) {
|
||||||
@@ -295,7 +293,7 @@ public class Yacht {
|
|||||||
currentMarkSeqID++;
|
currentMarkSeqID++;
|
||||||
finishedRace = true;
|
finishedRace = true;
|
||||||
logMarkRounding(currentMark);
|
logMarkRounding(currentMark);
|
||||||
System.out.println("YAY YOU FINISHED!");
|
logger.debug(sourceId + " finished");
|
||||||
// TODO: 8/08/17 wmu16 - Do something!
|
// TODO: 8/08/17 wmu16 - Do something!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -588,10 +586,13 @@ public class Yacht {
|
|||||||
if (currentMark.isGate()) {
|
if (currentMark.isGate()) {
|
||||||
typeString = "gate";
|
typeString = "gate";
|
||||||
}
|
}
|
||||||
System.out.println(
|
logger.debug(
|
||||||
"(" + currentMarkSeqID + ") Passed " + typeString + ": " + currentMark.getMarks().get(0)
|
String.format("BoatID %d passed %s %s with id %d. Now on leg %d",
|
||||||
.getName()
|
sourceId,
|
||||||
+ " ID(" + currentMark.getId() + ")");
|
typeString,
|
||||||
|
currentMark.getMarks().get(0).getName(),
|
||||||
|
currentMark.getId(),
|
||||||
|
currentMarkSeqID));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLocationListener (YachtLocationListener listener) {
|
public void addLocationListener (YachtLocationListener listener) {
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
package seng302.model;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import seng302.model.mark.CompoundMark;
|
|
||||||
import seng302.model.mark.Mark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this link to test geo distances
|
|
||||||
* http://www.csgnetwork.com/gpsdistcalc.html
|
|
||||||
* Created by wmu16 on 3/08/17.
|
|
||||||
*/
|
|
||||||
public class YachtTest {
|
|
||||||
|
|
||||||
private Yacht yacht;
|
|
||||||
private CompoundMark compoundMark;
|
|
||||||
private Double toleranceRatio = 0.01;
|
|
||||||
private GeoPoint p1 = new GeoPoint(57.670333, 11.827833);
|
|
||||||
private GeoPoint p2 = new GeoPoint(57.671524, 11.844495);
|
|
||||||
private GeoPoint p3 = new GeoPoint(57.670822, 11.843392);
|
|
||||||
private GeoPoint p4 = new GeoPoint(25.694829, 98.392049);
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() {
|
|
||||||
yacht = new Yacht("Yacht",
|
|
||||||
0,
|
|
||||||
"0",
|
|
||||||
"WillIsCool",
|
|
||||||
"HaomingIsOk",
|
|
||||||
"NZL");
|
|
||||||
|
|
||||||
yacht.setLocation(57.670333, 11.827833);
|
|
||||||
|
|
||||||
List<Mark> subMarks = new ArrayList<>();
|
|
||||||
Mark subMark1 = new Mark("H", 57.671524, 11.844495, 0);
|
|
||||||
Mark subMark2 = new Mark("H", 57.670822, 11.843392, 0);
|
|
||||||
subMarks.add(subMark1);
|
|
||||||
subMarks.add(subMark2);
|
|
||||||
compoundMark = new CompoundMark(0, "HaomingsMark", subMarks);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//This will no longer work as we cant set the next mark any more as we no longer hold it in
|
|
||||||
//yacht class as an attribute
|
|
||||||
|
|
||||||
// @Test
|
|
||||||
// public void testDistanceToNextMark() {
|
|
||||||
// Double actual, expected;
|
|
||||||
// actual = yacht.calcDistanceToCurrentMark();
|
|
||||||
// expected = 927d;
|
|
||||||
// assertEquals(expected, actual, expected * toleranceRatio);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package seng302.model.mark;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seng302.model.GeoPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to test the compound mark calss
|
||||||
|
* Created by wmu16 on 10/08/17.
|
||||||
|
*/
|
||||||
|
public class CompoundMarkTest {
|
||||||
|
|
||||||
|
private Mark mark1;
|
||||||
|
private Mark mark2;
|
||||||
|
private CompoundMark gateMark;
|
||||||
|
private CompoundMark singleMark;
|
||||||
|
|
||||||
|
private static Double TOLERANCE_RATIO = 0.01;
|
||||||
|
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
mark1 = new Mark("Mark1", 57.670333, 11.842833, 0);
|
||||||
|
mark2 = new Mark("Mark2", 57.671524, 11.844495, 1);
|
||||||
|
|
||||||
|
List<Mark> gateMarks = new ArrayList<Mark>();
|
||||||
|
gateMarks.add(mark1);
|
||||||
|
gateMarks.add(mark2);
|
||||||
|
|
||||||
|
List<Mark> singleMarks = new ArrayList<Mark>();
|
||||||
|
singleMarks.add(mark1);
|
||||||
|
|
||||||
|
gateMark = new CompoundMark(0, "Fun Mark", gateMarks);
|
||||||
|
singleMark = new CompoundMark(1, "Awesome Mark", singleMarks);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSubMark() throws Exception {
|
||||||
|
assertEquals(mark1, gateMark.getSubMark(1));
|
||||||
|
assertEquals(mark2, gateMark.getSubMark(2));
|
||||||
|
|
||||||
|
assertEquals(mark1, singleMark.getSubMark(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMidPoint() throws Exception {
|
||||||
|
GeoPoint result = gateMark.getMidPoint();
|
||||||
|
assertEquals(57.6709285, result.getLat(), result.getLat() * TOLERANCE_RATIO);
|
||||||
|
assertEquals(11.843664, result.getLng(), result.getLng() * TOLERANCE_RATIO);
|
||||||
|
|
||||||
|
result = singleMark.getMidPoint();
|
||||||
|
assertEquals(result, mark1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isGate() throws Exception {
|
||||||
|
assertTrue(gateMark.isGate());
|
||||||
|
assertFalse(singleMark.isGate());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -170,4 +170,11 @@ public class GeoUtilityTest {
|
|||||||
assertTrue(GeoUtility.checkCrossedLine(mark2, mark1, location2, location3) == 2);
|
assertTrue(GeoUtility.checkCrossedLine(mark2, mark1, location2, location3) == 2);
|
||||||
assertTrue(GeoUtility.checkCrossedLine(mark1, mark2, location3, location2) == 2);
|
assertTrue(GeoUtility.checkCrossedLine(mark1, mark2, location3, location2) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDirtyMiddlePoint() {
|
||||||
|
GeoPoint result = GeoUtility.getDirtyMidPoint(p1, p2);
|
||||||
|
assertEquals(57.6709285, result.getLat(), result.getLat() * toleranceRate);
|
||||||
|
assertEquals(11.836164, result.getLng(), result.getLng() * toleranceRate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user