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/develop' into develop
This commit is contained in:
@@ -228,18 +228,21 @@ public class ClientPacketParser {
|
||||
|
||||
private static void setBoatLegPosition(Yacht updatingBoat, Integer leg){
|
||||
Integer placing = 1;
|
||||
if (leg != updatingBoat.getLegNumber() && (raceStarted || raceFinished)) {
|
||||
|
||||
if (/* TODO implement when we are getting this data /TODO leg != updatingBoat.getLegNumber() && */(raceStarted || raceFinished)) {
|
||||
for (Yacht boat : boats.values()) {
|
||||
placing = boat.getSourceId();
|
||||
/* See above to-do
|
||||
if (boat.getLegNumber() != null && leg <= boat.getLegNumber()){
|
||||
placing += 1;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
updatingBoat.setPosition(placing.toString());
|
||||
updatingBoat.setLegNumber(leg);
|
||||
boatsPos.putIfAbsent(placing, updatingBoat);
|
||||
boatsPos.replace(placing, updatingBoat);
|
||||
} else if(updatingBoat.getLegNumber() == null){
|
||||
updatingBoat.setPosition("1");
|
||||
updatingBoat.setPosition("-");
|
||||
updatingBoat.setLegNumber(leg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,6 +287,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
updateWindDirection();
|
||||
// updateOrder();
|
||||
updateBoatSelectionComboBox();
|
||||
updateOrder();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -383,9 +384,12 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
}
|
||||
|
||||
if (ClientPacketParser.isRaceStarted()) {
|
||||
/*
|
||||
for (Yacht boat : ClientPacketParser.getBoatsPos().values()) {
|
||||
if (participantIDs.contains(boat.getSourceId())) { // check if the boat is racing
|
||||
if (boat.getBoatStatus() == 3) { // 3 is finish status
|
||||
System.out.println("Hi tjere" + boat.getBoatName());
|
||||
if (participantIDs.contains(boat.getSourceId()) || true
|
||||
) { // check if the boat is racing
|
||||
if (boat.getBoatStatus() == 69) { // 3 is finish status
|
||||
Text textToAdd = new Text(boat.getPosition() + ". " +
|
||||
boat.getShortName() + " (Finished)");
|
||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||
@@ -397,9 +401,17 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||
textToAdd.setStyle("");
|
||||
positionVbox.getChildren().add(textToAdd);
|
||||
System.out.println("Adding " + textToAdd.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (Yacht boat : ClientPacketParser.getBoats().values()){
|
||||
Text textToAdd = new Text(boat.getSourceId() + ". " + boat.getShortName() + " ");
|
||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||
textToAdd.setStyle("");
|
||||
positionVbox.getChildren().add(textToAdd);
|
||||
}
|
||||
} else {
|
||||
for (Yacht boat : ClientPacketParser.getBoats().values()) {
|
||||
if (participantIDs.contains(boat.getSourceId())) { // check if the boat is racing
|
||||
|
||||
@@ -26,6 +26,9 @@ public class GameState implements Runnable {
|
||||
private static Boolean isRaceStarted;
|
||||
private static GameStages currentStage;
|
||||
|
||||
private static long startTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
public GameState(String hostIpAddress) {
|
||||
windDirection = 170d;
|
||||
windSpeed = 10000d;
|
||||
@@ -79,9 +82,17 @@ public class GameState implements Runnable {
|
||||
}
|
||||
|
||||
public static void setCurrentStage(GameStages currentStage) {
|
||||
if (currentStage == GameStages.RACING){
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
GameState.currentStage = currentStage;
|
||||
}
|
||||
|
||||
public static long getStartTime(){
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public static Double getWindDirection() {
|
||||
return windDirection;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A class describing the overall server, which creates and collects server threads for each client
|
||||
@@ -133,8 +136,16 @@ public class MainServerThread extends Observable implements Runnable, ClientConn
|
||||
}
|
||||
|
||||
public void startGame() {
|
||||
Timer t = new Timer();
|
||||
|
||||
t.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
for (ServerToClientThread serverToClientThread : serverToClientThreads) {
|
||||
serverToClientThread.sendRaceStatusMessage();
|
||||
}
|
||||
}
|
||||
}, 0, 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,8 +340,7 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
|
||||
public void sendRaceStatusMessage() {
|
||||
// variables taken from GameServerThread
|
||||
int TIME_TILL_RACE_START = 20 * 1000;
|
||||
long startTime = System.currentTimeMillis() + TIME_TILL_RACE_START;
|
||||
|
||||
|
||||
List<BoatSubMessage> boatSubMessages = new ArrayList<>();
|
||||
BoatStatus boatStatus;
|
||||
@@ -369,7 +368,7 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
raceStatus = RaceStatus.WARNING;
|
||||
}
|
||||
|
||||
sendMessage(new RaceStatusMessage(1, raceStatus, startTime, GameState.getWindDirection(),
|
||||
sendMessage(new RaceStatusMessage(1, raceStatus, GameState.getStartTime(), GameState.getWindDirection(),
|
||||
GameState.getWindSpeedMMS().longValue(), GameState.getPlayers().size(),
|
||||
RaceType.MATCH_RACE, 1, boatSubMessages));
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
<children>
|
||||
<AnchorPane prefHeight="960.0" prefWidth="250.0" style="-fx-background-color: #2C2c36;" GridPane.rowSpan="3">
|
||||
<children>
|
||||
<Label layoutX="11.0" layoutY="259.0" text="Team Position" textFill="WHITE" />
|
||||
<Label layoutX="11.0" layoutY="283.0" text="Team Position" textFill="WHITE" />
|
||||
<Label layoutX="13.0" layoutY="432.0" text="Settings" textFill="WHITE" />
|
||||
<Label layoutX="11.0" layoutY="14.0" text="Timer" textFill="WHITE" />
|
||||
<Label layoutX="11.0" layoutY="88.0" text="Wind direction" textFill="WHITE" />
|
||||
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#3dcdc8" layoutX="110.0" layoutY="166.0" radius="35.0" stroke="#d7d7d7" strokeType="INSIDE" strokeWidth="3.0" />
|
||||
<Text fx:id="windArrowText" fill="#a8a8a8" layoutX="86.0" layoutY="186.0" strokeType="OUTSIDE" strokeWidth="0.0" text="↓">
|
||||
<Label layoutX="11.0" layoutY="41.0" text="Timer" textFill="WHITE" />
|
||||
<Label layoutX="11.0" layoutY="112.0" text="Wind direction" textFill="WHITE" />
|
||||
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#3dcdc8" layoutX="110.0" layoutY="190.0" radius="35.0" stroke="#d7d7d7" strokeType="INSIDE" strokeWidth="3.0" />
|
||||
<Text fx:id="windArrowText" fill="#a8a8a8" layoutX="86.0" layoutY="210.0" strokeType="OUTSIDE" strokeWidth="0.0" text="↓">
|
||||
<font>
|
||||
<Font name="AdobeArabic-Regular" size="55.0" />
|
||||
</font>
|
||||
@@ -35,16 +35,16 @@
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Text fx:id="windSpeedText" fill="#d3d3d3" layoutX="12.0" layoutY="213.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0 Knot" textAlignment="RIGHT">
|
||||
<Text fx:id="windSpeedText" fill="#d3d3d3" layoutX="12.0" layoutY="237.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0 Knot" textAlignment="RIGHT">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<CheckBox fx:id="toggleFps" focusTraversable="false" graphicTextGap="0.0" layoutX="21.0" layoutY="453.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="143.0" selected="true" styleClass="ui-checkbox" text="Show FPS" textFill="WHITE" />
|
||||
<VBox fx:id="positionVbox" layoutX="12.0" layoutY="280.0" prefHeight="140.0" prefWidth="200.0" styleClass="text-white" />
|
||||
<Pane layoutX="11.0" layoutY="30.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="51.0" prefWidth="193.0">
|
||||
<VBox fx:id="positionVbox" layoutX="12.0" layoutY="304.0" prefHeight="116.0" prefWidth="200.0" styleClass="text-white" />
|
||||
<Pane layoutX="11.0" layoutY="39.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="51.0" prefWidth="193.0">
|
||||
<children>
|
||||
<Text fx:id="timerLabel" fill="#f8f8f8" layoutX="-26.0" layoutY="34.0" strokeType="OUTSIDE" strokeWidth="0.0" text="00:00" textAlignment="CENTER" wrappingWidth="246.0">
|
||||
<Text fx:id="timerLabel" fill="#f8f8f8" layoutX="-26.0" layoutY="51.0" strokeType="OUTSIDE" strokeWidth="0.0" text="00:00" textAlignment="CENTER" wrappingWidth="246.0">
|
||||
<font>
|
||||
<Font size="25.0" />
|
||||
</font>
|
||||
|
||||
Reference in New Issue
Block a user