import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;
import java.util.Scanner;
public class Spiel {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Random rand = new Random();
String[] enemies = { "Skelett", "Zombie", "Riesenratte", "Goblin",
"Magier", "SchalliLP's Klon", "Riesenspinne" };
int maxEnemyHealth = 75;
int enemyAttakDamage = 25;
int Score = 0;
boolean Fail = false;
int health = 100;
int attakDamage = 50;
int numHealthPotions = 3;
int healthPotionHealAmount = 30;
int healthPotionDropChance = 50;
boolean running = true;
for (int i = 0; i < 80; i++) {
System.out.println();
}
System.out.println(" --------------------------------------------");
System.out.println(" / / |");
System.out.println("-------------------------------------------- |");
System.out.println("| DungeonFighter V1.6.2 BETA BUILD | /");
System.out.println("--------------------------------------------");
System.out.println();
System.out.println();
System.out.println(" Willkommen im Dungeon");
label1288: while (running) {
System.out.println("--------------------------------------------");
int enemyHealth = rand.nextInt(maxEnemyHealth);
int Scoremultiplier = enemyHealth;
int EnemyStartHealth = enemyHealth;
String enemy = enemies[rand.nextInt(enemies.length)];
if (enemy == "SchalliLP's Klon") {
Scoremultiplier = 100;
}
if (enemy == "SchalliLP's Klon") {
enemyHealth = 120;
}
if (enemyHealth < 5) {
enemyHealth = 5;
}
System.out.println("\t# " + enemy + " erscheint!#\n");
while (enemyHealth > 0) {
System.out.println("\tDeine HP: " + health);
System.out.println("\t" + enemy + " HP: " + enemyHealth);
System.out.println("\n\tWas willst du tun?");
System.out.println("\t1. Angreifen");
System.out.println("\t2. Heiltrank trinken");
System.out.println("\t3. Wegrennen!");
String input = in.nextLine();
if (input.equals("1")) {
int damageDealt = rand.nextInt(attakDamage);
int damageTaken = rand.nextInt(enemyAttakDamage);
if (enemy == "SchalliLP's Klon") {
damageTaken = 15;
}
enemyHealth -= damageDealt;
health -= damageTaken;
for (int i = 0; i < 80; i++) {
System.out.println();
}
System.out
.println("--------------------------------------------");
System.out.println("\t> Du triffst " + enemy
+ " und verursachst " + damageDealt + " Schaden.");
System.out.println("\t> Du kassierst " + damageTaken
+ " Schaden!");
if (health < 1) {
for (int i = 0; i < 80; i++) {
System.out.println();
}
System.out
.println("\t> Du nahmst zu viel Schaden und bist zu geschwächt um weiterzumachen!");
Fail = true;
break;
}
} else if (input.equals("2")) {
if (numHealthPotions > 0) {
health += healthPotionHealAmount;
numHealthPotions--;
for (int i = 0; i < 80; i++) {
System.out.println();
}
if (health > 100) {
health = 100;
}
System.out
.println("--------------------------------------------");
System.out
.println("\t Du trinkst einen heiltrank. Du hast "
+ healthPotionHealAmount
+ " HP dazu bekommen."
+ "\n\t> Du hast jetzt "
+ health
+ "HP."
+ "\n\t> Du hast "
+ numHealthPotions
+ " Heiltränke übrig.\n");
} else {
for (int i = 0; i < 80; i++) {
System.out.println();
}
System.out
.println("\t Du hast keine Heiltränke mehr! Besiege Gegner um welche zu finden!\n");
if (health > 100) {
health = 100;
}
}
} else {
if (input.equals("3")) {
for (int i = 0; i < 80; i++) {
System.out.println();
}
System.out.println("\t Du liefst weg vor: " + enemy
+ "!");
if (enemy == "SchalliLP's Klon") {
health -= 10;
}
if (health >= 1) {
break label1288;
}
for (int i = 0; i < 80; i++) {
System.out.println();
}
System.out
.println("\t> Du nahmst zu viel Schaden und bist zu geschwächt um weiterzumachen!");
Fail = true;
break;
}
System.out.println("\tUngültieger Befehl!");
}
}
if (health < 1) {
for (int i = 0; i < 80; i++) {
System.out.println();
}
System.out
.println("Du kriechst aus dem Dungeon, geschwächt vom kampf.");
Fail = true;
break;
}
System.out.println("--------------------------------------------");
System.out.println(" # " + enemy + " wurde besiegt! #");
System.out.println(" # Du hast " + health + " HP übrig. #");
Score += Scoremultiplier;
if (EnemyStartHealth < 30) {
if ((rand.nextInt(100) < EnemyStartHealth)
|| (enemy == "SchalliLP's Klon")) {
numHealthPotions++;
System.out.println(" # " + enemy
+ " Hat einen Heiltrank fallen gelassen! # ");
System.out.println(" # Du hast jetzt " + numHealthPotions
+ " Heiltrank(s). # ");
}
} else if (rand.nextInt(100) < healthPotionDropChance) {
numHealthPotions++;
System.out.println(" # " + enemy
+ " Hat einen Heiltrank fallen gelassen! # ");
System.out.println(" # Du hast jetzt " + numHealthPotions
+ " Heiltrank(s). # ");
}
System.out.println("--------------------------------------------");
System.out.println("Was möchtest du jetzt tun?");
System.out.println("1. Weiter kämpfen");
System.out.println("2. Dungeon verlassen");
String input = in.nextLine();
while ((!input.equals("1")) && (!input.equals("2"))) {
System.out.println("Ungültiger Befehl!");
input = in.nextLine();
}
if (input.equals("1")) {
for (int i = 0; i < 80; i++) {
System.out.println();
}
System.out.println("Du setzt dein Abenteuer fort!");
} else if (input.equals("2")) {
for (int i = 0; i < 80; i++) {
System.out.println();
}
System.out
.println("Du verlässt den Dungeon erfolgreich nach deinen Abenteuern!");
break;
}
}
for (int i = 0; i < 80; i++) {
System.out.println();
}
if (Fail) {
Score /= 2;
}
System.out.println("#######################");
System.out.println("# DANKE FÜRS SPIELEN! #");
System.out.println("#######################");
System.out.println();
System.out.println("Dein Score ist " + Score);
System.out.println("Name: ");
for (int i = 0; i < 9; i++) {
System.out.println();
}
String input = in.nextLine();
String name = input;
try {
FileWriter write = new FileWriter("text.txt", true);
PrintWriter text = new PrintWriter(write);
text.println(name + ":");
text.println(Score);
text.println();
text.flush();
write.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
for (int i = 0; i < 100; i++) {
System.out.println();
}
}
}