Fixed testing problem where race tests would sometimes fail because a boat did not finish
- Added an option to set the dnf chance, then set it to 0 is all tests #story[760]
This commit is contained in:
@@ -24,6 +24,7 @@ public abstract class Race implements Runnable {
|
||||
protected RaceController controller;
|
||||
protected int boatsFinished = 0;
|
||||
protected long totalTimeElapsed;
|
||||
private int dnfChance = 1; //%percentage chance a boat fails at each checkpoint
|
||||
|
||||
private int lastFPS = 20;
|
||||
|
||||
@@ -54,6 +55,16 @@ public abstract class Race implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the chance each boat has of failing at a gate or marker
|
||||
* @param chance percentage chance a boat has of failing per checkpoint.
|
||||
*/
|
||||
protected void setDnfChance(int chance) {
|
||||
if (chance >= 0 && chance <= 100) {
|
||||
dnfChance = chance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void initialiseBoats() {
|
||||
|
||||
@@ -174,7 +185,7 @@ public abstract class Race implements Runnable {
|
||||
|
||||
private boolean doNotFinish() {
|
||||
Random rand = new Random();
|
||||
return rand.nextInt(4) < 1;
|
||||
return rand.nextInt(100) < dnfChance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user