add locations
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package org.project.location;
|
||||
|
||||
import org.project.entity.enemies.Dragon;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
|
||||
public class Castle extends Location {
|
||||
public Castle() {
|
||||
super("Castle");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Enemy GetEnemy() {
|
||||
return new Dragon();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.project.location;
|
||||
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.entity.enemies.Vampire;
|
||||
|
||||
public class DarkCaves extends Location {
|
||||
public DarkCaves() {
|
||||
super("Dark Caves");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Enemy GetEnemy() {
|
||||
return new Vampire();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.project.location;
|
||||
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.entity.enemies.Skeleton;
|
||||
|
||||
public class GraveYard extends Location {
|
||||
public GraveYard() {
|
||||
super("Grave Yard");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Enemy GetEnemy() {
|
||||
return new Skeleton();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.project.location;
|
||||
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.entity.enemies.Goblin;
|
||||
|
||||
public class Jungle extends Location {
|
||||
public Jungle() {
|
||||
super("Jungle");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Enemy GetEnemy() {
|
||||
return new Goblin();
|
||||
}
|
||||
}
|
||||
@@ -3,26 +3,30 @@ package org.project.location;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class Location {
|
||||
private String name;
|
||||
public abstract class Location {
|
||||
private final String name;
|
||||
public Enemy enemy;
|
||||
|
||||
private ArrayList<Enemy> enemies;
|
||||
|
||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
||||
this.locations = locations;
|
||||
this.enemies = enemies;
|
||||
public Location(String name) {
|
||||
this.name = name;
|
||||
this.enemy = GetEnemy();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() { return name; }
|
||||
|
||||
public ArrayList<Location> getLocations() {
|
||||
return locations;
|
||||
}
|
||||
protected abstract Enemy GetEnemy();
|
||||
|
||||
public ArrayList<Enemy> getEnemies() {
|
||||
return enemies;
|
||||
public static Location RandomLocation() {
|
||||
Random random = new Random();
|
||||
int chance = random.nextInt(3);
|
||||
|
||||
return switch (chance) {
|
||||
case 0 -> new GraveYard();
|
||||
case 1 -> new DarkCaves();
|
||||
case 2 -> new Jungle();
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user