Added shared.model.Wind class.
shared.model.Race now uses Wind. It is wrapped in Property<>. #story[1093]
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package shared.model;
|
package shared.model;
|
||||||
|
|
||||||
import javafx.beans.property.IntegerProperty;
|
import javafx.beans.property.IntegerProperty;
|
||||||
|
import javafx.beans.property.Property;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
import network.Messages.Enums.RaceStatusEnum;
|
import network.Messages.Enums.RaceStatusEnum;
|
||||||
import network.Messages.Enums.RaceTypeEnum;
|
import network.Messages.Enums.RaceTypeEnum;
|
||||||
import network.Messages.LatestMessages;
|
import network.Messages.LatestMessages;
|
||||||
@@ -98,15 +100,9 @@ public abstract class Race implements Runnable {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current wind direction bearing.
|
* The race's wind.
|
||||||
*/
|
*/
|
||||||
protected Bearing windDirection;
|
protected Property<Wind> raceWind = new SimpleObjectProperty<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Wind speed (knots).
|
|
||||||
* Convert this to millimeters per second before passing to RaceStatus.
|
|
||||||
*/
|
|
||||||
protected double windSpeed;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,11 +165,9 @@ public abstract class Race implements Runnable {
|
|||||||
//Race type.
|
//Race type.
|
||||||
this.raceType = raceDataSource.getRaceType();
|
this.raceType = raceDataSource.getRaceType();
|
||||||
|
|
||||||
//Wind speed.
|
//Wind.
|
||||||
this.windSpeed = 0;
|
Wind wind = new Wind(Bearing.fromDegrees(0), 0);
|
||||||
//Wind direction.
|
this.raceWind.setValue(wind);
|
||||||
this.windDirection = Bearing.fromDegrees(0);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +253,7 @@ public abstract class Race implements Runnable {
|
|||||||
* @return The wind bearing.
|
* @return The wind bearing.
|
||||||
*/
|
*/
|
||||||
public Bearing getWindDirection() {
|
public Bearing getWindDirection() {
|
||||||
return windDirection;
|
return raceWind.getValue().getWindDirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,7 +262,15 @@ public abstract class Race implements Runnable {
|
|||||||
* @return The wind speed.
|
* @return The wind speed.
|
||||||
*/
|
*/
|
||||||
public double getWindSpeed() {
|
public double getWindSpeed() {
|
||||||
return windSpeed;
|
return raceWind.getValue().getWindSpeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the race's wind.
|
||||||
|
* @return The race's wind.
|
||||||
|
*/
|
||||||
|
public Property<Wind> windProperty() {
|
||||||
|
return raceWind;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package shared.model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class encapsulates the wind during a race.
|
||||||
|
* It has speed and a bearing.
|
||||||
|
* This is intended to be immutable.
|
||||||
|
*/
|
||||||
|
public class Wind {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current wind direction bearing.
|
||||||
|
*/
|
||||||
|
private Bearing windDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wind speed (knots).
|
||||||
|
* Convert this to millimeters per second before passing to RaceStatus.
|
||||||
|
*/
|
||||||
|
private double windSpeed;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new wind object, with a given direction and speed, in knots.
|
||||||
|
* @param windDirection The direction of the wind.
|
||||||
|
* @param windSpeed The speed of the wind, in knots.
|
||||||
|
*/
|
||||||
|
public Wind(Bearing windDirection, double windSpeed) {
|
||||||
|
this.windDirection = windDirection;
|
||||||
|
this.windSpeed = windSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the race wind's bearing.
|
||||||
|
* @return The race wind's bearing.
|
||||||
|
*/
|
||||||
|
public Bearing getWindDirection() {
|
||||||
|
return windDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the race wind's speed, in knots.
|
||||||
|
* @return The race wind's speed, in knots.
|
||||||
|
*/
|
||||||
|
public double getWindSpeed() {
|
||||||
|
return windSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user