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:
Erika Savell
2017-04-17 15:41:23 +12:00
parent f25e2bac32
commit 4e78ae2ae7
2 changed files with 19 additions and 1 deletions
+12 -1
View File
@@ -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;
}
/**