package org.project.location; import org.project.entity.enemies.*; import java.util.ArrayList; import java.util.Random; public class LocationManager { private ArrayList locations; private Location currentLocation; private Random random; public LocationManager() { locations = new ArrayList<>(); random = new Random(); createLocations(); } private void createLocations() { //Creating different game locations Location forest = new Location("Dark Forest", "A mysterious forest filled with dangerous creatures"); forest.addEnemy(new Goblin()); forest.addEnemy(new Skeleton()); Location crypt = new Location("Ancient Crypt", "An old crypt where skeletons roam"); crypt.addEnemy(new Skeleton()); crypt.addEnemy(new Vampire()); Location castleGate = new Location("Castle Gate", "The entrance to the Dragon's castle"); castleGate.addEnemy(new Goblin()); castleGate.addEnemy(new Vampire()); locations.add(forest); locations.add(crypt); locations.add(castleGate); } public void moveToRandomLocation() { int index = random.nextInt(locations.size()); currentLocation = locations.get(index); currentLocation.spawnRandomEnemy(); } public void moveToLocation(int index) { if (index >= 0 && index < locations.size()) { currentLocation = locations.get(index); currentLocation.spawnRandomEnemy(); } } public Location getCurrentLocation() { return currentLocation; } public void displayLocations() { NarrativeConsole.printInfo("\n=== Available Locations ==="); for (int i = 0; i < locations.size(); i++) { NarrativeConsole.printInfo((i + 1) + ". " + locations.get(i).getName()); NarrativeConsole.printInfo(" " + locations.get(i).getDescription()); } } public ArrayList getLocations() { return locations; } }