-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
70 lines (58 loc) · 2.84 KB
/
Main.java
File metadata and controls
70 lines (58 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.util.Scanner;
import java.util.Random;
public class Main{
public static void main(String args[]) {
//system objects
Scanner in = new Scanner(System.in);
Random rand = new Random();
//Game Variables
String[] enemies = { "Slime", "Creeper", "Zombie", "Villager"}; //villager is for genocide route
int maxEnemyHealth = 45;
int maxAttackDamage = 10;
int health = 50;
int AttackDamage = 12;
int numHeathPots = 3;
int healthPotHealAmmount = 30;
int healthPotionDropChance = 35;
boolean running = true;
System.out.println("Welcome to TerminalCraft Legends!");
GAME:
while(running) {
System.out.println("----------------------------------------");
int enemyHealth = rand.nextInt(maxEnemyHealth);
String enemy = enemies[rand.nextInt(enemies.length)];
System.out.println("\t# " + enemy + " has appeared! #\n");
while(enemyHealth > 0) {
System.out.println("\tYour HP: " + health);
System.out.println("\t" + enemy + "'s HP: " + enemyHealth);
System.out.println("\n\tWhat Would You Like to Do?");
System.out.println("\t1. Attack");
System.out.println("\t2. Drink Health");
System.out.println("\t3. Flee");
String input = in.nextLine();
if (input.equals("1")) {
int damageDelt = rand.nextInt(AttackDamage);
int damageTaken = rand.nextInt(maxAttackDamage);
enemyHealth -= damageDelt;
health -= damageTaken;
System.out.println("\t> you strike the " + enemy + " for " + damageDelt + " damage.");
System.out.println("\t> you recive " + damageTaken + "in retaliation.");
if (health < 1) {
System.out.println("\tF in the chat for you. you died.");
break;
}
}
if (input.equals("2")) {
if(numHeathPots > 0) {
health += healthPotHealAmmount;
numHeathPots -= 1;
System.out.println("\t> You drink one health potion. healed for " + healthPotHealAmmount)
}
}
if (input.equals("3")) {
System.out.println("\t> You Fled!");
}
}
}
}
}