Started implementing the gameState broadcasts.

Initial xml files are almost broad casted, just need to create them (or import the for the regatta). Started the setup for sending boat location packets, should work once we get at least the boat xml working when being sent.

#story[1047]
This commit is contained in:
Kusal Ekanayake
2017-07-21 13:16:43 +12:00
parent 2fff73c075
commit 5df7efda03
9 changed files with 73 additions and 25 deletions
@@ -1,11 +1,9 @@
package seng302.gameServer;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import seng302.models.Player;
import java.util.ArrayList;
import seng302.models.Yacht;
import seng302.server.messages.BoatActionType;
@@ -30,6 +28,7 @@ public class GameState {
players = new ArrayList<>();
currentStage = GameStages.LOBBYING;
isRaceStarted = false;
yachts = new HashMap<>();
//set this when game stage changes to prerace
previousUpdateTime = System.currentTimeMillis();
}
@@ -74,6 +73,10 @@ public class GameState {
return windSpeed;
}
public static Map<Integer, Yacht> getYachts() {
return yachts;
}
public static void updateBoat(Integer sourceId, BoatActionType actionType) {
switch (actionType) {
case VMG:
@@ -92,6 +95,7 @@ public class GameState {
}
public static void update() {
Long timeInterval = System.currentTimeMillis() - previousUpdateTime;
previousUpdateTime = System.currentTimeMillis();
for (Yacht yacht : yachts.values()) {