develop #1

Open
farnam_jhn wants to merge 7 commits from develop into main
Showing only changes of commit 82027ac95e - Show all commits
@@ -121,7 +121,7 @@ public class Main {
} }
break; break;
case 2: case 2:
currentLocation = moveToLocation(scanner, currentLocation); currentLocation = moveToLocation(scanner, currentLocation, player);
if (!currentLocation.hasEnemy()) { if (!currentLocation.hasEnemy()) {
spawnRandomEnemy(currentLocation, random); spawnRandomEnemy(currentLocation, random);
} }
@@ -190,16 +190,19 @@ public class Main {
} }
} }
private static Location moveToLocation(Scanner scanner, Location current) { private static Location moveToLocation(Scanner scanner, Location current, Player player) {
System.out.println("Choose a location to move to:"); int choice = -1;
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;
do { 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; choice = scanner.nextInt() - 1;
if (choice == 3 && !player.hasAllKeys()){
System.out.println("Locked!");
choice = -1;
}
} while (choice < 0 || choice >= locations.size()); } while (choice < 0 || choice >= locations.size());
return locations.get(choice); return locations.get(choice);