Fix budget validation; restore "keep same allocations"

This commit is contained in:
Andrew Regan
2022-01-15 22:54:13 +00:00
parent 48edb2c5d7
commit c256a7b0fb

View File

@@ -190,27 +190,31 @@ public class CivilWar {
currentResources = resources.union;
}
out.println("HOW MUCH DO YOU WISH TO SPEND FOR");
out.print("- FOOD...... ? ");
var F = terminalInput.nextInt();
if (F == 0) {
if (this.revenue.confederate != 0) {
out.println("ASSUME YOU WANT TO KEEP SAME ALLOCATIONS");
out.println();
var validInputs = false;
while (!validInputs) {
out.println("HOW MUCH DO YOU WISH TO SPEND FOR");
out.print("- FOOD...... ? ");
var food = terminalInput.nextInt();
if (food == 0) {
if (this.revenue.confederate != 0) {
out.println("ASSUME YOU WANT TO KEEP SAME ALLOCATIONS");
out.println();
}
} else {
currentResources.food = food;
}
}
currentResources.food = F;
out.print("- SALARIES.. ? ");
currentResources.salaries = terminalInput.nextInt();
out.print("- SALARIES.. ? ");
currentResources.salaries = terminalInput.nextInt();
out.print("- AMMUNITION ? ");
currentResources.ammunition = terminalInput.nextInt(); // FIXME Retry if -ve
out.print("- AMMUNITION ? ");
currentResources.ammunition = terminalInput.nextInt(); // FIXME Retry if -ve
if (currentResources.getTotal() > currentResources.budget) {
out.println("THINK AGAIN! YOU HAVE ONLY $" + currentResources.budget);
// FIXME Redo inputs from Food
if (currentResources.getTotal() > currentResources.budget) {
out.println("THINK AGAIN! YOU HAVE ONLY $" + currentResources.budget);
} else {
validInputs = true;
}
}
}