Repository navigation
Expand file tree
/
Copy pathAssignment2.java
More file actions
179 lines (176 loc) · 6.16 KB
/
Copy pathAssignment2.java
File metadata and controls
179 lines (176 loc) · 6.16 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import java.util.Scanner;
public class Assignment2 {
public static void main(String [] args){
Scanner scanner = new Scanner(System.in);
boolean valid = true;
System.out.println("--- Welcome to Digital Monster Creation Arena ---");
System.out.println("");
System.out.print("Let's create your first monster. Give it a cool name: ");
String beast = scanner.nextLine();
int HP = 50; //Health Points
int AP = 10; // Attack Power
int DP = 5; // Defense Power
System.out.println("");
System.out.print("Now, choose your monster's element. This choice will determine its core strength.\n"
+ "[1] Fire (Attack-oriented)\n"
+ "[2] Water (Health-oriented)\n"
+ "[3] Earth (Defense-oriented)\n"
+ "Your choice (1-3): ");
int element = scanner.nextInt();
String elementname = "";
if(element == 1){
elementname = "Fire";
AP += 5;
}
else if(element == 2){
elementname = "Water";
HP += 20;
}
else if(element == 3){
elementname = "Earth";
DP += 10;
}
else{
System.out.println("ERROR: Invalid element choice. Exiting program.");
valid = false;
}
String potentialname = "";
if (valid) {
System.out.println("");
System.out.print("Every monster has a potential. Choose its potential:\n"
+ "[1] Normal (Standard stats)\n"
+ "[2] Rare (Bonus to all stats)\n"
+ "Your choice (1-2): ");
int potential = scanner.nextInt();
if(potential == 1){
potentialname = "Normal";
}
else if(potential == 2){
potentialname = "Rare";
AP += 10;
HP += 10;
DP += 10;
}
else{
System.out.println("ERROR: Invalid potential choice. Exiting program.");
valid = false;
}
}
if (valid) {
System.out.println("");
System.out.print("Finally, enter a number between 1 and 10 to influence its destiny: ");
int destiny = scanner.nextInt();
if(destiny >= 1 && destiny <= 10){
if(elementname.equals("Fire")){
AP += destiny;
}
else if(elementname.equals("Water")){
HP += destiny;
}
else if(elementname.equals("Earth")){
DP += destiny;
}
}
else{
System.out.println("ERROR: Destiny Number must be between 1 and 10. Exiting program.");
valid = false;
}
}
if (valid) {
System.out.println("");
System.out.println("Excellent choices! Your monster " + beast + " is being created...");
System.out.println("");
System.out.println("--- MONSTER PROFILE CARD ---\n"
+ "Name: " + beast + "\n"
+ "Element: " + elementname + "\n"
+ "Potential: " + potentialname + "\n"
+ "\n"
+ "Health Points (HP): " + HP + "\n"
+ "Attack Power (AP): " + AP + "\n"
+ "Defense Power (DP): " + DP + "\n"
+ "----------------------------------");
}
int initialHP = HP;
int initialAP = AP;
int initialDP = DP;
int level = 1;
int initiallevel = level;
int xpToNextLevel = level * 100;
int currentXP = 0;
int week = 1;
int daycounter = 1;
System.out.println("--- Now, let's train your new monster! ---");
System.out.println("");
System.out.print("How many days would you lke to train your monster? ");
int day = scanner.nextInt();
while (daycounter <= day) {
System.out.println("-- Training Week " + week + " --");
System.out.print("Select your training focus for this week:\n"
+ "[1] Focus on Health (Bonus HP on level-up)\n"
+ "[2] Focus on Attack (Bonus AP on level-up)\n"
+ "[3] Focus on Defense (Bonus DP on level-up)\n"
+ "Your choice: ");
int trainingFocus = scanner.nextInt();
int lastweekday = week * 7;
while (daycounter <= lastweekday && daycounter <= day) {
currentXP += 30;
System.out.println("Day " + daycounter + "... (XP +30) Total XP: " + currentXP + "/" + xpToNextLevel);
while (currentXP >= xpToNextLevel) {
level++;
System.out.println("*** LEVEL UP! Your monster is now Level " + level + "! ***");
HP = HP + 10;
AP = AP + 5;
DP = DP + 5;
if(trainingFocus == 1){
HP = HP + 5;
}
else if(trainingFocus == 2){
AP = AP + 5;
}
else if(trainingFocus == 3){
DP = DP + 5;
}
currentXP = currentXP - xpToNextLevel;
xpToNextLevel = level * 100;
}
daycounter++;
}
week++;
}
System.out.println("--- Training Results ---");
System.out.println("| Initial Stats | Final Stats");
System.out.println("| HP: " + initialHP + " | HP: " + HP);
System.out.println("| AP: " + initialAP + " | AP: " + AP);
System.out.println("| DP: " + initialDP + " | DP: " + DP);
System.out.println("| Level: " + initiallevel + " | Level: " + level);
int GuardianHP = 150;
int GuardianAP = 35;
int GuardianDP = 15;
System.out.println("--- The Guardian's Trial Begins! ---");
while(true){
int damageDealt = AP - GuardianDP;
if(damageDealt<5){
damageDealt = 5;
}
GuardianHP = GuardianHP - damageDealt;
System.out.println("Your monster attacks and deals " + damageDealt + " damage!");
System.out.println("(Guardian HP: " + GuardianHP + "/150)");
if(GuardianHP<=0){
System.out.println("VICTORY! The Guardian deems your monster worthy. The path to new adventures is now open!");
break;
}
int damageTaken = GuardianAP - DP;
if(damageTaken<5){
damageTaken = 5;
}
HP = HP - damageTaken;
System.out.println("The Stone Guardian attacks and deals " + damageTaken + " damage!");
System.out.println("(Your HP: " + HP + "/" + initialHP + ")");
if(HP<=0){
System.out.println("DEFEAT! Your monster has fallen. Return to training to prepare for the trial once more.");
break;
}
}
scanner.close();
}
}