Committed merge-related bug fixes
This commit is contained in:
@@ -18,6 +18,7 @@ import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import shared.model.Bearing;
|
||||
import shared.model.Constants;
|
||||
import shared.xml.XMLUtilities;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@@ -70,6 +71,8 @@ public class Event {
|
||||
|
||||
private Thread connectionThread;
|
||||
|
||||
private int mapIndex;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -79,11 +82,29 @@ public class Event {
|
||||
* @param singlePlayer Whether or not to create a single player event.
|
||||
* @throws EventConstructionException Thrown if we cannot create an Event for any reason.
|
||||
*/
|
||||
public Event(boolean singlePlayer) throws EventConstructionException {
|
||||
|
||||
String raceXMLFile = "mock/mockXML/raceThreePlayers.xml";
|
||||
public Event(boolean singlePlayer, int mapIndex) throws EventConstructionException {
|
||||
this.mapIndex = mapIndex;
|
||||
String raceXMLFile;
|
||||
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
||||
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
|
||||
switch (mapIndex){
|
||||
case 0:raceXMLFile = "mock/mockXML/raceSixPlayers.xml";
|
||||
break;
|
||||
case 1:raceXMLFile = "mock/mockXML/oMapLayout.xml";
|
||||
break;
|
||||
case 2: raceXMLFile = "mock/mockXML/iMapLayout.xml";
|
||||
break;
|
||||
case 3: raceXMLFile = "mock/mockXML/mMapLayout.xml";
|
||||
break;
|
||||
case 4:
|
||||
raceXMLFile = "mock/mockXML/raceTutorial.xml";
|
||||
boatsXMLFile = "mock/mockXML/boatTutorial.xml";
|
||||
regattaXMLFile = "mock/mockXML/regattaTutorial.xml";
|
||||
break;
|
||||
default: raceXMLFile = "mock/mockXML/raceSixPlayers.xml";
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (singlePlayer) {
|
||||
raceXMLFile = "mock/mockXML/raceSinglePlayer.xml";
|
||||
@@ -95,7 +116,9 @@ public class Event {
|
||||
//this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90);
|
||||
this.raceXML = XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8);
|
||||
this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8));
|
||||
|
||||
if(mapIndex==4){
|
||||
this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8), 1000, 5000);
|
||||
}
|
||||
this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8);
|
||||
this.regattaXML = XMLReader.readXMLFileToString(regattaXMLFile, StandardCharsets.UTF_8);
|
||||
|
||||
@@ -178,9 +201,14 @@ public class Event {
|
||||
* @return String containing edited xml
|
||||
*/
|
||||
public static String setRaceXMLAtCurrentTimeToNow(String raceXML) {
|
||||
return setRaceXMLAtCurrentTimeToNow(raceXML, Constants.RacePreStartTime, Constants.RacePreparatoryTime);
|
||||
}
|
||||
|
||||
public static String setRaceXMLAtCurrentTimeToNow(String raceXML, long racePreStartTime, long racePreparatoryTime){
|
||||
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
|
||||
long millisecondsToAdd = Constants.RacePreStartTime + 1 * 60 * 1000;
|
||||
|
||||
long millisecondsToAdd = racePreStartTime + racePreparatoryTime;
|
||||
|
||||
long secondsToAdd = millisecondsToAdd / 1000;
|
||||
//Scale the time using our time scalar.
|
||||
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
|
||||
@@ -190,7 +218,6 @@ public class Event {
|
||||
raceXML = raceXML.replace("RACE_CREATION_TIME", dateFormat.format(creationTime));
|
||||
raceXML = raceXML.replace("RACE_START_TIME", dateFormat.format(creationTime.plusSeconds(secondsToAdd)));
|
||||
|
||||
|
||||
return raceXML;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +42,12 @@ public class SourceIdAllocator {
|
||||
}
|
||||
|
||||
List<Integer> allocatedIDs = mockRace.getRaceDataSource().getParticipants();
|
||||
System.out.println(allocatedIDs);
|
||||
|
||||
List<Integer> allIDs = new ArrayList<>(mockRace.getBoatDataSource().getBoats().keySet());
|
||||
System.out.println(allIDs);
|
||||
|
||||
//Get list of unallocated ids.
|
||||
List<Integer> unallocatedIDs = new ArrayList<>(allIDs);
|
||||
unallocatedIDs.removeAll(allocatedIDs);
|
||||
System.out.println(unallocatedIDs.isEmpty());
|
||||
|
||||
|
||||
if (!unallocatedIDs.isEmpty()) {
|
||||
|
||||
@@ -39,14 +39,14 @@ public class Constants {
|
||||
* The race pre-start time, in milliseconds. 3 minutes (30 seconds for development).
|
||||
*/
|
||||
// public static final long RacePreStartTime = 30 * 1000;
|
||||
public static final long RacePreStartTime = 6 * 1000;
|
||||
public static final long RacePreStartTime = 1000;
|
||||
|
||||
|
||||
/**
|
||||
* The race preparatory time, in milliseconds. 1 minute.
|
||||
*/
|
||||
// public static final long RacePreparatoryTime = 60 * 1000;
|
||||
public static final long RacePreparatoryTime = 6 * 1000;
|
||||
public static final long RacePreparatoryTime = 1 * 60 * 1000;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -62,12 +62,12 @@ public class Boundary3D {
|
||||
double c = Math.sqrt(a * a + b * b);
|
||||
|
||||
|
||||
Subject3D bound1 = new Subject3D(new Sphere(thickness * 2));
|
||||
Subject3D bound1 = new Subject3D(new Sphere(thickness * 2),0);
|
||||
bound1.setX(graphCoord1.getX());
|
||||
bound1.setZ(graphCoord1.getY());
|
||||
boundaryNodes.add(bound1);
|
||||
|
||||
Subject3D connector = new Subject3D(new Box(c, thickness, thickness));
|
||||
Subject3D connector = new Subject3D(new Box(c, thickness, thickness),0);
|
||||
connector.setX(avgCoord.getX());
|
||||
connector.setZ(avgCoord.getY());
|
||||
double angle = 90 + Math.toDegrees(GPSConverter.getAngle(graphCoord2, graphCoord1));
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SeaSurface extends Subject3D {
|
||||
* @param freq frequency the perlin noise is to be generated at
|
||||
*/
|
||||
public SeaSurface(int size, double freq){
|
||||
super(createSurface(size, freq));
|
||||
super(createSurface(size, freq),0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SkyBox {
|
||||
surface.setTranslateY(y - size + 1);
|
||||
surface.setTranslateZ(z);
|
||||
|
||||
Subject3D top = new Subject3D(surface);
|
||||
Subject3D top = new Subject3D(surface,0);
|
||||
skyBoxPlanes.add(top);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SkyBox {
|
||||
surface.setTranslateZ(z + size/2 - 1);
|
||||
|
||||
|
||||
Subject3D right = new Subject3D(surface);
|
||||
Subject3D right = new Subject3D(surface,0);
|
||||
skyBoxPlanes.add(right);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class SkyBox {
|
||||
surface.setTranslateZ(z - size/2 + 1);
|
||||
|
||||
|
||||
Subject3D left = new Subject3D(surface);
|
||||
Subject3D left = new Subject3D(surface,0);
|
||||
skyBoxPlanes.add(left);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class SkyBox {
|
||||
surface.setTranslateY(y - size/2);
|
||||
surface.setTranslateZ(z);
|
||||
|
||||
Subject3D back = new Subject3D(surface);
|
||||
Subject3D back = new Subject3D(surface,0);
|
||||
skyBoxPlanes.add(back);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class SkyBox {
|
||||
surface.setTranslateY(y - size/2);
|
||||
surface.setTranslateZ(z);
|
||||
|
||||
Subject3D front = new Subject3D(surface);
|
||||
Subject3D front = new Subject3D(surface,0);
|
||||
skyBoxPlanes.add(front);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user