# Conflicts: # racevisionGame/src/main/java/mock/model/MockRace.java # racevisionGame/src/main/java/mock/model/RaceState.javamain
commit
9249e74e3a
@ -1,18 +1,4 @@
|
|||||||
package mock.model;
|
package mock.model;
|
||||||
|
|
||||||
import javafx.beans.property.IntegerProperty;
|
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
|
||||||
import network.Messages.Enums.RaceStatusEnum;
|
|
||||||
import network.Messages.Enums.RaceTypeEnum;
|
|
||||||
import network.Messages.LatestMessages;
|
|
||||||
import shared.dataInput.BoatDataSource;
|
|
||||||
import shared.dataInput.RaceDataSource;
|
|
||||||
import shared.dataInput.RegattaDataSource;
|
|
||||||
import shared.model.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class RaceState {
|
public class RaceState {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,92 @@
|
|||||||
|
package mock.model;
|
||||||
|
|
||||||
|
import shared.model.Bearing;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class Wind {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to generate random numbers when changing the wind direction.
|
||||||
|
*/
|
||||||
|
private int changeWind = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bearing the wind direction starts at.
|
||||||
|
*/
|
||||||
|
private Bearing windBearing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The lower bearing angle that the wind may have.
|
||||||
|
*/
|
||||||
|
private Bearing windLowerBound;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The upper bearing angle that the wind may have.
|
||||||
|
*/
|
||||||
|
private Bearing windUpperBound;
|
||||||
|
|
||||||
|
double windSpeed;
|
||||||
|
|
||||||
|
public Wind() {
|
||||||
|
this.windBearing = Bearing.fromDegrees(225);
|
||||||
|
this.windSpeed = 12;
|
||||||
|
this.windLowerBound = Bearing.fromDegrees(215);
|
||||||
|
this.windUpperBound = Bearing.fromDegrees(235);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Wind(Bearing windBearing, double windSpeed, Bearing windLowerBound, Bearing windUpperBound) {
|
||||||
|
this.windBearing = windBearing;
|
||||||
|
this.windSpeed = windSpeed;
|
||||||
|
this.windLowerBound = windLowerBound;
|
||||||
|
this.windUpperBound = windUpperBound;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the wind direction randomly, while keeping it within [windLowerBound, windUpperBound].
|
||||||
|
*/
|
||||||
|
public void changeWindDirection() {
|
||||||
|
|
||||||
|
//Randomly add or remove 0.5 degrees.
|
||||||
|
int r = new Random().nextInt(changeWind) + 1;
|
||||||
|
|
||||||
|
if (r == 1) {
|
||||||
|
//Add 0.5 degrees to the wind bearing.
|
||||||
|
this.windBearing.setDegrees(this.windBearing.degrees() + 0.5);
|
||||||
|
|
||||||
|
} else if (r == 2) {
|
||||||
|
//Minus 0.5 degrees from the wind bearing.
|
||||||
|
this.windBearing.setDegrees(this.windBearing.degrees() - 0.5);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ensure that the wind is in the correct bounds.
|
||||||
|
if (this.windBearing.degrees() > this.windUpperBound.degrees()) {
|
||||||
|
this.windBearing.setBearing(this.windUpperBound);
|
||||||
|
|
||||||
|
} else if (this.windBearing.degrees() < this.windLowerBound.degrees()) {
|
||||||
|
this.windBearing.setBearing(this.windLowerBound);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bearing getWindDirection() {
|
||||||
|
return this.windBearing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getWindSpeed() {
|
||||||
|
return this.windSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWindDirection(Bearing windBearing) {
|
||||||
|
this.windBearing = windBearing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWindSpeed(double windSpeed) {
|
||||||
|
this.windSpeed = windSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDegrees(double degrees) {
|
||||||
|
this.windBearing.setDegrees(degrees);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue