mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
New server creation view created. Added templates for custom races. Updated xml generator to remove all hard coded values. Updated XMLParser to parse custom race files. No unit tests exists currently.
#implement #story[1275]
This commit is contained in:
@@ -15,4 +15,9 @@ public class Limit extends GeoPoint {
|
||||
public Integer getSeqID() {
|
||||
return seqID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Limit = {seqID=" + seqID + ", lat=" + getLat() + ", lng=" + getLng() + "}";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package seng302.model.mark;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import seng302.gameServer.messages.RoundingSide;
|
||||
import seng302.model.GeoPoint;
|
||||
@@ -10,13 +10,13 @@ public class CompoundMark {
|
||||
|
||||
private int compoundMarkId;
|
||||
private String name;
|
||||
private List<Mark> marks = new ArrayList<>();
|
||||
private List<Mark> marks;
|
||||
private GeoPoint midPoint;
|
||||
|
||||
public CompoundMark(int markID, String name, List<Mark> marks) {
|
||||
this.compoundMarkId = markID;
|
||||
this.name = name;
|
||||
this.marks.addAll(marks);
|
||||
this.marks = Collections.unmodifiableList(marks);
|
||||
if (marks.size() > 1) {
|
||||
this.midPoint = GeoUtility.getDirtyMidPoint(marks.get(0), marks.get(1));
|
||||
} else {
|
||||
|
||||
@@ -32,4 +32,10 @@ public class Corner {
|
||||
public Integer getZoneSize() {
|
||||
return zoneSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Corner = {seqID=" + seqID + ", compoundMarkID=" + compoundMarkID + ", rounding="
|
||||
+ rounding +", zoneSize=" + zoneSize + "}";
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,12 @@ package seng302.model.mark;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@@ -11,13 +17,9 @@ import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import seng302.gameServer.messages.RoundingSide;
|
||||
import seng302.model.ServerYacht;
|
||||
import seng302.model.stream.xml.generator.RaceXMLTemplate;
|
||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||
import seng302.model.token.Token;
|
||||
import seng302.utilities.XMLGenerator;
|
||||
import seng302.utilities.XMLParser;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Class to hold the order of the marks in the race.
|
||||
@@ -127,10 +129,11 @@ public class MarkOrder {
|
||||
private void loadRaceProperties(){
|
||||
XMLGenerator generator = new XMLGenerator();
|
||||
|
||||
// TODO: 29/08/17 wmu16 - This is terrible, having to make a template just to receive constant data
|
||||
generator.setRaceTemplate(new RaceXMLTemplate(
|
||||
new ArrayList<>(),
|
||||
new ArrayList<>()));
|
||||
// // TODO: 29/08/17 wmu16 - This is terrible, having to make a template just to receive constant data
|
||||
// generator.setRaceTemplate(new RaceXMLTemplate(
|
||||
// new ArrayList<>(),
|
||||
// new ArrayList<>())
|
||||
// );
|
||||
|
||||
String raceXML = generator.getRaceAsXml();
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package seng302.model.stream.xml.generator;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import seng302.model.Limit;
|
||||
import seng302.model.ServerYacht;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Corner;
|
||||
import seng302.model.token.Token;
|
||||
|
||||
/**
|
||||
@@ -15,10 +17,17 @@ public class RaceXMLTemplate {
|
||||
private List<ServerYacht> yachts;
|
||||
private LocalDateTime startTime;
|
||||
private List<Token> tokens;
|
||||
private List<Corner> roundings;
|
||||
private List<Limit> courseLimit;
|
||||
private List<CompoundMark> course;
|
||||
|
||||
public RaceXMLTemplate(List<ServerYacht> yachts, List<Token> tokens) {
|
||||
public RaceXMLTemplate(List<ServerYacht> yachts, List<Token> tokens, List<Corner> roundings,
|
||||
List<Limit> limit, List<CompoundMark> course) {
|
||||
this.yachts = yachts;
|
||||
this.tokens = tokens;
|
||||
this.roundings = roundings;
|
||||
this.courseLimit = limit;
|
||||
this.course = course;
|
||||
startTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@@ -39,6 +48,18 @@ public class RaceXMLTemplate {
|
||||
return Collections.unmodifiableList(tokens);
|
||||
}
|
||||
|
||||
public List<CompoundMark> getCompoundMarks() {
|
||||
return Collections.unmodifiableList(course);
|
||||
}
|
||||
|
||||
public List<Limit> getCourseLimit() {
|
||||
return Collections.unmodifiableList(courseLimit);
|
||||
}
|
||||
|
||||
public List<Corner> getRoundings() {
|
||||
return Collections.unmodifiableList(roundings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time until the race starts
|
||||
* @param seconds The time in seconds until the race starts
|
||||
|
||||
Reference in New Issue
Block a user