mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge remote-tracking branch 'origin/1124_broadcast_mark_rounding_message' into 1124_broadcast_mark_rounding_message
# Conflicts: # src/main/java/seng302/gameServer/GameState.java
This commit is contained in:
@@ -4,9 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import seng302.gameServer.server.messages.BoatAction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.gameServer.server.messages.BoatAction;
|
||||
import seng302.gameServer.server.messages.MarkRoundingMessage;
|
||||
import seng302.gameServer.server.messages.MarkType;
|
||||
import seng302.gameServer.server.messages.Message;
|
||||
@@ -14,7 +14,7 @@ import seng302.gameServer.server.messages.RoundingBoatStatus;
|
||||
import seng302.model.GeoPoint;
|
||||
import seng302.model.Player;
|
||||
import seng302.model.PolarTable;
|
||||
import seng302.model.Yacht;
|
||||
import seng302.model.ServerYacht;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Mark;
|
||||
import seng302.model.mark.MarkOrder;
|
||||
@@ -44,7 +44,7 @@ public class GameState implements Runnable {
|
||||
|
||||
private static String hostIpAddress;
|
||||
private static List<Player> players;
|
||||
private static Map<Integer, Yacht> yachts;
|
||||
private static Map<Integer, ServerYacht> yachts;
|
||||
private static Boolean isRaceStarted;
|
||||
private static GameStages currentStage;
|
||||
private static MarkOrder markOrder;
|
||||
@@ -102,7 +102,7 @@ public class GameState implements Runnable {
|
||||
playerStringMap.remove(player);
|
||||
}
|
||||
|
||||
public static void addYacht(Integer sourceId, Yacht yacht) {
|
||||
public static void addYacht(Integer sourceId, ServerYacht yacht) {
|
||||
yachts.put(sourceId, yacht);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class GameState implements Runnable {
|
||||
return GeoUtility.mmsToKnots(windSpeed); // TODO: 26/07/17 cir27 - remove magic numbers
|
||||
}
|
||||
|
||||
public static Map<Integer, Yacht> getYachts() {
|
||||
public static Map<Integer, ServerYacht> getYachts() {
|
||||
return yachts;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public class GameState implements Runnable {
|
||||
}
|
||||
|
||||
public static void updateBoat(Integer sourceId, BoatAction actionType) {
|
||||
Yacht playerYacht = yachts.get(sourceId);
|
||||
ServerYacht playerYacht = yachts.get(sourceId);
|
||||
switch (actionType) {
|
||||
case VMG:
|
||||
playerYacht.turnToVMG();
|
||||
@@ -215,7 +215,7 @@ public class GameState implements Runnable {
|
||||
public void update() {
|
||||
Double timeInterval = (System.currentTimeMillis() - previousUpdateTime) / 1000000.0;
|
||||
previousUpdateTime = System.currentTimeMillis();
|
||||
for (Yacht yacht : yachts.values()) {
|
||||
for (ServerYacht yacht : yachts.values()) {
|
||||
updateVelocity(yacht);
|
||||
yacht.runAutoPilot();
|
||||
yacht.updateLocation(timeInterval);
|
||||
@@ -226,13 +226,11 @@ public class GameState implements Runnable {
|
||||
}
|
||||
|
||||
|
||||
private void updateVelocity(Yacht yacht) {
|
||||
private void updateVelocity(ServerYacht yacht) {
|
||||
Double velocity = yacht.getCurrentVelocity();
|
||||
Double trueWindAngle = Math.abs(windDirection - yacht.getHeading());
|
||||
Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle);
|
||||
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots);
|
||||
yacht.setCurrentMaxVelocity(maxBoatSpeed);
|
||||
System.out.println(maxBoatSpeed);
|
||||
// TODO: 15/08/17 remove magic numbers from these equations.
|
||||
if (yacht.getSailIn()) {
|
||||
if (velocity < maxBoatSpeed - 500) {
|
||||
@@ -262,7 +260,7 @@ public class GameState implements Runnable {
|
||||
* @throws IndexOutOfBoundsException If the next mark is null (ie the last mark in the race)
|
||||
* Check first using {@link seng302.model.mark.MarkOrder#isLastMark(Integer)}
|
||||
*/
|
||||
private Double calcDistanceToCurrentMark(Yacht yacht) throws IndexOutOfBoundsException {
|
||||
private Double calcDistanceToCurrentMark(ServerYacht yacht) throws IndexOutOfBoundsException {
|
||||
Integer currentMarkSeqID = yacht.getCurrentMarkSeqID();
|
||||
CompoundMark currentMark = markOrder.getCurrentMark(currentMarkSeqID);
|
||||
GeoPoint location = yacht.getLocation();
|
||||
@@ -291,7 +289,7 @@ public class GameState implements Runnable {
|
||||
* in-race Gate 3 - Passing any in-race Mark 4 - Passing the finish line
|
||||
* @param yacht the current yacht to check for progression
|
||||
*/
|
||||
private void checkForLegProgression(Yacht yacht) {
|
||||
private void checkForLegProgression(ServerYacht yacht) {
|
||||
Integer currentMarkSeqID = yacht.getCurrentMarkSeqID();
|
||||
CompoundMark currentMark = markOrder.getCurrentMark(currentMarkSeqID);
|
||||
|
||||
@@ -323,7 +321,7 @@ public class GameState implements Runnable {
|
||||
*
|
||||
* @param yacht The current yacht to check for
|
||||
*/
|
||||
private Boolean checkStartLineCrossing(Yacht yacht) {
|
||||
private Boolean checkStartLineCrossing(ServerYacht yacht) {
|
||||
Integer currentMarkSeqID = yacht.getCurrentMarkSeqID();
|
||||
CompoundMark currentMark = markOrder.getCurrentMark(currentMarkSeqID);
|
||||
GeoPoint lastLocation = yacht.getLastLocation();
|
||||
@@ -353,7 +351,7 @@ public class GameState implements Runnable {
|
||||
*
|
||||
* @param yacht The current yacht to check for
|
||||
*/
|
||||
private Boolean checkMarkRounding(Yacht yacht) {
|
||||
private Boolean checkMarkRounding(ServerYacht yacht) {
|
||||
Integer currentMarkSeqID = yacht.getCurrentMarkSeqID();
|
||||
CompoundMark currentMark = markOrder.getCurrentMark(currentMarkSeqID);
|
||||
GeoPoint lastLocation = yacht.getLastLocation();
|
||||
@@ -382,7 +380,7 @@ public class GameState implements Runnable {
|
||||
*
|
||||
* @param yacht The current yacht to check for
|
||||
*/
|
||||
private Boolean checkGateRounding(Yacht yacht) {
|
||||
private Boolean checkGateRounding(ServerYacht yacht) {
|
||||
Integer currentMarkSeqID = yacht.getCurrentMarkSeqID();
|
||||
CompoundMark currentMark = markOrder.getCurrentMark(currentMarkSeqID);
|
||||
GeoPoint lastLocation = yacht.getLastLocation();
|
||||
@@ -425,7 +423,7 @@ public class GameState implements Runnable {
|
||||
*
|
||||
* @param yacht The current yacht to check for
|
||||
*/
|
||||
private Boolean checkFinishLineCrossing(Yacht yacht) {
|
||||
private Boolean checkFinishLineCrossing(ServerYacht yacht) {
|
||||
Integer currentMarkSeqID = yacht.getCurrentMarkSeqID();
|
||||
CompoundMark currentMark = markOrder.getCurrentMark(currentMarkSeqID);
|
||||
GeoPoint lastLocation = yacht.getLastLocation();
|
||||
@@ -449,7 +447,7 @@ public class GameState implements Runnable {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendMarkRoundingMessage(Yacht yacht) {
|
||||
private void sendMarkRoundingMessage(ServerYacht yacht) {
|
||||
Integer sourceID = yacht.getSourceId();
|
||||
Integer currentMarkSeqID = yacht.getCurrentMarkSeqID();
|
||||
CompoundMark currentMark = markOrder.getCurrentMark(currentMarkSeqID);
|
||||
@@ -467,7 +465,7 @@ public class GameState implements Runnable {
|
||||
}
|
||||
|
||||
|
||||
private void logMarkRounding(Yacht yacht) {
|
||||
private void logMarkRounding(ServerYacht yacht) {
|
||||
Mark roundingMark = yacht.getClosestCurrentMark();
|
||||
|
||||
logger.debug(
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.zip.CRC32;
|
||||
import java.util.zip.Checksum;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.gameServer.server.messages.BoatAction;
|
||||
import seng302.gameServer.server.messages.BoatLocationMessage;
|
||||
import seng302.gameServer.server.messages.BoatStatus;
|
||||
import seng302.gameServer.server.messages.BoatSubMessage;
|
||||
@@ -32,13 +33,12 @@ import seng302.gameServer.server.messages.RegistrationResponseStatus;
|
||||
import seng302.gameServer.server.messages.XMLMessage;
|
||||
import seng302.gameServer.server.messages.XMLMessageSubType;
|
||||
import seng302.model.Player;
|
||||
import seng302.model.Yacht;
|
||||
import seng302.model.ServerYacht;
|
||||
import seng302.model.stream.packets.PacketType;
|
||||
import seng302.model.stream.packets.StreamPacket;
|
||||
import seng302.model.stream.xml.generator.Race;
|
||||
import seng302.model.stream.xml.generator.Regatta;
|
||||
import seng302.utilities.XMLGenerator;
|
||||
import seng302.gameServer.server.messages.BoatAction;
|
||||
|
||||
/**
|
||||
* A class describing a single connection to a Client for the purposes of sending and receiving on
|
||||
@@ -115,8 +115,7 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
all = ln.lines().collect(Collectors.toList());
|
||||
lName = all.get(ThreadLocalRandom.current().nextInt(0, all.size()));
|
||||
|
||||
|
||||
Yacht yacht = new Yacht(
|
||||
ServerYacht yacht = new ServerYacht(
|
||||
"Yacht", sourceId, sourceId.toString(), fName, fName + " " + lName, "NZ"
|
||||
);
|
||||
|
||||
@@ -221,7 +220,7 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
xml = new XMLGenerator();
|
||||
Race race = new Race();
|
||||
|
||||
for (Yacht yacht : GameState.getYachts().values()) {
|
||||
for (ServerYacht yacht : GameState.getYachts().values()) {
|
||||
race.addBoat(yacht);
|
||||
}
|
||||
|
||||
@@ -299,8 +298,8 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
|
||||
|
||||
public void sendBoatLocationPackets() {
|
||||
ArrayList<Yacht> yachts = new ArrayList<>(GameState.getYachts().values());
|
||||
for (Yacht yacht : yachts) {
|
||||
ArrayList<ServerYacht> yachts = new ArrayList<>(GameState.getYachts().values());
|
||||
for (ServerYacht yacht : yachts) {
|
||||
BoatLocationMessage boatLocationMessage =
|
||||
new BoatLocationMessage(
|
||||
yacht.getSourceId(),
|
||||
@@ -326,7 +325,7 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
RaceStatus raceStatus;
|
||||
|
||||
for (Player player : GameState.getPlayers()) {
|
||||
Yacht y = player.getYacht();
|
||||
ServerYacht y = player.getYacht();
|
||||
|
||||
if (GameState.getCurrentStage() == GameStages.PRE_RACE) {
|
||||
boatStatus = BoatStatus.PRESTART;
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
package seng302.model;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import javafx.beans.property.ReadOnlyDoubleProperty;
|
||||
import javafx.beans.property.ReadOnlyDoubleWrapper;
|
||||
import javafx.beans.property.ReadOnlyLongProperty;
|
||||
import javafx.beans.property.ReadOnlyLongWrapper;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
|
||||
/**
|
||||
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
|
||||
* compared to the XMLParser boat class, also done outside Boat class because some old variables are
|
||||
* not used anymore.
|
||||
*/
|
||||
public class ClientYacht extends Observable {
|
||||
|
||||
@FunctionalInterface
|
||||
public interface YachtLocationListener {
|
||||
|
||||
void notifyLocation(ClientYacht clientYacht, double lat, double lon, double heading,
|
||||
double velocity);
|
||||
}
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
||||
|
||||
|
||||
//BOTH AFAIK
|
||||
private String boatType;
|
||||
private Integer sourceId;
|
||||
private String hullID; //matches HullNum in the XML spec.
|
||||
private String shortName;
|
||||
private String boatName;
|
||||
private String country;
|
||||
|
||||
private Long estimateTimeAtFinish;
|
||||
private Integer currentMarkSeqID = 0;
|
||||
private Long markRoundTime;
|
||||
private Long timeTillNext;
|
||||
private Double heading;
|
||||
private Integer legNumber = 0;
|
||||
private GeoPoint location;
|
||||
private Integer boatStatus;
|
||||
private Double currentVelocity;
|
||||
|
||||
//CLIENT SIDE
|
||||
private List<YachtLocationListener> locationListeners = new ArrayList<>();
|
||||
private ReadOnlyDoubleWrapper velocityProperty = new ReadOnlyDoubleWrapper();
|
||||
private ReadOnlyLongWrapper timeTillNextProperty = new ReadOnlyLongWrapper();
|
||||
private ReadOnlyLongWrapper timeSinceLastMarkProperty = new ReadOnlyLongWrapper();
|
||||
private CompoundMark lastMarkRounded;
|
||||
private Integer positionInt = 0;
|
||||
private Color colour;
|
||||
|
||||
public ClientYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
||||
String boatName, String country) {
|
||||
this.boatType = boatType;
|
||||
this.sourceId = sourceId;
|
||||
this.hullID = hullID;
|
||||
this.shortName = shortName;
|
||||
this.boatName = boatName;
|
||||
this.country = country;
|
||||
this.location = new GeoPoint(57.670341, 11.826856);
|
||||
this.heading = 120.0; //In degrees
|
||||
this.currentVelocity = 0d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add ServerToClientThread as the observer, this observer pattern mainly server for the boat
|
||||
* rounding package.
|
||||
*/
|
||||
@Override
|
||||
public void addObserver(Observer o) {
|
||||
super.addObserver(o);
|
||||
}
|
||||
|
||||
public String getBoatType() {
|
||||
return boatType;
|
||||
}
|
||||
|
||||
public Integer getSourceId() {
|
||||
//@TODO Remove and merge with Creating Game Loop
|
||||
if (sourceId == null) {
|
||||
return 0;
|
||||
}
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
public String getHullID() {
|
||||
if (hullID == null) {
|
||||
return "";
|
||||
}
|
||||
return hullID;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public String getBoatName() {
|
||||
return boatName;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
if (country == null) {
|
||||
return "";
|
||||
}
|
||||
return country;
|
||||
}
|
||||
|
||||
public Integer getBoatStatus() {
|
||||
return boatStatus;
|
||||
}
|
||||
|
||||
public void setBoatStatus(Integer boatStatus) {
|
||||
this.boatStatus = boatStatus;
|
||||
}
|
||||
|
||||
public Integer getLegNumber() {
|
||||
return legNumber;
|
||||
}
|
||||
|
||||
public void setLegNumber(Integer legNumber) {
|
||||
this.legNumber = legNumber;
|
||||
}
|
||||
|
||||
public void setEstimateTimeTillNextMark(Long estimateTimeTillNextMark) {
|
||||
timeTillNext = estimateTimeTillNextMark;
|
||||
}
|
||||
|
||||
public String getEstimateTimeAtFinish() {
|
||||
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
return format.format(estimateTimeAtFinish);
|
||||
}
|
||||
|
||||
public void setEstimateTimeAtFinish(Long estimateTimeAtFinish) {
|
||||
this.estimateTimeAtFinish = estimateTimeAtFinish;
|
||||
}
|
||||
|
||||
public Integer getPositionInteger() {
|
||||
return positionInt;
|
||||
}
|
||||
|
||||
public void setPositionInteger(Integer position) {
|
||||
this.positionInt = position;
|
||||
}
|
||||
|
||||
public void updateVelocityProperty(double velocity) {
|
||||
this.velocityProperty.set(velocity);
|
||||
}
|
||||
|
||||
public void setMarkRoundingTime(Long markRoundingTime) {
|
||||
this.markRoundTime = markRoundingTime;
|
||||
}
|
||||
|
||||
public ReadOnlyDoubleProperty getVelocityProperty() {
|
||||
return velocityProperty.getReadOnlyProperty();
|
||||
}
|
||||
|
||||
public ReadOnlyLongProperty timeTillNextProperty() {
|
||||
return timeTillNextProperty.getReadOnlyProperty();
|
||||
}
|
||||
|
||||
public Long getTimeTillNext() {
|
||||
return timeTillNext;
|
||||
}
|
||||
|
||||
public Long getMarkRoundTime() {
|
||||
return markRoundTime;
|
||||
}
|
||||
|
||||
public CompoundMark getLastMarkRounded() {
|
||||
return lastMarkRounded;
|
||||
}
|
||||
|
||||
public void setLastMarkRounded(CompoundMark lastMarkRounded) {
|
||||
this.lastMarkRounded = lastMarkRounded;
|
||||
}
|
||||
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current location of the boat in lat and long whilst preserving the last location
|
||||
*
|
||||
* @param lat Latitude
|
||||
* @param lng Longitude
|
||||
*/
|
||||
public void setLocation(Double lat, Double lng) {
|
||||
location.setLat(lat);
|
||||
location.setLng(lng);
|
||||
}
|
||||
|
||||
public Double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading(Double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return boatName;
|
||||
}
|
||||
|
||||
public void updateTimeSinceLastMarkProperty(long timeSinceLastMark) {
|
||||
this.timeSinceLastMarkProperty.set(timeSinceLastMark);
|
||||
}
|
||||
|
||||
public ReadOnlyLongProperty timeSinceLastMarkProperty() {
|
||||
return timeSinceLastMarkProperty.getReadOnlyProperty();
|
||||
}
|
||||
|
||||
public void setTimeTillNext(Long timeTillNext) {
|
||||
this.timeTillNext = timeTillNext;
|
||||
}
|
||||
|
||||
|
||||
public Color getColour() {
|
||||
return colour;
|
||||
}
|
||||
|
||||
public void setColour(Color colour) {
|
||||
this.colour = colour;
|
||||
}
|
||||
|
||||
// public Double getCurrentVelocity() {
|
||||
// return currentVelocity;
|
||||
// }
|
||||
//
|
||||
// public void setCurrentVelocity(Double currentVelocity) {
|
||||
// this.currentVelocity = currentVelocity;
|
||||
// }
|
||||
|
||||
|
||||
public void updateLocation(double lat, double lng, double heading, double velocity) {
|
||||
setLocation(lat, lng);
|
||||
this.heading = heading;
|
||||
// this.currentVelocity = velocity;
|
||||
updateVelocityProperty(velocity);
|
||||
for (YachtLocationListener yll : locationListeners) {
|
||||
yll.notifyLocation(this, lat, lng, heading, velocity);
|
||||
}
|
||||
}
|
||||
|
||||
public void addLocationListener(YachtLocationListener listener) {
|
||||
locationListeners.add(listener);
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,11 @@ import java.net.Socket;
|
||||
public class Player {
|
||||
|
||||
private Socket socket;
|
||||
private Yacht yacht;
|
||||
private ServerYacht yacht;
|
||||
private Integer lastMarkPassed;
|
||||
|
||||
|
||||
public Player(Socket socket, Yacht yacht) {
|
||||
public Player(Socket socket, ServerYacht yacht) {
|
||||
this.socket = socket;
|
||||
this.yacht = yacht;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class Player {
|
||||
this.lastMarkPassed = lastMarkPassed;
|
||||
}
|
||||
|
||||
public Yacht getYacht() {
|
||||
public ServerYacht getYacht() {
|
||||
return yacht;
|
||||
}
|
||||
|
||||
|
||||
+11
-185
@@ -1,21 +1,11 @@
|
||||
package seng302.model;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import javafx.beans.property.ReadOnlyDoubleProperty;
|
||||
import javafx.beans.property.ReadOnlyDoubleWrapper;
|
||||
import javafx.beans.property.ReadOnlyLongProperty;
|
||||
import javafx.beans.property.ReadOnlyLongWrapper;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.gameServer.GameState;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Mark;
|
||||
import seng302.utilities.GeoUtility;
|
||||
|
||||
@@ -24,18 +14,12 @@ import seng302.utilities.GeoUtility;
|
||||
* compared to the XMLParser boat class, also done outside Boat class because some old variables are
|
||||
* not used anymore.
|
||||
*/
|
||||
public class Yacht extends Observable {
|
||||
public class ServerYacht extends Observable {
|
||||
|
||||
@FunctionalInterface
|
||||
public interface YachtLocationListener {
|
||||
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
||||
|
||||
void notifyLocation(Yacht yacht, double lat, double lon, double heading, double velocity);
|
||||
}
|
||||
public static final Double TURN_STEP = 5.0;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(Yacht.class);
|
||||
|
||||
|
||||
//BOTH AFAIK
|
||||
private String boatType;
|
||||
private Integer sourceId;
|
||||
private String hullID; //matches HullNum in the XML spec.
|
||||
@@ -43,43 +27,24 @@ public class Yacht extends Observable {
|
||||
private String boatName;
|
||||
private String country;
|
||||
|
||||
private Long estimateTimeAtFinish;
|
||||
private Integer currentMarkSeqID = 0;
|
||||
private Long markRoundTime;
|
||||
private Double distanceToCurrentMark;
|
||||
private Long timeTillNext;
|
||||
private Double heading;
|
||||
private Integer legNumber = 0;
|
||||
|
||||
//SERVER SIDE
|
||||
public static final Double TURN_STEP = 5.0; //This should be in some utils class somewhere 2bh. Public for tests sake.
|
||||
private Double lastHeading;
|
||||
private Boolean sailIn;
|
||||
private Double heading;
|
||||
private GeoPoint location;
|
||||
private Integer boatStatus;
|
||||
private Double currentVelocity;
|
||||
private Double currentMaxVelocity;
|
||||
private Boolean isAuto;
|
||||
private Double autoHeading;
|
||||
|
||||
//MARK ROUNDING INFO
|
||||
private GeoPoint lastLocation; //For purposes of mark rounding calculations
|
||||
private Boolean hasEnteredRoundingZone; //The distance that the boat must be from the mark to round
|
||||
private Integer currentMarkSeqID = 0;
|
||||
private GeoPoint lastLocation;
|
||||
private Boolean hasEnteredRoundingZone;
|
||||
private Mark closestCurrentMark;
|
||||
private Boolean hasPassedLine;
|
||||
private Boolean hasPassedThroughGate;
|
||||
private Boolean finishedRace;
|
||||
|
||||
//CLIENT SIDE
|
||||
private List<YachtLocationListener> locationListeners = new ArrayList<>();
|
||||
private ReadOnlyDoubleWrapper velocityProperty = new ReadOnlyDoubleWrapper();
|
||||
private ReadOnlyLongWrapper timeTillNextProperty = new ReadOnlyLongWrapper();
|
||||
private ReadOnlyLongWrapper timeSinceLastMarkProperty = new ReadOnlyLongWrapper();
|
||||
private CompoundMark lastMarkRounded;
|
||||
private Integer positionInt = 0;
|
||||
private Color colour;
|
||||
|
||||
public Yacht(String boatType, Integer sourceId, String hullID, String shortName,
|
||||
public ServerYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
||||
String boatName, String country) {
|
||||
this.boatType = boatType;
|
||||
this.sourceId = sourceId;
|
||||
@@ -103,6 +68,7 @@ public class Yacht extends Observable {
|
||||
|
||||
/**
|
||||
* Changes the boats current currentVelocity by a set amount, positive or negative
|
||||
*
|
||||
* @param velocityChange The ammount to change the currentVelocity by, in mms-1
|
||||
*/
|
||||
public void changeVelocity(Double velocityChange) {
|
||||
@@ -128,7 +94,6 @@ public class Yacht extends Observable {
|
||||
super.addObserver(o);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adjusts the heading of the boat by a given amount, while recording the boats last heading.
|
||||
*
|
||||
@@ -291,10 +256,6 @@ public class Yacht extends Observable {
|
||||
return normalizedHeading;
|
||||
}
|
||||
|
||||
public String getBoatType() {
|
||||
return boatType;
|
||||
}
|
||||
|
||||
public Integer getSourceId() {
|
||||
//@TODO Remove and merge with Creating Game Loop
|
||||
if (sourceId == null) {
|
||||
@@ -303,6 +264,7 @@ public class Yacht extends Observable {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
// TODO: 15/08/17 This method is implicitly called from the XML generator for boats DO NOT DELETE
|
||||
public String getHullID() {
|
||||
if (hullID == null) {
|
||||
return "";
|
||||
@@ -310,6 +272,7 @@ public class Yacht extends Observable {
|
||||
return hullID;
|
||||
}
|
||||
|
||||
// TODO: 15/08/17 This method is implicitly called from the XML generator for boats DO NOT DELETE
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
@@ -325,102 +288,11 @@ public class Yacht extends Observable {
|
||||
return country;
|
||||
}
|
||||
|
||||
public Integer getBoatStatus() {
|
||||
return boatStatus;
|
||||
}
|
||||
|
||||
public void setBoatStatus(Integer boatStatus) {
|
||||
this.boatStatus = boatStatus;
|
||||
}
|
||||
|
||||
public Integer getLegNumber() {
|
||||
return legNumber;
|
||||
}
|
||||
|
||||
public void setLegNumber(Integer legNumber) {
|
||||
// if (colour != null && position != "-" && legNumber != this.legNumber) {
|
||||
// RaceViewController.updateYachtPositionSparkline(this, legNumber);
|
||||
// }
|
||||
this.legNumber = legNumber;
|
||||
}
|
||||
|
||||
public void setEstimateTimeTillNextMark(Long estimateTimeTillNextMark) {
|
||||
timeTillNext = estimateTimeTillNextMark;
|
||||
}
|
||||
|
||||
public String getEstimateTimeAtFinish() {
|
||||
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
return format.format(estimateTimeAtFinish);
|
||||
}
|
||||
|
||||
public void setEstimateTimeAtFinish(Long estimateTimeAtFinish) {
|
||||
this.estimateTimeAtFinish = estimateTimeAtFinish;
|
||||
}
|
||||
|
||||
public Integer getPositionInteger() {
|
||||
return positionInt;
|
||||
}
|
||||
|
||||
public void setPositionInteger(Integer position) {
|
||||
this.positionInt = position;
|
||||
}
|
||||
|
||||
public void updateVelocityProperty(double velocity) {
|
||||
this.velocityProperty.set(velocity);
|
||||
}
|
||||
|
||||
public void setMarkRoundingTime(Long markRoundingTime) {
|
||||
this.markRoundTime = markRoundingTime;
|
||||
}
|
||||
|
||||
public ReadOnlyDoubleProperty getVelocityProperty() {
|
||||
return velocityProperty.getReadOnlyProperty();
|
||||
}
|
||||
|
||||
public double getVelocityMMS() {
|
||||
return currentVelocity;
|
||||
}
|
||||
|
||||
public ReadOnlyLongProperty timeTillNextProperty() {
|
||||
return timeTillNextProperty.getReadOnlyProperty();
|
||||
}
|
||||
|
||||
public Double getVelocityKnots() {
|
||||
return currentVelocity / 1000 * 1.943844492; // TODO: 26/07/17 cir27 - remove magic number
|
||||
}
|
||||
|
||||
public Long getTimeTillNext() {
|
||||
return timeTillNext;
|
||||
}
|
||||
|
||||
public Long getMarkRoundTime() {
|
||||
return markRoundTime;
|
||||
}
|
||||
|
||||
public CompoundMark getLastMarkRounded() {
|
||||
return lastMarkRounded;
|
||||
}
|
||||
|
||||
public void setLastMarkRounded(CompoundMark lastMarkRounded) {
|
||||
this.lastMarkRounded = lastMarkRounded;
|
||||
}
|
||||
|
||||
public GeoPoint getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current location of the boat in lat and long whilst preserving the last location
|
||||
*
|
||||
* @param lat Latitude
|
||||
* @param lng Longitude
|
||||
*/
|
||||
public void setLocation(Double lat, Double lng) {
|
||||
lastLocation.setLat(location.getLat());
|
||||
lastLocation.setLng(location.getLng());
|
||||
location.setLat(lat);
|
||||
location.setLng(lng);
|
||||
}
|
||||
|
||||
public Double getHeading() {
|
||||
return heading;
|
||||
@@ -439,26 +311,6 @@ public class Yacht extends Observable {
|
||||
return boatName;
|
||||
}
|
||||
|
||||
public void updateTimeSinceLastMarkProperty(long timeSinceLastMark) {
|
||||
this.timeSinceLastMarkProperty.set(timeSinceLastMark);
|
||||
}
|
||||
|
||||
public ReadOnlyLongProperty timeSinceLastMarkProperty() {
|
||||
return timeSinceLastMarkProperty.getReadOnlyProperty();
|
||||
}
|
||||
|
||||
public void setTimeTillNext(Long timeTillNext) {
|
||||
this.timeTillNext = timeTillNext;
|
||||
}
|
||||
|
||||
|
||||
public Color getColour() {
|
||||
return colour;
|
||||
}
|
||||
|
||||
public void setColour(Color colour) {
|
||||
this.colour = colour;
|
||||
}
|
||||
|
||||
public void setIsFinished(Boolean isFinished) {
|
||||
finishedRace = isFinished;
|
||||
@@ -519,30 +371,4 @@ public class Yacht extends Observable {
|
||||
public Boolean hasPassedLine() {
|
||||
return hasPassedLine;
|
||||
}
|
||||
|
||||
public Double getDistanceToCurrentMark() {
|
||||
return distanceToCurrentMark;
|
||||
}
|
||||
|
||||
public Double getCurrentMaxVelocity() {
|
||||
return currentMaxVelocity;
|
||||
}
|
||||
|
||||
public void setCurrentMaxVelocity(Double currentMaxVelocity) {
|
||||
this.currentMaxVelocity = currentMaxVelocity;
|
||||
}
|
||||
|
||||
public void updateLocation(double lat, double lng, double heading, double velocity) {
|
||||
setLocation(lat, lng);
|
||||
this.heading = heading;
|
||||
this.currentVelocity = velocity;
|
||||
updateVelocityProperty(velocity);
|
||||
for (YachtLocationListener yll : locationListeners) {
|
||||
yll.notifyLocation(this, lat, lng, heading, velocity);
|
||||
}
|
||||
}
|
||||
|
||||
public void addLocationListener(YachtLocationListener listener) {
|
||||
locationListeners.add(listener);
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,14 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import seng302.model.Yacht;
|
||||
import seng302.model.ServerYacht;
|
||||
|
||||
/**
|
||||
* A Race object that can be parsed into XML
|
||||
*/
|
||||
public class Race {
|
||||
private List<Yacht> yachts;
|
||||
|
||||
private List<ServerYacht> yachts;
|
||||
private LocalDateTime startTime;
|
||||
|
||||
public Race(){
|
||||
@@ -22,7 +23,7 @@ public class Race {
|
||||
* Add a boat to the race
|
||||
* @param yacht The boat to add
|
||||
*/
|
||||
public void addBoat(Yacht yacht){
|
||||
public void addBoat(ServerYacht yacht) {
|
||||
yachts.add(yacht);
|
||||
}
|
||||
|
||||
@@ -30,7 +31,7 @@ public class Race {
|
||||
* Get a list of boats in the race
|
||||
* @return A List of boats
|
||||
*/
|
||||
public List<Yacht> getBoats(){
|
||||
public List<ServerYacht> getBoats() {
|
||||
return Collections.unmodifiableList(yachts);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import seng302.model.ClientYacht;
|
||||
import seng302.model.Limit;
|
||||
import seng302.model.Yacht;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Corner;
|
||||
import seng302.model.mark.Mark;
|
||||
@@ -125,8 +125,8 @@ public class XMLParser {
|
||||
* @param doc XML Document Object
|
||||
* @return Mapping of sourceIds to Boats.
|
||||
*/
|
||||
public static Map<Integer, Yacht> parseBoats(Document doc){
|
||||
Map<Integer, Yacht> competingBoats = new HashMap<>();
|
||||
public static Map<Integer, ClientYacht> parseBoats(Document doc) {
|
||||
Map<Integer, ClientYacht> competingBoats = new HashMap<>();
|
||||
|
||||
Element docEle = doc.getDocumentElement();
|
||||
|
||||
@@ -135,7 +135,8 @@ public class XMLParser {
|
||||
Node currentBoat = boatsList.item(i);
|
||||
if (currentBoat.getNodeName().equals("Boat")) {
|
||||
// Boat boat = new Boat(currentBoat);
|
||||
Yacht yacht = new Yacht(XMLParser.getNodeAttributeString(currentBoat, "Type"),
|
||||
ClientYacht yacht = new ClientYacht(
|
||||
XMLParser.getNodeAttributeString(currentBoat, "Type"),
|
||||
XMLParser.getNodeAttributeInt(currentBoat, "SourceID"),
|
||||
XMLParser.getNodeAttributeString(currentBoat, "HullNum"),
|
||||
XMLParser.getNodeAttributeString(currentBoat, "ShortName"),
|
||||
|
||||
@@ -14,8 +14,8 @@ import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.Pane;
|
||||
import seng302.gameServer.MainServerThread;
|
||||
import seng302.gameServer.server.messages.BoatAction;
|
||||
import seng302.model.ClientYacht;
|
||||
import seng302.model.RaceState;
|
||||
import seng302.model.Yacht;
|
||||
import seng302.model.stream.packets.StreamPacket;
|
||||
import seng302.model.stream.parser.MarkRoundingData;
|
||||
import seng302.model.stream.parser.PositionUpdateData;
|
||||
@@ -41,7 +41,7 @@ public class GameClient {
|
||||
|
||||
private RaceViewController raceView;
|
||||
|
||||
private Map<Integer, Yacht> allBoatsMap;
|
||||
private Map<Integer, ClientYacht> allBoatsMap;
|
||||
private RegattaXMLData regattaData;
|
||||
private RaceXMLData courseData;
|
||||
private RaceState raceState = new RaceState();
|
||||
@@ -151,7 +151,7 @@ public class GameClient {
|
||||
holderPane.getScene().setOnKeyPressed(this::keyPressed);
|
||||
holderPane.getScene().setOnKeyReleased(this::keyReleased);
|
||||
raceView = fxmlLoader.getController();
|
||||
Yacht player = allBoatsMap.get(socketThread.getClientId());
|
||||
ClientYacht player = allBoatsMap.get(socketThread.getClientId());
|
||||
raceView.loadRace(allBoatsMap, courseData, raceState, player);
|
||||
}
|
||||
|
||||
@@ -224,8 +224,8 @@ public class GameClient {
|
||||
private void updatePosition(PositionUpdateData positionData) {
|
||||
if (positionData.getType() == DeviceType.YACHT_TYPE) {
|
||||
if (allXMLReceived() && allBoatsMap.containsKey(positionData.getDeviceId())) {
|
||||
Yacht yacht = allBoatsMap.get(positionData.getDeviceId());
|
||||
yacht.updateLocation(positionData.getLat(),
|
||||
ClientYacht clientYacht = allBoatsMap.get(positionData.getDeviceId());
|
||||
clientYacht.updateLocation(positionData.getLat(),
|
||||
positionData.getLon(), positionData.getHeading(),
|
||||
positionData.getGroundSpeed());
|
||||
}
|
||||
@@ -242,11 +242,11 @@ public class GameClient {
|
||||
*/
|
||||
private void updateMarkRounding(MarkRoundingData roundingData) {
|
||||
if (allXMLReceived()) {
|
||||
Yacht yacht = allBoatsMap.get(roundingData.getBoatId());
|
||||
yacht.setMarkRoundingTime(roundingData.getTimeStamp());
|
||||
yacht.updateTimeSinceLastMarkProperty(
|
||||
ClientYacht clientYacht = allBoatsMap.get(roundingData.getBoatId());
|
||||
clientYacht.setMarkRoundingTime(roundingData.getTimeStamp());
|
||||
clientYacht.updateTimeSinceLastMarkProperty(
|
||||
raceState.getRaceTime() - roundingData.getTimeStamp());
|
||||
yacht.setLastMarkRounded(
|
||||
clientYacht.setLastMarkRounded(
|
||||
courseData.getCompoundMarks().get(
|
||||
roundingData.getMarkId()
|
||||
)
|
||||
@@ -258,20 +258,20 @@ public class GameClient {
|
||||
if (allXMLReceived()) {
|
||||
raceState.updateState(data);
|
||||
for (long[] boatData : data.getBoatData()) {
|
||||
Yacht yacht = allBoatsMap.get((int) boatData[0]);
|
||||
yacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]);
|
||||
yacht.setEstimateTimeAtFinish(boatData[2]);
|
||||
ClientYacht clientYacht = allBoatsMap.get((int) boatData[0]);
|
||||
clientYacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]);
|
||||
clientYacht.setEstimateTimeAtFinish(boatData[2]);
|
||||
int legNumber = (int) boatData[3];
|
||||
yacht.setLegNumber(legNumber);
|
||||
yacht.setBoatStatus((int) boatData[4]);
|
||||
if (legNumber != yacht.getLegNumber()) {
|
||||
clientYacht.setLegNumber(legNumber);
|
||||
clientYacht.setBoatStatus((int) boatData[4]);
|
||||
if (legNumber != clientYacht.getLegNumber()) {
|
||||
int placing = 1;
|
||||
for (Yacht otherYacht : allBoatsMap.values()) {
|
||||
if (otherYacht.getSourceId() != boatData[0] &&
|
||||
yacht.getLegNumber() <= otherYacht.getLegNumber())
|
||||
for (ClientYacht otherClientYacht : allBoatsMap.values()) {
|
||||
if (otherClientYacht.getSourceId() != boatData[0] &&
|
||||
clientYacht.getLegNumber() <= otherClientYacht.getLegNumber())
|
||||
placing++;
|
||||
}
|
||||
yacht.setPositionInteger(placing);
|
||||
clientYacht.setPositionInteger(placing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.shape.Polygon;
|
||||
import javafx.scene.text.Text;
|
||||
import seng302.model.ClientYacht;
|
||||
import seng302.model.Colors;
|
||||
import seng302.model.GeoPoint;
|
||||
import seng302.model.Limit;
|
||||
import seng302.model.Yacht;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Corner;
|
||||
import seng302.model.mark.Mark;
|
||||
@@ -61,8 +61,8 @@ public class GameView extends Pane {
|
||||
private List<Limit> borderPoints;
|
||||
private Map<Mark, Marker> markerObjects;
|
||||
|
||||
private Map<Yacht, BoatObject> boatObjects = new HashMap<>();
|
||||
private Map<Yacht, AnnotationBox> annotations = new HashMap<>();
|
||||
private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>();
|
||||
private Map<ClientYacht, AnnotationBox> annotations = new HashMap<>();
|
||||
private ObservableList<Node> gameObjects;
|
||||
private Group annotationsGroup = new Group();
|
||||
private Group wakesGroup = new Group();
|
||||
@@ -318,23 +318,23 @@ public class GameView extends Pane {
|
||||
|
||||
/**
|
||||
* Draws all the boats.
|
||||
* @param yachts The yachts to set in the race
|
||||
* @param clientYachts The yachts to set in the race
|
||||
*/
|
||||
public void setBoats(List<Yacht> yachts) {
|
||||
public void setBoats(List<ClientYacht> clientYachts) {
|
||||
BoatObject newBoat;
|
||||
final List<Group> wakes = new ArrayList<>();
|
||||
for (Yacht yacht : yachts) {
|
||||
for (ClientYacht clientYacht : clientYachts) {
|
||||
Paint colour = Colors.getColor();
|
||||
newBoat = new BoatObject();
|
||||
newBoat.setFill(colour);
|
||||
boatObjects.put(yacht, newBoat);
|
||||
createAndBindAnnotationBox(yacht, colour);
|
||||
boatObjects.put(clientYacht, newBoat);
|
||||
createAndBindAnnotationBox(clientYacht, colour);
|
||||
// wakesGroup.getChildren().add(newBoat.getWake());
|
||||
wakes.add(newBoat.getWake());
|
||||
boatObjectGroup.getChildren().add(newBoat);
|
||||
trails.getChildren().add(newBoat.getTrail());
|
||||
// TODO: 1/08/17 Make this less vile to look at.
|
||||
yacht.addLocationListener((boat, lat, lon, heading, velocity) ->{
|
||||
clientYacht.addLocationListener((boat, lat, lon, heading, velocity) -> {
|
||||
BoatObject bo = boatObjects.get(boat);
|
||||
Point2D p2d = findScaledXY(lat, lon);
|
||||
bo.moveTo(p2d.getX(), p2d.getY(), heading, velocity);
|
||||
@@ -358,11 +358,11 @@ public class GameView extends Pane {
|
||||
});
|
||||
}
|
||||
|
||||
private void createAndBindAnnotationBox (Yacht yacht, Paint colour) {
|
||||
private void createAndBindAnnotationBox(ClientYacht clientYacht, Paint colour) {
|
||||
AnnotationBox newAnnotation = new AnnotationBox();
|
||||
newAnnotation.setFill(colour);
|
||||
newAnnotation.addAnnotation(
|
||||
"name", "Player: " + yacht.getShortName()
|
||||
"name", "Player: " + clientYacht.getShortName()
|
||||
);
|
||||
// newAnnotation.addAnnotation(
|
||||
// "velocity",
|
||||
@@ -385,7 +385,7 @@ public class GameView extends Pane {
|
||||
// return format.format(time);
|
||||
// }
|
||||
// );
|
||||
annotations.put(yacht, newAnnotation);
|
||||
annotations.put(clientYacht, newAnnotation);
|
||||
}
|
||||
|
||||
private void drawFps(Double fps){
|
||||
@@ -562,9 +562,9 @@ public class GameView extends Pane {
|
||||
fpsDisplay.setVisible(visibility);
|
||||
}
|
||||
|
||||
public void selectBoat (Yacht selectedYacht) {
|
||||
public void selectBoat(ClientYacht selectedClientYacht) {
|
||||
boatObjects.forEach((boat, group) ->
|
||||
group.setIsSelected(boat == selectedYacht)
|
||||
group.setIsSelected(boat == selectedClientYacht)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -576,7 +576,7 @@ public class GameView extends Pane {
|
||||
timer.start();
|
||||
}
|
||||
|
||||
public void setBoatAsPlayer (Yacht playerYacht) {
|
||||
public void setBoatAsPlayer(ClientYacht playerYacht) {
|
||||
boatObjects.get(playerYacht).setAsPlayer();
|
||||
annotations.get(playerYacht).addAnnotation(
|
||||
"velocity",
|
||||
|
||||
@@ -17,24 +17,24 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import seng302.model.Yacht;
|
||||
import seng302.model.ClientYacht;
|
||||
|
||||
public class FinishScreenViewController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private GridPane finishScreenGridPane;
|
||||
@FXML
|
||||
private TableView<Yacht> finishOrderTable;
|
||||
private TableView<ClientYacht> finishOrderTable;
|
||||
@FXML
|
||||
private TableColumn<Yacht, String> posCol;
|
||||
private TableColumn<ClientYacht, String> posCol;
|
||||
@FXML
|
||||
private TableColumn<Yacht, String> boatNameCol;
|
||||
private TableColumn<ClientYacht, String> boatNameCol;
|
||||
@FXML
|
||||
private TableColumn<Yacht, String> shortNameCol;
|
||||
private TableColumn<ClientYacht, String> shortNameCol;
|
||||
@FXML
|
||||
private TableColumn<Yacht, String> countryCol;
|
||||
private TableColumn<ClientYacht, String> countryCol;
|
||||
|
||||
ObservableList<Yacht> data = FXCollections.observableArrayList();
|
||||
ObservableList<ClientYacht> data = FXCollections.observableArrayList();
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
@@ -61,9 +61,9 @@ public class FinishScreenViewController implements Initializable {
|
||||
finishOrderTable.refresh();
|
||||
}
|
||||
|
||||
public void setFinishers (List<Yacht> participants) {
|
||||
List<Yacht> sorted = new ArrayList<>(participants);
|
||||
sorted.sort(Comparator.comparingInt(Yacht::getPositionInteger));
|
||||
public void setFinishers(List<ClientYacht> participants) {
|
||||
List<ClientYacht> sorted = new ArrayList<>(participants);
|
||||
sorted.sort(Comparator.comparingInt(ClientYacht::getPositionInteger));
|
||||
finishOrderTable.getItems().setAll(sorted);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.util.StringConverter;
|
||||
import seng302.model.ClientYacht;
|
||||
import seng302.model.RaceState;
|
||||
import seng302.model.Yacht;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Mark;
|
||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||
@@ -70,10 +70,10 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
@FXML
|
||||
private Button selectAnnotationBtn;
|
||||
@FXML
|
||||
private ComboBox<Yacht> yachtSelectionComboBox;
|
||||
private ComboBox<ClientYacht> yachtSelectionComboBox;
|
||||
|
||||
//Race Data
|
||||
private Map<Integer, Yacht> participants;
|
||||
private Map<Integer, ClientYacht> participants;
|
||||
private Map<Integer, CompoundMark> markers;
|
||||
private RaceXMLData courseData;
|
||||
private GameView gameView;
|
||||
@@ -101,7 +101,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
}
|
||||
|
||||
public void loadRace (
|
||||
Map<Integer, Yacht> participants, RaceXMLData raceData, RaceState raceState, Yacht player
|
||||
Map<Integer, ClientYacht> participants, RaceXMLData raceData, RaceState raceState,
|
||||
ClientYacht player
|
||||
) {
|
||||
this.participants = participants;
|
||||
this.courseData = raceData;
|
||||
@@ -214,7 +215,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
// TODO: 2/08/17 there is about 0 chance of this working. Once we are keeping track of boat positions it can be fixed.
|
||||
// Collect the racing yachts that aren't already in the chart
|
||||
sparkLineData.clear();
|
||||
List<Yacht> sparkLineCandidates = new ArrayList<>(participants.values());
|
||||
List<ClientYacht> sparkLineCandidates = new ArrayList<>(participants.values());
|
||||
// Create a new data series for new yachts
|
||||
sparkLineCandidates
|
||||
.stream()
|
||||
@@ -260,15 +261,15 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
|
||||
/**
|
||||
* Updates the yachts sparkline of the desired yacht and using the new leg number
|
||||
* @param yacht The yacht to be updated on the sparkline
|
||||
* @param clientYacht The yacht to be updated on the sparkline
|
||||
* @param legNumber the leg number that the position will be assigned to
|
||||
*/
|
||||
void updateYachtPositionSparkline(Yacht yacht, Integer legNumber){
|
||||
void updateYachtPositionSparkline(ClientYacht clientYacht, Integer legNumber) {
|
||||
for (XYChart.Series<String, Double> positionData : sparkLineData) {
|
||||
positionData.getData().add(
|
||||
new Data<>(
|
||||
Integer.toString(legNumber),
|
||||
1.0 + participants.size() - yacht.getPositionInteger()
|
||||
1.0 + participants.size() - clientYacht.getPositionInteger()
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -376,21 +377,21 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
// positionVbox.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
||||
|
||||
// list of racing yacht id
|
||||
List<Yacht> sorted = new ArrayList<>(participants.values());
|
||||
sorted.sort(Comparator.comparingInt(Yacht::getPositionInteger));
|
||||
List<ClientYacht> sorted = new ArrayList<>(participants.values());
|
||||
sorted.sort(Comparator.comparingInt(ClientYacht::getPositionInteger));
|
||||
List<Text> vboxEntries = new ArrayList<>();
|
||||
|
||||
for (Yacht yacht : sorted) {
|
||||
for (ClientYacht clientYacht : sorted) {
|
||||
// System.out.println("yacht == null " + String.valueOf(yacht == null));
|
||||
if (yacht.getBoatStatus() == 3) { // 3 is finish status
|
||||
Text textToAdd = new Text(yacht.getPositionInteger() + ". " +
|
||||
yacht.getShortName() + " (Finished)");
|
||||
if (clientYacht.getBoatStatus() == 3) { // 3 is finish status
|
||||
Text textToAdd = new Text(clientYacht.getPositionInteger() + ". " +
|
||||
clientYacht.getShortName() + " (Finished)");
|
||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||
vboxEntries.add(textToAdd);
|
||||
|
||||
} else {
|
||||
Text textToAdd = new Text(yacht.getPositionInteger() + ". " +
|
||||
yacht.getShortName() + " ");
|
||||
Text textToAdd = new Text(clientYacht.getPositionInteger() + ". " +
|
||||
clientYacht.getShortName() + " ");
|
||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||
textToAdd.setStyle("");
|
||||
vboxEntries.add(textToAdd);
|
||||
@@ -575,9 +576,9 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
/**
|
||||
* Sets all the annotations of the selected yacht to be visible and all others to be hidden
|
||||
*
|
||||
* @param yacht The yacht for which we want to view all annotations
|
||||
* @param clientYacht The yacht for which we want to view all annotations
|
||||
*/
|
||||
private void setSelectedBoat(Yacht yacht) {
|
||||
private void setSelectedBoat(ClientYacht clientYacht) {
|
||||
// for (BoatObject bg : gameViewController.getBoatGroups()) {
|
||||
// //We need to iterate over all race groups to get the matching yacht group belonging to this yacht if we
|
||||
// //are to toggle its annotations, there is no other backwards knowledge of a yacht to its yachtgroup.
|
||||
|
||||
Reference in New Issue
Block a user