Disabled map rotation - temp fix for the demo.

Set race to use 3 boat race.xml file.
This commit is contained in:
fjc40
2017-08-17 22:26:56 +12:00
parent 27e8cddd94
commit 666c7b029f
4 changed files with 89 additions and 17 deletions
@@ -79,7 +79,7 @@ public class Event {
*/
public Event(boolean singlePlayer) throws EventConstructionException {
String raceXMLFile = "mock/mockXML/raceTest.xml";
String raceXMLFile = "mock/mockXML/raceThreePlayers.xml";//TEMP 3 player race - for demo on 18th august
String boatsXMLFile = "mock/mockXML/boatTest.xml";
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
@@ -90,22 +90,15 @@ public class Event {
//Read XML files.
try {
this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90);
//this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90);
this.raceXML = XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8);
this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8));
this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8);
this.regattaXML = XMLReader.readXMLFileToString(regattaXMLFile, StandardCharsets.UTF_8);
} catch (XMLReaderException e) {
throw new EventConstructionException("Could not read XML files.", e);
} catch (IOException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (InvalidRaceDataException e) {
e.printStackTrace();
} catch (JAXBException e) {
e.printStackTrace();
}
this.xmlFileType = XMLFileType.Contents;
@@ -197,4 +190,29 @@ public class Event {
connectionAcceptor.setBoatsXml(boatXML);
}
}
//TODO remove this after demo on 18th august!
/**
* Sets the xml description of the race to show the race was created now, and starts in 4 minutes
* @param raceXML The race.xml contents.
* @return String containing edited xml
*/
public static String setRaceXMLAtCurrentTimeToNow(String raceXML) {
//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 secondsToAdd = millisecondsToAdd / 1000;
//Scale the time using our time scalar.
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
ZonedDateTime creationTime = ZonedDateTime.now();
raceXML = raceXML.replace("RACE_CREATION_TIME", dateFormat.format(creationTime));
raceXML = raceXML.replace("RACE_START_TIME", dateFormat.format(creationTime.plusSeconds(secondsToAdd)));
return raceXML;
}
}