mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Working ordering for in game AND race finish screen.
List in RaceState holds a sorted list of yachts. A Listener is added to this list, listening for a permutation change, on perm change, sorts the list by comparitor of leg number of each yacht (stable sort)
This commit is contained in:
@@ -437,6 +437,7 @@ public class GameState implements Runnable {
|
||||
}
|
||||
|
||||
if (hasProgressed) {
|
||||
yacht.incrementLegNumber();
|
||||
sendMarkRoundingMessage(yacht);
|
||||
logMarkRounding(yacht);
|
||||
yacht.setHasPassedLine(false);
|
||||
@@ -444,7 +445,6 @@ public class GameState implements Runnable {
|
||||
yacht.setHasPassedThroughGate(false);
|
||||
if (!markOrder.isLastMark(currentMarkSeqID)) {
|
||||
yacht.incrementMarkSeqID();
|
||||
yacht.incrementLegNumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +83,11 @@ public class RaceState {
|
||||
}
|
||||
|
||||
public void sortPlayers() {
|
||||
playerPositions.sort(Comparator.comparingInt(ClientYacht::getLegNumber));
|
||||
playerPositions.sort((yacht1, yacht2) -> Integer.compare(yacht2.getLegNumber(),
|
||||
yacht1.getLegNumber()));
|
||||
}
|
||||
|
||||
public ObservableList<ClientYacht> getPlayerPositions() {
|
||||
return FXCollections.unmodifiableObservableList(playerPositions);
|
||||
return playerPositions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ public class GameClient {
|
||||
}
|
||||
|
||||
FinishScreenViewController controller = fxmlLoader.getController();
|
||||
controller.setFinishers(allBoatsMap.values());
|
||||
controller.setFinishers(raceState.getPlayerPositions());
|
||||
}
|
||||
|
||||
private void parsePackets() {
|
||||
@@ -338,6 +338,11 @@ public class GameClient {
|
||||
if (legNumber != clientYacht.getLegNumber()) {
|
||||
clientYacht.setLegNumber(legNumber);
|
||||
raceState.sortPlayers();
|
||||
// System.out.println("ORDER:");
|
||||
// for (ClientYacht clientYacht1 : raceState.getPlayerPositions()) {
|
||||
// System.out.println(clientYacht1.getShortName());
|
||||
// }
|
||||
// System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,17 +394,17 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
private void updateOrder(ObservableList<ClientYacht> yachts) {
|
||||
List<Text> vboxEntries = new ArrayList<>();
|
||||
|
||||
for (ClientYacht clientYacht : yachts) {
|
||||
for (int i = 0; i < yachts.size(); i++) {
|
||||
// System.out.println("yacht == null " + String.valueOf(yacht == null));
|
||||
if (clientYacht.getBoatStatus() == 3) { // 3 is finish status
|
||||
Text textToAdd = new Text(clientYacht.getPositionInteger() + ". " +
|
||||
clientYacht.getShortName() + " (Finished)");
|
||||
if (yachts.get(i).getBoatStatus() == 3) { // 3 is finish status
|
||||
Text textToAdd = new Text(i + 1 + ". " +
|
||||
yachts.get(i).getShortName() + " (Finished)");
|
||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||
vboxEntries.add(textToAdd);
|
||||
|
||||
} else {
|
||||
Text textToAdd = new Text(clientYacht.getPositionInteger() + ". " +
|
||||
clientYacht.getShortName() + " ");
|
||||
Text textToAdd = new Text(i + 1 + ". " +
|
||||
yachts.get(i).getShortName() + " ");
|
||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||
textToAdd.setStyle("");
|
||||
vboxEntries.add(textToAdd);
|
||||
|
||||
Reference in New Issue
Block a user