Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f1ffd2520 | ||
|
|
cd1e244201 | ||
|
|
bd81d42a3b |
@@ -0,0 +1,5 @@
|
||||
package org.project.constants.appConstants;
|
||||
|
||||
public class ConsoleColor {
|
||||
public static final String Reset = "\\u001B[0m";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.project.constants.appConstants;
|
||||
|
||||
public enum GameModes {
|
||||
SINGLE_PLAYER,
|
||||
MULTI_PLAYER_LOCAL
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.project.constants.appConstants;
|
||||
|
||||
public class TextColor extends ConsoleColor{
|
||||
public static String Black = "\\u001B[30m";
|
||||
public static String Red = "\\u001B[31m";
|
||||
public static String Green = "\\u001B[32m";
|
||||
public static String Yellow = "\\u001B[33m";
|
||||
public static String Blue = "\\u001B[34m";
|
||||
public static String Magenta = "\\u001B[35m";
|
||||
public static String Cyan = "\\u001B[36m";
|
||||
public static String White = "\\u001B[37m";
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.engine;
|
||||
|
||||
public class BattleEngine {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.project.engine;
|
||||
|
||||
import org.project.constants.appConstants.GameModes;
|
||||
|
||||
public abstract class MainEngine {
|
||||
protected MainEngine() {}
|
||||
|
||||
public abstract void run();
|
||||
|
||||
public static MainEngine CreateEngine(GameModes mode) {
|
||||
return switch (mode) {
|
||||
case GameModes.SINGLE_PLAYER -> new SinglePlayerEngine();
|
||||
case GameModes.MULTI_PLAYER_LOCAL -> new MultiplayerEngine();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.engine;
|
||||
|
||||
public class MultiPlayerBattleEngine {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.engine;
|
||||
|
||||
public class MultiplayerEngine extends MainEngine{
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.engine;
|
||||
|
||||
public class SinglePlayerBattleEngine {
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package org.project.engine;
|
||||
|
||||
import org.project.constants.appConstants.ConsoleColor;
|
||||
import org.project.constants.appConstants.TextColor;
|
||||
import org.project.constants.gameConstant.ItemClass;
|
||||
import org.project.entity.players.Assassin;
|
||||
import org.project.entity.players.Knight;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.entity.players.Wizard;
|
||||
import org.project.location.*;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class SinglePlayerEngine extends MainEngine {
|
||||
private Player player;
|
||||
|
||||
public SinglePlayerEngine() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
System.out.println(TextColor.Cyan + GetIntro() + ConsoleColor.Reset);
|
||||
System.out.println();
|
||||
|
||||
System.out.println("How should me call you, hero? ");
|
||||
String name = scanner.nextLine();
|
||||
|
||||
boolean InValidInput = false;
|
||||
do {
|
||||
System.out.println("Greetings, " + name + ". May we know your role? \n" +
|
||||
"0 > Wizard" +
|
||||
"1 > Assassin" +
|
||||
"2 > Knight");
|
||||
|
||||
int choice = scanner.nextInt();
|
||||
|
||||
switch (choice) {
|
||||
case 0 -> player = new Wizard(name);
|
||||
case 1 -> player = new Assassin(name);
|
||||
case 2 -> player = new Knight(name);
|
||||
default -> InValidInput = true;
|
||||
}
|
||||
} while (InValidInput);
|
||||
|
||||
System.out.println("Very well, " + TextColor.Cyan + GetIntro() + ConsoleColor.Reset + " your journey begins!");
|
||||
System.out.println();
|
||||
|
||||
while (true) {
|
||||
boolean canFightDragon = false;
|
||||
if (player.GetInventoryByClass(ItemClass.KEY).size() == 3) {
|
||||
canFightDragon = true;
|
||||
}
|
||||
|
||||
Location location = Location.RandomLocation();
|
||||
System.out.println(GetLocationIntro(location));
|
||||
|
||||
while (true) {
|
||||
System.out.println("What do you do, " + player.Name + "?");
|
||||
System.out.println(
|
||||
"0 > FIGHT!\n" +
|
||||
"1 > Go to the next location\n" +
|
||||
"2 > Visit the market place in the town"
|
||||
);
|
||||
if (canFightDragon) {
|
||||
System.out.println("3 > Go to the castle to face the dragon");
|
||||
}
|
||||
|
||||
int choice = scanner.nextInt();
|
||||
|
||||
switch (choice) {
|
||||
case 0 -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public String GetIntro() {
|
||||
return "For centuries, the land of Javanest lived in peace, until a magical Dragon attacked, plunging the realm into absolute darkness. With a wicked curse, the Dragon transformed the innocent people into horrific monsters: Goblins, Skeletons, and Vampires. Retreating to its impenetrable Castle, the Dragon divided the three keys to its lair and hid them among these cursed creatures. Now, it is your duty to step up and save the land. You must battle these monsters, recover the unique key from each monster type, and finally slay the Dragon to break the curse and restore peace to Javanest!";
|
||||
}
|
||||
|
||||
public String GetLocationIntro(Location location) {
|
||||
if (location instanceof Jungle) {
|
||||
return player.Name + " enters the woods, after a few steps, they see a green goblin searching for food a few steps away";
|
||||
}
|
||||
else if (location instanceof GraveYard) {
|
||||
return player.Name + " goes inside the grave ward, they cannot see a more than 10 steps ahead because of the fog in the air. After lurking through out the graves, the shadow appears... It's a skeleton!";
|
||||
}
|
||||
else if (location instanceof DarkCaves) {
|
||||
return player.Name + " dives into the darkness. As our hero was going deeper, a black smoke appears, a vampire is nearby...";
|
||||
}
|
||||
else if (location instanceof Castle) {
|
||||
return player.Name + " Goes through the gates, the dragon looks at " + player.Name + "... It knows that an epic battle awaits both it them";
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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