mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Attempted to fix sparklines, temporarily disabled them for end of sprint.
This commit is contained in:
@@ -360,7 +360,7 @@ public class GameState implements Runnable {
|
||||
Double velocity = yacht.getCurrentVelocity();
|
||||
Double trueWindAngle = Math.abs(windDirection - yacht.getHeading());
|
||||
Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle);
|
||||
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots);
|
||||
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots) * 5;
|
||||
// TODO: 15/08/17 remove magic numbers from these equations.
|
||||
if (yacht.getSailIn()) {
|
||||
if (velocity < maxBoatSpeed - 500) {
|
||||
|
||||
@@ -256,7 +256,6 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
currentByte = is.read();
|
||||
crcBuffer.write(currentByte);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.warn("Socket read failed", 1);
|
||||
}
|
||||
if (currentByte == -1) {
|
||||
|
||||
@@ -289,7 +289,7 @@ public class ClientYacht extends Observable {
|
||||
this.markRoundTime = markRoundTime;
|
||||
timeSinceLastMarkProperty.set(timeSinceLastMark);
|
||||
lastMarkRounded = mark;
|
||||
legNumber += 1;
|
||||
legNumber++;
|
||||
for (MarkRoundingListener listener : markRoundingListeners) {
|
||||
listener.notifyRounding(this, lastMarkRounded, legNumber);
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ public class ClientToServerThread implements Runnable {
|
||||
clientLog("Read byte failed", 1);
|
||||
}
|
||||
if (currentByte == -1) {
|
||||
throw new ByteReadException("InputStream reach end of stream");
|
||||
clientLog("InputStream reach end of stream", 1);
|
||||
}
|
||||
return currentByte;
|
||||
}
|
||||
|
||||
@@ -303,6 +303,7 @@ public class GameClient {
|
||||
raceState.getRaceTime() - roundingData.getTimeStamp()
|
||||
);
|
||||
}
|
||||
updatePlayerPositions();
|
||||
}
|
||||
|
||||
private void processRaceStatusUpdate(RaceStatusData data) {
|
||||
@@ -319,12 +320,11 @@ public class GameClient {
|
||||
ClientYacht clientYacht = allBoatsMap.get((int) boatData[0]);
|
||||
clientYacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]);
|
||||
clientYacht.setEstimateTimeAtFinish(boatData[2]);
|
||||
int legNumber = (int) boatData[3];
|
||||
// int legNumber = (int) boatData[3];
|
||||
clientYacht.setBoatStatus((int) boatData[4]);
|
||||
if (legNumber != clientYacht.getLegNumber()) {
|
||||
clientYacht.setLegNumber(legNumber);
|
||||
updatePlayerPositions();
|
||||
}
|
||||
// if (legNumber != clientYacht.getLegNumber()) {
|
||||
// clientYacht.setLegNumber(legNumber);
|
||||
// }
|
||||
}
|
||||
|
||||
if (raceFinished) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.util.StringConverter;
|
||||
import seng302.gameServer.messages.BoatStatus;
|
||||
import seng302.model.ClientYacht;
|
||||
import seng302.model.RaceState;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
@@ -94,9 +95,10 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
importantAnnotations = new ImportantAnnotationsState();
|
||||
|
||||
//Formatting the y axis of the sparkline
|
||||
raceSparkLine.getYAxis().setRotate(180);
|
||||
raceSparkLine.getYAxis().setTickLabelRotation(180);
|
||||
raceSparkLine.getYAxis().setTranslateX(-5);
|
||||
// raceSparkLine.getYAxis().setRotate(180);
|
||||
// raceSparkLine.getYAxis().setTickLabelRotation(180);
|
||||
// raceSparkLine.getYAxis().setTranslateX(-5);
|
||||
raceSparkLine.visibleProperty().setValue(false);
|
||||
raceSparkLine.getYAxis().setAutoRanging(false);
|
||||
sparklineYAxis.setTickMarkVisible(false);
|
||||
|
||||
@@ -124,6 +126,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
while (c.next()) {
|
||||
if (c.wasPermutated()) {
|
||||
updateOrder(raceState.getPlayerPositions());
|
||||
updateSparkLine();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -247,14 +250,17 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
// Create a new data series for new yachts
|
||||
sparkLineCandidates
|
||||
.stream()
|
||||
.filter(yacht -> yacht.getPlacing() != null)
|
||||
.filter(yacht -> yacht.getPosition() != null)
|
||||
.forEach(yacht -> {
|
||||
System.out.println(
|
||||
yacht.getBoatName() + " pos: " + yacht.getPosition() + " legno: " + yacht
|
||||
.getLegNumber());
|
||||
Series<String, Double> yachtData = new Series<>();
|
||||
yachtData.setName(yacht.getSourceId().toString());
|
||||
yachtData.getData().add(
|
||||
new XYChart.Data<>(
|
||||
new Data<>(
|
||||
Integer.toString(yacht.getLegNumber()),
|
||||
1.0 + participants.size() - yacht.getPlacing()
|
||||
1.0 + participants.size() - yacht.getPosition()
|
||||
)
|
||||
);
|
||||
sparkLineData.add(yachtData);
|
||||
@@ -270,12 +276,14 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
|
||||
// Adds the new data series to the sparkline (and set the colour of the series)
|
||||
Platform.runLater(() -> {
|
||||
sparkLineData
|
||||
.stream()
|
||||
.filter(spark -> !raceSparkLine.getData().contains(spark))
|
||||
.forEach(spark -> {
|
||||
System.out.println(spark.getName());
|
||||
raceSparkLine.getData().add(spark);
|
||||
spark.getNode().lookup(".chart-series-line").setStyle("-fx-stroke:" + getBoatColorAsRGB(spark.getName()));
|
||||
});
|
||||
@@ -411,7 +419,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
|
||||
for (int i = 0; i < yachts.size(); i++) {
|
||||
// System.out.println("yacht == null " + String.valueOf(yacht == null));
|
||||
if (yachts.get(i).getBoatStatus() == 3) { // 3 is finish status
|
||||
if (yachts.get(i).getBoatStatus() == BoatStatus.FINISHED
|
||||
.getCode()) { // 3 is finish status
|
||||
Text textToAdd = new Text(i + 1 + ". " +
|
||||
yachts.get(i).getShortName() + " (Finished)");
|
||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||
|
||||
Reference in New Issue
Block a user