BoatState message can be received from mock by visualiser
- Basic penalties have been made for out of bounds and collisions - RaceServer packages and sends BoatState messages for each boat - ServerConnection routes BoatState messages instead of dropping by default - VisualiserRaceCommandFactory produces BoatStateCommands #story[1291]
This commit is contained in:
@@ -27,7 +27,7 @@ public class MockBoat extends Boat {
|
||||
* 1: passed only first check
|
||||
* 2: passed first and second check
|
||||
*/
|
||||
private Integer roundingStatus = 0;
|
||||
private int roundingStatus = 0;
|
||||
|
||||
/**
|
||||
* Stores whether the boat is on autoVMG or not
|
||||
@@ -284,8 +284,8 @@ public class MockBoat extends Boat {
|
||||
(this.isStarboardSide(mark1) && this.isPortSide(mark2));
|
||||
}
|
||||
|
||||
public Integer getRoundingStatus() {
|
||||
return Integer.valueOf(roundingStatus);
|
||||
public int getRoundingStatus() {
|
||||
return roundingStatus;
|
||||
}
|
||||
|
||||
public void increaseRoundingStatus() {
|
||||
|
||||
@@ -377,6 +377,11 @@ public class MockRace extends RaceState {
|
||||
boat.setTimeSinceTackChange(boat.getTimeSinceTackChange() + updatePeriodMilliseconds);
|
||||
}
|
||||
|
||||
// Remove one unit of health for every frame spent outside boundary
|
||||
if(!finish && checkBearingInsideCourse(boat.getBearing(), boat.getPosition())) {
|
||||
boat.updateHealth(-1);
|
||||
}
|
||||
|
||||
this.updateEstimatedTime(boat);
|
||||
|
||||
}
|
||||
|
||||
@@ -173,12 +173,9 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
|
||||
race.updatePosition(boat, framePeriod, race.getRaceClock().getDurationMilli());
|
||||
|
||||
if(race.getColliderRegistry().rayCast(boat)){
|
||||
//System.out.println("Collision!");
|
||||
//Add boat to list
|
||||
collisionBoats.add(boat);
|
||||
}
|
||||
|
||||
//System.out.println(race.getColliderRegistry().rayCast(boat));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -71,6 +71,9 @@ public class RaceServer {
|
||||
//Parse the boat locations.
|
||||
snapshotMessages.addAll(parseBoatLocations());
|
||||
|
||||
//Parse the boat states
|
||||
snapshotMessages.addAll(parseBoatStates());
|
||||
|
||||
//Parse the marks.
|
||||
snapshotMessages.addAll(parseMarks());
|
||||
|
||||
@@ -250,7 +253,29 @@ public class RaceServer {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates BoatState messages for every boat in the race
|
||||
* @return list of BoatState messages
|
||||
*/
|
||||
private List<BoatState> parseBoatStates() {
|
||||
List<BoatState> boatStates = new ArrayList<>();
|
||||
for(MockBoat boat: race.getBoats()) {
|
||||
boatStates.add(parseIndividualBoatState(boat));
|
||||
}
|
||||
return boatStates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a BoatState message for the current state of the given boat
|
||||
* @param boat to generate message for
|
||||
* @return BoatState message
|
||||
*/
|
||||
private BoatState parseIndividualBoatState(MockBoat boat) {
|
||||
return new BoatState(
|
||||
boat.getSourceID(),
|
||||
boat.getHealth()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the race status, and returns it.
|
||||
|
||||
Reference in New Issue
Block a user