enhance engines

This commit is contained in:
2026-07-11 15:26:55 +03:30
parent 2e71767311
commit da218c1134
6 changed files with 418 additions and 48 deletions
@@ -1,6 +1,11 @@
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() {}
@@ -13,4 +18,36 @@ public abstract class MainEngine {
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);
}
}
}
}