mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge remote-tracking branch 'origin/1124_broadcast_mark_rounding_message' into 1124_broadcast_mark_rounding_message
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.gameServer.server.messages.BoatAction;
|
||||
import seng302.gameServer.server.messages.BoatStatus;
|
||||
import seng302.gameServer.server.messages.MarkRoundingMessage;
|
||||
import seng302.gameServer.server.messages.MarkType;
|
||||
import seng302.gameServer.server.messages.Message;
|
||||
@@ -306,7 +307,7 @@ public class GameState implements Runnable {
|
||||
|
||||
if (hasProgressed) {
|
||||
sendMarkRoundingMessage(yacht);
|
||||
// logMarkRounding(yacht);
|
||||
logMarkRounding(yacht);
|
||||
yacht.setHasPassedLine(false);
|
||||
yacht.setHasEnteredRoundingZone(false);
|
||||
yacht.setHasPassedThroughGate(false);
|
||||
@@ -336,6 +337,7 @@ public class GameState implements Runnable {
|
||||
Boolean isClockwiseCross = GeoUtility.isClockwise(mark1, mark2, nextMark.getMidPoint());
|
||||
if (crossedLine == 2 && isClockwiseCross || crossedLine == 1 && !isClockwiseCross) {
|
||||
yacht.setClosestCurrentMark(mark1);
|
||||
yacht.setBoatStatus(BoatStatus.RACING);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -439,7 +441,7 @@ public class GameState implements Runnable {
|
||||
if (crossedLine == 1 && isClockwiseCross || crossedLine == 2 && !isClockwiseCross) {
|
||||
yacht.setClosestCurrentMark(mark1);
|
||||
yacht.setIsFinished(true);
|
||||
logger.debug(yacht.getSourceId() + " finished");
|
||||
yacht.setBoatStatus(BoatStatus.FINISHED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -467,20 +469,8 @@ public class GameState implements Runnable {
|
||||
|
||||
private void logMarkRounding(ServerYacht yacht) {
|
||||
Mark roundingMark = yacht.getClosestCurrentMark();
|
||||
|
||||
logger.debug(
|
||||
String.format("Sending Mark Rounding Message:\n"
|
||||
+ "AckNumber %d\n"
|
||||
+ "RaceID %d\n"
|
||||
+ "BoatSourceID %d\n"
|
||||
+ "BoatStatus %s\n"
|
||||
+ "Rounding Side %s\n"
|
||||
+ "MarkSeqID %d",
|
||||
0,
|
||||
0,
|
||||
yacht.getSourceId(),
|
||||
RoundingBoatStatus.RACING.name(),
|
||||
roundingMark.getRoundingSide().getName(),
|
||||
String.format("Yacht srcID(%d) passed Mark srcID(%d)", yacht.getSourceId(),
|
||||
roundingMark.getSourceID()));
|
||||
}
|
||||
|
||||
|
||||
@@ -321,22 +321,13 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
// variables taken from GameServerThread
|
||||
|
||||
List<BoatSubMessage> boatSubMessages = new ArrayList<>();
|
||||
BoatStatus boatStatus;
|
||||
RaceStatus raceStatus;
|
||||
|
||||
for (Player player : GameState.getPlayers()) {
|
||||
ServerYacht y = player.getYacht();
|
||||
|
||||
if (GameState.getCurrentStage() == GameStages.PRE_RACE) {
|
||||
boatStatus = BoatStatus.PRESTART;
|
||||
} else if (GameState.getCurrentStage() == GameStages.RACING) {
|
||||
boatStatus = BoatStatus.RACING;
|
||||
} else {
|
||||
boatStatus = BoatStatus.UNDEFINED;
|
||||
}
|
||||
|
||||
BoatSubMessage m = new BoatSubMessage(y.getSourceId(), boatStatus, 0, 0, 0, 1234l,
|
||||
1234l);
|
||||
BoatSubMessage m = new BoatSubMessage(y.getSourceId(), y.getBoatStatus(), 0,
|
||||
0, 0, 1234L,
|
||||
1234L);
|
||||
boatSubMessages.add(m);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Observer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.gameServer.GameState;
|
||||
import seng302.gameServer.server.messages.BoatStatus;
|
||||
import seng302.model.mark.Mark;
|
||||
import seng302.utilities.GeoUtility;
|
||||
|
||||
@@ -20,23 +21,28 @@ public class ServerYacht extends Observable {
|
||||
|
||||
public static final Double TURN_STEP = 5.0;
|
||||
|
||||
//Boat info
|
||||
private String boatType;
|
||||
private Integer sourceId;
|
||||
private String hullID; //matches HullNum in the XML spec.
|
||||
private String shortName;
|
||||
private String boatName;
|
||||
private String country;
|
||||
private BoatStatus boatStatus;
|
||||
|
||||
|
||||
//Location
|
||||
private Double lastHeading;
|
||||
private Boolean sailIn;
|
||||
private Double heading;
|
||||
private GeoPoint lastLocation;
|
||||
private GeoPoint location;
|
||||
private Double currentVelocity;
|
||||
private Boolean isAuto;
|
||||
private Double autoHeading;
|
||||
|
||||
//Mark Rounding
|
||||
private Integer currentMarkSeqID = 0;
|
||||
private GeoPoint lastLocation;
|
||||
private Boolean hasEnteredRoundingZone;
|
||||
private Mark closestCurrentMark;
|
||||
private Boolean hasPassedLine;
|
||||
@@ -47,6 +53,7 @@ public class ServerYacht extends Observable {
|
||||
public ServerYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
||||
String boatName, String country) {
|
||||
this.boatType = boatType;
|
||||
this.boatStatus = BoatStatus.PRESTART;
|
||||
this.sourceId = sourceId;
|
||||
this.hullID = hullID;
|
||||
this.shortName = shortName;
|
||||
@@ -356,6 +363,14 @@ public class ServerYacht extends Observable {
|
||||
this.hasPassedThroughGate = hasPassedThroughGate;
|
||||
}
|
||||
|
||||
public BoatStatus getBoatStatus() {
|
||||
return boatStatus;
|
||||
}
|
||||
|
||||
public void setBoatStatus(BoatStatus boatStatus) {
|
||||
this.boatStatus = boatStatus;
|
||||
}
|
||||
|
||||
public void incrementMarkSeqID() {
|
||||
currentMarkSeqID++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user