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 org.project.entity.enemies.Enemy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class Location {
|
public abstract class Location {
|
||||||
private String name;
|
private final String name;
|
||||||
|
public Enemy enemy;
|
||||||
|
|
||||||
private ArrayList<Enemy> enemies;
|
public Location(String name) {
|
||||||
|
this.name = name;
|
||||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
this.enemy = GetEnemy();
|
||||||
this.locations = locations;
|
|
||||||
this.enemies = enemies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() { return name; }
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Location> getLocations() {
|
protected abstract Enemy GetEnemy();
|
||||||
return locations;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Enemy> getEnemies() {
|
public static Location RandomLocation() {
|
||||||
return enemies;
|
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