Fixed probability of ships running away

This commit is contained in:
KahootChampion
2019-03-10 12:00:00 -06:00
parent a07d633ff9
commit 42c4534f52
3 changed files with 46 additions and 33 deletions

View File

@@ -223,7 +223,7 @@ public class ShipWarfareGUI extends Application {
}
/**
* One in two chance of running away
* One in 10 chance of running away
*
* @return true if the user is allowed to run, false if not, the "default" is false
*/
@@ -231,7 +231,7 @@ public class ShipWarfareGUI extends Application {
public boolean runFromShips() {
userAttacks = false;
Random randomValue = new Random();
int runSuccessChance = randomValue.nextInt(2) + 1;
int runSuccessChance = randomValue.nextInt(10) + 1;
if (runSuccessChance == 2) {
return true;
} else if (runSuccessChance == 1) {
@@ -459,10 +459,6 @@ public class ShipWarfareGUI extends Application {
runAwayOrLeft.setText(String.format("Cowards! %d ships ran away %s! ", howMuchRun, player.getName()));
//runAwayOrLeft.setVisible(true);
}
else{
runAwayOrLeft.setText(String.format("Escaped %d of them %s! ", howMuchRun, player.getName()));
}
} else {
report.setText((String.format("Escaped %d of them %s!", howMuchRun,player.getName())));
@@ -656,7 +652,8 @@ public class ShipWarfareGUI extends Application {
destroyPeasantShipsOrEscape();
} catch (Exception e) {
}
if (counter == 2) {
if (counter >= 2) {
title.setVisible(false);
}
@@ -685,6 +682,10 @@ public class ShipWarfareGUI extends Application {
}
if (counter>=2){
title.setVisible(false);
}