This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void delay(int milliseconds){ | |
try{ | |
Thread.sleep(milliseconds); | |
}catch (InterruptedException e) { | |
Thread.currentThread().interrupt(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Função para limpar o console e reposicionar o cursor | |
public static void clearConsole() { | |
System.out.print("\033[H\033[2J"); | |
System.out.flush(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int atacar() { | |
Random rand = new Random(); | |
int min = getForca() / 2; | |
int max = getForca() + getDefesa(); | |
int dano = rand.nextInt(max - min + 1) + min; | |
System.out.println(getNome() + " atacou com sua espada e causou " + dano + " de dano!"); | |
return dano; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gerador de monstros aleatorios | |
public static Monstro gerarMonstroAleatorio() { | |
Random rand = new Random(); | |
String[] nomes = { "Esqueleto", "Orc", "Troll", "Goblin", "Dragão" }; | |
int vida = rand.nextInt(100) + 100; // Vida do Monstro | |
int ataque = rand.nextInt(20) + 20; // Ataque do Monstro | |
int defesa = rand.nextInt(20) + 20; // Defesa do Monstro | |
return new Monstro(nomes[rand.nextInt(nomes.length)], vida, ataque, defesa); | |
} |