-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
84 lines (70 loc) · 3.06 KB
/
Game.java
File metadata and controls
84 lines (70 loc) · 3.06 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.util.Random;
import java.util.Scanner;
public class Game {
Main main = new Main();
public static void main(String[] args) {
//System Variables
Scanner in = new Scanner(System.in);
Random rand = new Random();
//game Variables
String[] enemies = {"Dave", "Richie", "Jordan", "KnightDev", "Pixelator"};
int maxhealth = 85;
int enemyattackdamage = 35;
//player Variables
int health = 500;
int attackdamage = 70;
int healthpotionsnum = 5;
int potionhealamount = 40;
int potiondropchance = 60;
String[] teammates = {"Bob", "DJ", "Narwhal", "James", "Sean", "Aerh"};
boolean running = true;
System.out.println("Welcome to the game!" + "Would you like to play y/n");
String input = in.nextLine();
if (input.equals("n")) {
System.out.println("BYE");
return;
}
if (input.equals("y")) {
//Starts while loop
while (running) {
System.out.println("----------------------------------------------------");
int enemyhealth = rand.nextInt();
String enemy = enemies[rand.nextInt(enemies.length)];
System.out.println("A while " + enemy + " Has showed up!");
label:
while (maxhealth > 0) {
System.out.println("Your HP: " + health);
System.out.println("Enemy Max Health: " + maxhealth);
System.out.println("What would you like to do?");
System.out.println("1. Run away");
System.out.println("2. Fight the enemy");
System.out.println("3. Call backup");
String inp = in.nextLine();
switch (inp) {
case "1":
System.out.println("You ran away like a pussy!");
System.out.println("THE END");
break label;
case "2":
int damageGiven = rand.nextInt(attackdamage);
int damageTaken = rand.nextInt(enemyattackdamage);
maxhealth -= damageGiven;
health -= damageTaken;
System.out.println("You damaged " + enemy + " for " + damageGiven + " HP");
System.out.println("However you took " + damageTaken + " HP");
break;
case "3":
String teammate = teammates[rand.nextInt(teammates.length)];
System.out.println("You have called for back up and your teammate " + teammate);
break;
}
}
break;
}
}
}
}
/* DO TO LIST:
Add more to game
make more stuff to do and make it more complex/fun.
*/