54 lines
1.7 KiB
Java
54 lines
1.7 KiB
Java
package org.project.engine;
|
|
|
|
import org.project.constants.appConstants.GameModes;
|
|
import org.project.constants.gameConstant.PlayerRoles;
|
|
import org.project.constants.gameConstant.PlayerRolesExt;
|
|
import org.project.entity.players.Player;
|
|
|
|
import java.util.Scanner;
|
|
|
|
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();
|
|
};
|
|
}
|
|
|
|
protected Player RoleMenu(String name, int level) {
|
|
Scanner scanner = new Scanner(System.in);
|
|
PlayerRoles[] roles = PlayerRoles.values();
|
|
int index = 0;
|
|
while (true) {
|
|
for (PlayerRoles role : roles) {
|
|
System.out.println(index + " > " + role.name().toLowerCase());
|
|
}
|
|
int choice = scanner.nextInt();
|
|
|
|
if (choice >= 0 && choice < roles.length) {
|
|
return PlayerRolesExt.CreatePlayer(roles[choice], name, level);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected Player RoleMenu(String name) {
|
|
Scanner scanner = new Scanner(System.in);
|
|
PlayerRoles[] roles = PlayerRoles.values();
|
|
int index = 0;
|
|
while (true) {
|
|
for (PlayerRoles role : roles) {
|
|
System.out.println(index + " > " + role.name().toLowerCase());
|
|
}
|
|
int choice = scanner.nextInt();
|
|
|
|
if (choice >= 0 && choice < roles.length) {
|
|
return PlayerRolesExt.CreatePlayer(roles[choice], name);
|
|
}
|
|
}
|
|
}
|
|
}
|