+ (fix) : fixed bugs related to changing location.
This commit is contained in:
@@ -121,7 +121,7 @@ public class Main {
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
currentLocation = moveToLocation(scanner, currentLocation);
|
||||
currentLocation = moveToLocation(scanner, currentLocation, player);
|
||||
if (!currentLocation.hasEnemy()) {
|
||||
spawnRandomEnemy(currentLocation, random);
|
||||
}
|
||||
@@ -190,16 +190,19 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private static Location moveToLocation(Scanner scanner, Location current) {
|
||||
System.out.println("Choose a location to move to:");
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
String prefix = locations.get(i).equals(current) ? " * " : " ";
|
||||
System.out.println(BLUE + " " + (i + 1) + "." + RESET + " " + prefix + locations.get(i).getName());
|
||||
}
|
||||
|
||||
int choice;
|
||||
private static Location moveToLocation(Scanner scanner, Location current, Player player) {
|
||||
int choice = -1;
|
||||
do {
|
||||
System.out.println("Choose a location to move to:");
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
String prefix = locations.get(i).equals(current) ? " * " : " ";
|
||||
System.out.println(BLUE + " " + (i + 1) + "." + RESET + " " + prefix + locations.get(i).getName());
|
||||
}
|
||||
choice = scanner.nextInt() - 1;
|
||||
if (choice == 3 && !player.hasAllKeys()){
|
||||
System.out.println("Locked!");
|
||||
choice = -1;
|
||||
}
|
||||
} while (choice < 0 || choice >= locations.size());
|
||||
|
||||
return locations.get(choice);
|
||||
|
||||
Reference in New Issue
Block a user