This commit is contained in:
250406
2026-05-18 11:29:09 +01:00
parent 0fdbfdd81c
commit 7e0b0a808a

View File

@@ -16,52 +16,37 @@ import java.util.Random;
* @author 250406 * @author 250406
*/ */
public class Experientia { public class Experientia {
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
Random rand = new Random(); Random rand = new Random();
String nomeJogador; String nomeJogador;
String classe; String classe;
int nivelJogador = 1; int nivelJogador = 1;
int xpJogador = 0; int xpJogador = 0;
int ouro = 0; int ouro = 0;
int vidaMax = 100; int vidaMax = 100;
int vidaAtual = 100; int vidaAtual = 100;
int ataqueBase = 10; int ataqueBase = 10;
int defesaBase = 5; int defesaBase = 5;
int bonusAtaque = 0; int bonusAtaque = 0;
int bonusDefesa = 0; int bonusDefesa = 0;
int pontosStatus = 0; int pontosStatus = 0;
int refreshLojaRestantes = 3; // limite de refresh por luta int refreshLojaRestantes = 3; // limite de refresh por luta
Item[] inventario = new Item[20]; Item[] inventario = new Item[20];
int itensCount = 0; int itensCount = 0;
Item[] loja = new Item[3]; Item[] loja = new Item[3];
String password; String password;
boolean loggedIn = false; boolean loggedIn = false;
boolean bossFinalDerrotado = false; boolean bossFinalDerrotado = false;
boolean admin = false; boolean admin = false;
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
new Experientia().iniciar(); new Experientia().iniciar();
} }
public void iniciar() throws IOException { public void iniciar() throws IOException {
System.out.println("===== LOGIN ====="); System.out.println("===== LOGIN =====");
System.out.println("1-Novo jogo"); System.out.println("1-Novo jogo");
System.out.println("2-Carregar jogo"); System.out.println("2-Carregar jogo");
System.out.println("3-Login Admin"); System.out.println("3-Login Admin");
int op = scanner.nextInt(); int op = scanner.nextInt();
if (op == 1) { if (op == 1) {
criarPersonagem(); criarPersonagem();
} else if (op == 2) { } else if (op == 2) {
@@ -69,48 +54,31 @@ public class Experientia {
} else if (op == 3) { } else if (op == 3) {
loginAdmin(); loginAdmin();
} }
menu(); menu();
} }
public void criarPersonagem() { public void criarPersonagem() {
System.out.print("Nome: "); System.out.print("Nome: ");
nomeJogador = scanner.next(); nomeJogador = scanner.next();
if (nomeJogador.equalsIgnoreCase("Tralalero")) { if (nomeJogador.equalsIgnoreCase("Tralalero")) {
admin = true; admin = true;
System.out.println("MODO SECRETO ATIVADO"); System.out.println("MODO SECRETO ATIVADO");
nivelJogador = 100; nivelJogador = 100;
xpJogador = 0; xpJogador = 0;
ouro = 999999; ouro = 999999;
vidaMax = 9999; vidaMax = 9999;
vidaAtual = vidaMax; vidaAtual = vidaMax;
ataqueBase = 999; ataqueBase = 999;
defesaBase = 999; defesaBase = 999;
bonusAtaque = 999; bonusAtaque = 999;
bonusDefesa = 999; bonusDefesa = 999;
pontosStatus = 999; pontosStatus = 999;
itensCount = 0; itensCount = 0;
inventario = new Item[50]; inventario = new Item[50];
return; return;
} }
System.out.println("Classe:"); System.out.println("Classe:");
System.out.println("1-Guerreiro 2-Mago 3-Ladrão 4-Paladino 5-Assassino 6-Arqueiro"); System.out.println("1-Guerreiro 2-Mago 3-Ladrão 4-Paladino 5-Assassino 6-Arqueiro");
int c = scanner.nextInt(); int c = scanner.nextInt();
switch (c) { switch (c) {
case 1 -> { case 1 -> {
classe = "Guerreiro"; classe = "Guerreiro";
@@ -772,38 +740,25 @@ public class Experientia {
} }
public void carregarJogo() { public void carregarJogo() {
System.out.print("Nome do jogador: "); System.out.print("Nome do jogador: ");
String nome = scanner.next(); String nome = scanner.next();
try (BufferedReader br = new BufferedReader(new FileReader(nome + ".txt"))) { try (BufferedReader br = new BufferedReader(new FileReader(nome + ".txt"))) {
nomeJogador = br.readLine(); nomeJogador = br.readLine();
classe = br.readLine(); classe = br.readLine();
nivelJogador = Integer.parseInt(br.readLine()); nivelJogador = Integer.parseInt(br.readLine());
xpJogador = Integer.parseInt(br.readLine()); xpJogador = Integer.parseInt(br.readLine());
ouro = Integer.parseInt(br.readLine()); ouro = Integer.parseInt(br.readLine());
vidaMax = Integer.parseInt(br.readLine()); vidaMax = Integer.parseInt(br.readLine());
vidaAtual = Integer.parseInt(br.readLine()); vidaAtual = Integer.parseInt(br.readLine());
ataqueBase = Integer.parseInt(br.readLine()); ataqueBase = Integer.parseInt(br.readLine());
defesaBase = Integer.parseInt(br.readLine()); defesaBase = Integer.parseInt(br.readLine());
bonusAtaque = Integer.parseInt(br.readLine()); bonusAtaque = Integer.parseInt(br.readLine());
bonusDefesa = Integer.parseInt(br.readLine()); bonusDefesa = Integer.parseInt(br.readLine());
pontosStatus = Integer.parseInt(br.readLine()); pontosStatus = Integer.parseInt(br.readLine());
itensCount = Integer.parseInt(br.readLine()); itensCount = Integer.parseInt(br.readLine());
inventario = new Item[50]; inventario = new Item[50];
for (int i = 0; i < itensCount; i++) { for (int i = 0; i < itensCount; i++) {
String[] parts = br.readLine().split(";"); String[] parts = br.readLine().split(";");
inventario[i] = new Item( inventario[i] = new Item(
parts[0], parts[0],
parts[1], parts[1],
@@ -812,13 +767,9 @@ public class Experientia {
parts[4] parts[4]
); );
} }
System.out.println("Jogo carregado com sucesso!"); System.out.println("Jogo carregado com sucesso!");
} catch (IOException e) { } catch (IOException e) {
System.out.println("Save não encontrado!"); System.out.println("Save não encontrado!");
try { try {
iniciar(); iniciar();
} catch (IOException ex) { } catch (IOException ex) {
@@ -826,13 +777,9 @@ public class Experientia {
} }
} }
} }
public void carregarInventarioAdmin() { public void carregarInventarioAdmin() {
itensCount = 0; itensCount = 0;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
adicionarItem(new Item( adicionarItem(new Item(
"Espada Admin " + i, "Espada Admin " + i,
"arma", "arma",
@@ -840,7 +787,6 @@ public class Experientia {
0, 0,
"ADMIN" "ADMIN"
)); ));
adicionarItem(new Item( adicionarItem(new Item(
"Armadura Admin " + i, "Armadura Admin " + i,
"armadura", "armadura",
@@ -848,7 +794,6 @@ public class Experientia {
0, 0,
"ADMIN" "ADMIN"
)); ));
adicionarItem(new Item( adicionarItem(new Item(
"Poção Admin " + i, "Poção Admin " + i,
"consumivel", "consumivel",
@@ -857,13 +802,10 @@ public class Experientia {
"ADMIN" "ADMIN"
)); ));
} }
adicionarItem(new Item("Excalibur", "arma", 500, 0, "ÚNICO")); adicionarItem(new Item("Excalibur", "arma", 500, 0, "ÚNICO"));
adicionarItem(new Item("Armadura Divina", "armadura", 500, 0, "ÚNICO")); adicionarItem(new Item("Armadura Divina", "armadura", 500, 0, "ÚNICO"));
} }
public void login() { public void login() {
System.out.println("===== LOGIN ====="); System.out.println("===== LOGIN =====");
System.out.println("1-Novo jogador"); System.out.println("1-Novo jogador");
System.out.println("2-Carregar jogo"); System.out.println("2-Carregar jogo");