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/story1118_map_arrows' into 1124_Fixing_Order_And_Finish_Screen
# Conflicts: # src/main/java/seng302/gameServer/MainServerThread.java # src/main/java/seng302/visualiser/GameClient.java # src/main/java/seng302/visualiser/controllers/RaceViewController.java # src/main/resources/server_config/xml_templates/race.ftlh
This commit is contained in:
@@ -444,6 +444,7 @@ public class GameState implements Runnable {
|
|||||||
yacht.setHasPassedThroughGate(false);
|
yacht.setHasPassedThroughGate(false);
|
||||||
if (!markOrder.isLastMark(currentMarkSeqID)) {
|
if (!markOrder.isLastMark(currentMarkSeqID)) {
|
||||||
yacht.incrementMarkSeqID();
|
yacht.incrementMarkSeqID();
|
||||||
|
yacht.incrementLegNumber();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,7 +227,8 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
|
|
||||||
for (Player player : GameState.getPlayers()) {
|
for (Player player : GameState.getPlayers()) {
|
||||||
ServerYacht y = player.getYacht();
|
ServerYacht y = player.getYacht();
|
||||||
BoatSubMessage m = new BoatSubMessage(y.getSourceId(), y.getBoatStatus(), 0,
|
BoatSubMessage m = new BoatSubMessage(y.getSourceId(), y.getBoatStatus(),
|
||||||
|
y.getLegNumber(),
|
||||||
0, 0, 1234L,
|
0, 0, 1234L,
|
||||||
1234L);
|
1234L);
|
||||||
boatSubMessages.add(m);
|
boatSubMessages.add(m);
|
||||||
|
|||||||
@@ -2,7 +2,13 @@ package seng302.model;
|
|||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Observable;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
import seng302.model.stream.parser.RaceStartData;
|
import seng302.model.stream.parser.RaceStartData;
|
||||||
import seng302.model.stream.parser.RaceStatusData;
|
import seng302.model.stream.parser.RaceStatusData;
|
||||||
|
|
||||||
@@ -21,8 +27,10 @@ public class RaceState {
|
|||||||
private long expectedStartTime;
|
private long expectedStartTime;
|
||||||
private boolean isRaceStarted = false;
|
private boolean isRaceStarted = false;
|
||||||
long timeTillStart;
|
long timeTillStart;
|
||||||
|
private ObservableList<ClientYacht> playerPositions;
|
||||||
|
|
||||||
public RaceState() {
|
public RaceState() {
|
||||||
|
playerPositions = FXCollections.observableArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateState (RaceStatusData data) {
|
public void updateState (RaceStatusData data) {
|
||||||
@@ -69,4 +77,16 @@ public class RaceState {
|
|||||||
public boolean isRaceStarted () {
|
public boolean isRaceStarted () {
|
||||||
return isRaceStarted;
|
return isRaceStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBoats(Collection<ClientYacht> clientYachts) {
|
||||||
|
playerPositions.setAll(clientYachts);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sortPlayers() {
|
||||||
|
playerPositions.sort(Comparator.comparingInt(ClientYacht::getLegNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableList<ClientYacht> getPlayerPositions() {
|
||||||
|
return FXCollections.unmodifiableObservableList(playerPositions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public class ServerYacht extends Observable {
|
|||||||
private Double currentVelocity;
|
private Double currentVelocity;
|
||||||
private Boolean isAuto;
|
private Boolean isAuto;
|
||||||
private Double autoHeading;
|
private Double autoHeading;
|
||||||
|
private Integer legNumber;
|
||||||
|
|
||||||
//Mark Rounding
|
//Mark Rounding
|
||||||
private Integer currentMarkSeqID;
|
private Integer currentMarkSeqID;
|
||||||
@@ -65,6 +66,7 @@ public class ServerYacht extends Observable {
|
|||||||
this.heading = 120.0; //In degrees
|
this.heading = 120.0; //In degrees
|
||||||
this.currentVelocity = 0d; //in mms-1
|
this.currentVelocity = 0d; //in mms-1
|
||||||
this.currentMarkSeqID = 0;
|
this.currentMarkSeqID = 0;
|
||||||
|
this.legNumber = 0;
|
||||||
|
|
||||||
this.hasEnteredRoundingZone = false;
|
this.hasEnteredRoundingZone = false;
|
||||||
this.hasPassedLine = false;
|
this.hasPassedLine = false;
|
||||||
@@ -381,5 +383,12 @@ public class ServerYacht extends Observable {
|
|||||||
return hasPassedLine;
|
return hasPassedLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void incrementLegNumber() {
|
||||||
|
legNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getLegNumber() {
|
||||||
|
return legNumber;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,13 +95,8 @@ public class StreamParser {
|
|||||||
boatID = bytesToLong(
|
boatID = bytesToLong(
|
||||||
Arrays.copyOfRange(payload, 24 + (i * 20), 28 + (i * 20)));
|
Arrays.copyOfRange(payload, 24 + (i * 20), 28 + (i * 20)));
|
||||||
boatStatus = (int) payload[28 + (i * 20)];
|
boatStatus = (int) payload[28 + (i * 20)];
|
||||||
|
|
||||||
// setBoatLegPosition(boat, (int) payload[29 + (i * 20)]);
|
|
||||||
// boat.setPenaltiesAwarded((int) payload[30 + (i * 20)]);
|
|
||||||
// boat.setPenaltiesServed((int) payload[31 + (i * 20)]);
|
|
||||||
estTimeAtNextMark = bytesToLong(
|
estTimeAtNextMark = bytesToLong(
|
||||||
Arrays.copyOfRange(payload, 32 + (i * 20), 38 + (i * 20)));
|
Arrays.copyOfRange(payload, 32 + (i * 20), 38 + (i * 20)));
|
||||||
// boat.setEstimateTimeTillNextMark(estTimeAtNextMark);
|
|
||||||
estTimeAtFinish = bytesToLong(
|
estTimeAtFinish = bytesToLong(
|
||||||
Arrays.copyOfRange(payload, 38 + (i * 20), 44 + (i * 20)));
|
Arrays.copyOfRange(payload, 38 + (i * 20), 44 + (i * 20)));
|
||||||
leg = (int) payload[29 + (i * 20)];
|
leg = (int) payload[29 + (i * 20)];
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ public class GameClient {
|
|||||||
allBoatsMap.forEach((id, boat) ->
|
allBoatsMap.forEach((id, boat) ->
|
||||||
clientLobbyList.add(id + " " + boat.getBoatName())
|
clientLobbyList.add(id + " " + boat.getBoatName())
|
||||||
);
|
);
|
||||||
|
raceState.setBoats(allBoatsMap.values());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RACE_START_STATUS:
|
case RACE_START_STATUS:
|
||||||
@@ -323,7 +324,7 @@ public class GameClient {
|
|||||||
raceFinished = false;
|
raceFinished = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (raceFinished == true) {
|
if (raceFinished) {
|
||||||
close();
|
close();
|
||||||
loadFinishScreenView();
|
loadFinishScreenView();
|
||||||
}
|
}
|
||||||
@@ -333,16 +334,10 @@ public class GameClient {
|
|||||||
clientYacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]);
|
clientYacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]);
|
||||||
clientYacht.setEstimateTimeAtFinish(boatData[2]);
|
clientYacht.setEstimateTimeAtFinish(boatData[2]);
|
||||||
int legNumber = (int) boatData[3];
|
int legNumber = (int) boatData[3];
|
||||||
clientYacht.setLegNumber(legNumber);
|
|
||||||
clientYacht.setBoatStatus((int) boatData[4]);
|
clientYacht.setBoatStatus((int) boatData[4]);
|
||||||
if (legNumber != clientYacht.getLegNumber()) {
|
if (legNumber != clientYacht.getLegNumber()) {
|
||||||
int placing = 1;
|
clientYacht.setLegNumber(legNumber);
|
||||||
for (ClientYacht otherClientYacht : allBoatsMap.values()) {
|
raceState.sortPlayers();
|
||||||
if (otherClientYacht.getSourceId() != boatData[0] &&
|
|
||||||
clientYacht.getLegNumber() <= otherClientYacht.getLegNumber())
|
|
||||||
placing++;
|
|
||||||
}
|
|
||||||
clientYacht.setPositionInteger(placing);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ListChangeListener;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
@@ -117,6 +119,15 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
initialiseBoatSelectionComboBox();
|
initialiseBoatSelectionComboBox();
|
||||||
initialiseSparkLine();
|
initialiseSparkLine();
|
||||||
|
|
||||||
|
raceState.getPlayerPositions().addListener((ListChangeListener<ClientYacht>) c -> {
|
||||||
|
while (c.next()) {
|
||||||
|
if (c.wasPermutated()) {
|
||||||
|
updateOrder(raceState.getPlayerPositions());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updateOrder(raceState.getPlayerPositions());
|
||||||
gameView = new GameView();
|
gameView = new GameView();
|
||||||
gameView.setFrameRateFXText(fpsDisplay);
|
gameView.setFrameRateFXText(fpsDisplay);
|
||||||
Platform.runLater(() -> contentAnchorPane.getChildren().add(0, gameView));
|
Platform.runLater(() -> contentAnchorPane.getChildren().add(0, gameView));
|
||||||
@@ -318,7 +329,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
public void run() {
|
public void run() {
|
||||||
updateRaceTime();
|
updateRaceTime();
|
||||||
updateWind();
|
updateWind();
|
||||||
updateOrder();
|
|
||||||
// updateSparkLine();
|
// updateSparkLine();
|
||||||
}
|
}
|
||||||
}, 0, 1000);
|
}, 0, 1000);
|
||||||
@@ -381,16 +391,10 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
* Updates the order of the yachts as from the StreamParser and sets them in the yacht order
|
* Updates the order of the yachts as from the StreamParser and sets them in the yacht order
|
||||||
* section
|
* section
|
||||||
*/
|
*/
|
||||||
private void updateOrder() {
|
private void updateOrder(ObservableList<ClientYacht> yachts) {
|
||||||
// positionVbox.getChildren().removeAll();
|
|
||||||
// positionVbox.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
|
||||||
|
|
||||||
// list of racing yacht id
|
|
||||||
List<ClientYacht> sorted = new ArrayList<>(participants.values());
|
|
||||||
sorted.sort(Comparator.comparingInt(ClientYacht::getPositionInteger));
|
|
||||||
List<Text> vboxEntries = new ArrayList<>();
|
List<Text> vboxEntries = new ArrayList<>();
|
||||||
|
|
||||||
for (ClientYacht clientYacht : sorted) {
|
for (ClientYacht clientYacht : yachts) {
|
||||||
// System.out.println("yacht == null " + String.valueOf(yacht == null));
|
// System.out.println("yacht == null " + String.valueOf(yacht == null));
|
||||||
if (clientYacht.getBoatStatus() == 3) { // 3 is finish status
|
if (clientYacht.getBoatStatus() == 3) { // 3 is finish status
|
||||||
Text textToAdd = new Text(clientYacht.getPositionInteger() + ". " +
|
Text textToAdd = new Text(clientYacht.getPositionInteger() + ". " +
|
||||||
|
|||||||
Reference in New Issue
Block a user