mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Fixed bug that caused mark arrows to be rendered on Marker id not LegNumber
#bugs
This commit is contained in:
@@ -20,8 +20,6 @@ import seng302.gameServer.messages.MarkRoundingMessage;
|
|||||||
import seng302.gameServer.messages.MarkType;
|
import seng302.gameServer.messages.MarkType;
|
||||||
import seng302.gameServer.messages.Message;
|
import seng302.gameServer.messages.Message;
|
||||||
import seng302.gameServer.messages.RoundingBoatStatus;
|
import seng302.gameServer.messages.RoundingBoatStatus;
|
||||||
import seng302.gameServer.messages.XMLMessage;
|
|
||||||
import seng302.gameServer.messages.XMLMessageSubType;
|
|
||||||
import seng302.gameServer.messages.YachtEventCodeMessage;
|
import seng302.gameServer.messages.YachtEventCodeMessage;
|
||||||
import seng302.model.GeoPoint;
|
import seng302.model.GeoPoint;
|
||||||
import seng302.model.Limit;
|
import seng302.model.Limit;
|
||||||
@@ -31,11 +29,9 @@ import seng302.model.ServerYacht;
|
|||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
import seng302.model.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.model.mark.MarkOrder;
|
import seng302.model.mark.MarkOrder;
|
||||||
import seng302.model.stream.xml.generator.RaceXMLTemplate;
|
|
||||||
import seng302.model.token.Token;
|
import seng302.model.token.Token;
|
||||||
import seng302.model.token.TokenType;
|
import seng302.model.token.TokenType;
|
||||||
import seng302.utilities.GeoUtility;
|
import seng302.utilities.GeoUtility;
|
||||||
import seng302.utilities.XMLGenerator;
|
|
||||||
import seng302.utilities.XMLParser;
|
import seng302.utilities.XMLParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,16 +85,6 @@ public class GameState implements Runnable {
|
|||||||
private static List<NewMessageListener> markListeners;
|
private static List<NewMessageListener> markListeners;
|
||||||
|
|
||||||
private static Map<Player, String> playerStringMap = new HashMap<>();
|
private static Map<Player, String> playerStringMap = new HashMap<>();
|
||||||
/*
|
|
||||||
Ideally I would like to make this class an object instantiated by the server and given to
|
|
||||||
it's created threads if necessary. Outside of that I think the dependencies on it
|
|
||||||
(atm only Yacht & GameClient) can be removed from most other classes. The observable list of
|
|
||||||
players could be pulled directly from the server by the GameClient since it instantiates it
|
|
||||||
and it is reasonable for it to pull data. The current setup of publicly available statics is
|
|
||||||
pretty meh IMO because anything can change it making it unreliable and like people did with
|
|
||||||
the old ServerParser class everything that needs shared just gets thrown in the static
|
|
||||||
collections and things become a real mess.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public GameState(String hostIpAddress) {
|
public GameState(String hostIpAddress) {
|
||||||
windDirection = 180d;
|
windDirection = 180d;
|
||||||
|
|||||||
@@ -259,10 +259,6 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
* Initialise boats to specific spaced out geopoints behind starting line.
|
* Initialise boats to specific spaced out geopoints behind starting line.
|
||||||
*/
|
*/
|
||||||
private void initialiseBoatPositions() {
|
private void initialiseBoatPositions() {
|
||||||
// Getting the start line compound marks
|
|
||||||
// if (gameClient== null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
CompoundMark cm = GameState.getMarkOrder().getMarkOrder().get(0);
|
CompoundMark cm = GameState.getMarkOrder().getMarkOrder().get(0);
|
||||||
GeoPoint startMark1 = cm.getSubMark(1);
|
GeoPoint startMark1 = cm.getSubMark(1);
|
||||||
GeoPoint startMark2 = cm.getSubMark(2);
|
GeoPoint startMark2 = cm.getSubMark(2);
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import javafx.beans.property.ReadOnlyLongWrapper;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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)
|
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
|
||||||
@@ -32,7 +31,7 @@ public class ClientYacht extends Observable {
|
|||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface MarkRoundingListener {
|
public interface MarkRoundingListener {
|
||||||
void notifyRounding(ClientYacht yacht, CompoundMark markPassed, int legNumber);
|
void notifyRounding(ClientYacht yacht, int legNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
||||||
@@ -63,7 +62,6 @@ public class ClientYacht extends Observable {
|
|||||||
private ReadOnlyLongWrapper timeTillNextProperty = new ReadOnlyLongWrapper();
|
private ReadOnlyLongWrapper timeTillNextProperty = new ReadOnlyLongWrapper();
|
||||||
private ReadOnlyLongWrapper timeSinceLastMarkProperty = new ReadOnlyLongWrapper();
|
private ReadOnlyLongWrapper timeSinceLastMarkProperty = new ReadOnlyLongWrapper();
|
||||||
private ReadOnlyIntegerWrapper placingProperty = new ReadOnlyIntegerWrapper();
|
private ReadOnlyIntegerWrapper placingProperty = new ReadOnlyIntegerWrapper();
|
||||||
private CompoundMark lastMarkRounded;
|
|
||||||
private Color colour;
|
private Color colour;
|
||||||
|
|
||||||
public ClientYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
public ClientYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
||||||
@@ -189,14 +187,6 @@ public class ClientYacht extends Observable {
|
|||||||
return markRoundTime;
|
return markRoundTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundMark getLastMarkRounded() {
|
|
||||||
return lastMarkRounded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastMarkRounded(CompoundMark lastMarkRounded) {
|
|
||||||
this.lastMarkRounded = lastMarkRounded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GeoPoint getLocation() {
|
public GeoPoint getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
@@ -286,13 +276,12 @@ public class ClientYacht extends Observable {
|
|||||||
return sailIn;
|
return sailIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void roundMark(CompoundMark mark, long markRoundTime, long timeSinceLastMark) {
|
public void roundMark(long markRoundTime, long timeSinceLastMark) {
|
||||||
this.markRoundTime = markRoundTime;
|
this.markRoundTime = markRoundTime;
|
||||||
timeSinceLastMarkProperty.set(timeSinceLastMark);
|
timeSinceLastMarkProperty.set(timeSinceLastMark);
|
||||||
lastMarkRounded = mark;
|
|
||||||
legNumber++;
|
legNumber++;
|
||||||
for (MarkRoundingListener listener : markRoundingListeners) {
|
for (MarkRoundingListener listener : markRoundingListeners) {
|
||||||
listener.notifyRounding(this, lastMarkRounded, legNumber);
|
listener.notifyRounding(this, legNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import seng302.model.stream.parser.RaceStatusData;
|
|||||||
import seng302.model.stream.parser.YachtEventData;
|
import seng302.model.stream.parser.YachtEventData;
|
||||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||||
import seng302.model.stream.xml.parser.RegattaXMLData;
|
import seng302.model.stream.xml.parser.RegattaXMLData;
|
||||||
import seng302.model.token.Token;
|
|
||||||
import seng302.utilities.StreamParser;
|
import seng302.utilities.StreamParser;
|
||||||
import seng302.utilities.XMLParser;
|
import seng302.utilities.XMLParser;
|
||||||
import seng302.visualiser.controllers.FinishScreenViewController;
|
import seng302.visualiser.controllers.FinishScreenViewController;
|
||||||
@@ -334,7 +333,6 @@ public class GameClient {
|
|||||||
if (allXMLReceived()) {
|
if (allXMLReceived()) {
|
||||||
ClientYacht clientYacht = allBoatsMap.get(roundingData.getBoatId());
|
ClientYacht clientYacht = allBoatsMap.get(roundingData.getBoatId());
|
||||||
clientYacht.roundMark(
|
clientYacht.roundMark(
|
||||||
courseData.getCompoundMarks().get(roundingData.getMarkId()),
|
|
||||||
roundingData.getTimeStamp(),
|
roundingData.getTimeStamp(),
|
||||||
raceState.getRaceTime() - roundingData.getTimeStamp()
|
raceState.getRaceTime() - roundingData.getTimeStamp()
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,23 +26,15 @@ import javafx.scene.shape.Circle;
|
|||||||
import javafx.scene.shape.Polygon;
|
import javafx.scene.shape.Polygon;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import seng302.gameServer.GameState;
|
|
||||||
import seng302.gameServer.messages.XMLMessage;
|
|
||||||
import seng302.gameServer.messages.XMLMessageSubType;
|
|
||||||
import seng302.model.ClientYacht;
|
|
||||||
import seng302.gameServer.messages.RoundingSide;
|
import seng302.gameServer.messages.RoundingSide;
|
||||||
import seng302.model.ClientYacht;
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.Colors;
|
|
||||||
import seng302.model.GeoPoint;
|
import seng302.model.GeoPoint;
|
||||||
import seng302.model.Limit;
|
import seng302.model.Limit;
|
||||||
import seng302.model.ServerYacht;
|
|
||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
import seng302.model.mark.Corner;
|
import seng302.model.mark.Corner;
|
||||||
import seng302.model.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.model.stream.xml.generator.RaceXMLTemplate;
|
|
||||||
import seng302.model.token.Token;
|
import seng302.model.token.Token;
|
||||||
import seng302.utilities.GeoUtility;
|
import seng302.utilities.GeoUtility;
|
||||||
import seng302.utilities.XMLGenerator;
|
|
||||||
import seng302.visualiser.fxObjects.AnnotationBox;
|
import seng302.visualiser.fxObjects.AnnotationBox;
|
||||||
import seng302.visualiser.fxObjects.BoatObject;
|
import seng302.visualiser.fxObjects.BoatObject;
|
||||||
import seng302.visualiser.fxObjects.CourseBoundary;
|
import seng302.visualiser.fxObjects.CourseBoundary;
|
||||||
@@ -813,13 +805,8 @@ public class GameView extends Pane {
|
|||||||
playerYacht.addMarkRoundingListener(this::updateMarkArrows);
|
playerYacht.addMarkRoundingListener(this::updateMarkArrows);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMarkArrows (ClientYacht yacht, CompoundMark compoundMark, int legNumber) {
|
private void updateMarkArrows (ClientYacht yacht, int legNumber) {
|
||||||
//Only show arrows for this and next leg.
|
//Only show arrows for this and next leg.
|
||||||
if (compoundMark != null) {
|
|
||||||
for (Mark mark : compoundMark.getMarks()) {
|
|
||||||
markerObjects.get(mark).showNextExitArrow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CompoundMark nextMark = null;
|
CompoundMark nextMark = null;
|
||||||
if (legNumber < course.size() - 1) {
|
if (legNumber < course.size() - 1) {
|
||||||
nextMark = course.get(legNumber);
|
nextMark = course.get(legNumber);
|
||||||
@@ -835,6 +822,14 @@ public class GameView extends Pane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (legNumber - 1 >= 0) {
|
||||||
|
CompoundMark thisMark = course.get(Math.max(0, legNumber - 1));
|
||||||
|
if (thisMark != nextMark) {
|
||||||
|
for (Mark mark : thisMark.getMarks()) {
|
||||||
|
markerObjects.get(mark).showNextExitArrow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user