/
Warrior.java
189 lines (170 loc) · 4.82 KB
/
Warrior.java
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
180
181
182
183
184
185
186
187
188
189
import cs1.Keyboard;
public class Warrior extends Character{
public Warrior(String n){
name = n;
hp = 60;
spmp = 30;
tp = 45;
str = 0;
end = 0;
intl = 0;
spd = 0;
luck = 0;
}
public void autoSkills(){
hp = 100;
spmp = 50;
tp = 50;
str = 9;
end = 7;
intl = 2;
spd = 2;
luck = 5;
}
public void fullHeal(){
hp = 100;
}
public void attack(Monster m){
double dmg;
double hpinc;
dmg = (.8 + Math.random() * .2)*((str * .6) + (spd * .2) + (luck * .04)) - enemydef(m);
System.out.println("Your towering strength deals " + (int)dmg + " Damage\n");
m.lowerHp((int)dmg);
if (Math.random() * 10 <= 2){
hpinc = (1 + Math.random()) * 2;
System.out.println("Your overbearing strength heals your wounds");
incHp((int)hpinc);
}
}
public void DisplayHealth(Monster m){
System.out.println(name + "'s HP: " + hp + "\t" + name + "'s Sp/Mp: " + spmp + "\t\t\t Enemy's HP: " + m.getHp());
}
public void BluntBash(Monster m){
if(spmp < 25){
System.out.println("You don't have enough Sp/Mp and the skill fizzles!");
}
else{
double dmg;
this.lowerspmp(25);
dmg = (.9 + Math.random() * 1.2)*((str * .1) + (spd * .1) + (luck * .04)) - enemydef(m);
m.lowerHp((int)dmg);
System.out.println("Your Blunt Bash does " + (int)dmg + " Damage\n");
if (Math.random() * 100 < 60){
m.statusChange("Stunned");
System.out.println("Your Blunt Bash stuns your foe!");
}
}
}
public void PreciseStrike(Monster m){
if(spmp < 20){
System.out.println("You don't have enough Sp/Mp and the skill fizzles!");
}
else{
double dmg;
this.lowerspmp(20);
dmg = (.9 + Math.random() * 1.2)*((str * .5) + (spd * .1) + (luck * .04)) - enemydef(m);
m.lowerHp((int)dmg);
System.out.println("Your Precise Strike does " + (int)dmg + " Damage\n");
if (Math.random() * 100 < 80){
m.statusChange("Bleeding");
System.out.println("Your Precise strike causes your foe to bleed!");
}
}
}
public void Charge(Monster m){
if(spmp < 15){
System.out.println("You don't have enough Sp/Mp and the skill fizzles!");
}
else{
double dmg;
this.lowerspmp(15);
dmg = (.9 + Math.random() * 1.2)*((str * .7) + (spd * .2) + (luck * .04)) - enemydef(m);
m.lowerHp((int)dmg);
System.out.println("Your Charge does " + (int)dmg + " Damage\n");
}
}
public void SkillsDisplay(Monster m){
System.out.println("1 - Charge: Costs 15 SpMp, This is a powerful charge and hit against your enemy!");
System.out.println("2 - Blunt Bash: Costs 25 SpMp, This ability has a chance to stun your enemy!");
System.out.println("3 - Precise Strike: Costs 20 SpMp, This ability has a chance to make your opponent bleed!");
System.out.println("4 - Go Back");
String input = Keyboard.readString();
if (input.equals("1")){
Charge(m);
}
else if (input.equals("2")){
BluntBash(m);
}
else if (input.equals("3")){
PreciseStrike(m);
}
else if (input.equals("4")){
action(m);
}
else{
System.out.println("Invalid input");
SkillsDisplay(m);
}
}
public void action(Monster m){
System.out.println("1 - Basic Attack");
System.out.println("2 - Use a Skill");
System.out.println("3 - Use an Item");
System.out.println("4 - Run away");
String input = Keyboard.readString();
if (input.equals("1")){
System.out.println("Your majestic blade bathes in crimson as you dig the blade into your foe");
attack(m);
}
else if (input.equals("2")){
SkillsDisplay(m);
}
else if (input.equals("3")){
System.out.println("Under development. Please understand fam");
action(m);
}
else if (input.equals("4")){
System.out.println("Under development. Please understand fam");
action(m);
}
else{
System.out.println("Invalid input");
action(m);
}
}
public void enemyaction(Monster m){
m.action(this);
}
public void Afterbattle(Monster m){
if (!(isAlive() || m.isAlive())){
System.out.println("Your foe perishes before you, but not before claiming your life for themselves. You are dead. At least you tried");
}
else if (!(isAlive())){
System.out.println("Your strength fails you. You're dead.");
}
else if(!(m.isAlive())){
System.out.println("You emerge victorious! Nice kill.");
}
}
public void battle(Monster m){
System.out.println("The Battle Begins\n\n");
while (isAlive() && m.isAlive()){
DisplayHealth(m);
System.out.println("What do you do?");
action(m);
enemyaction(m);
}
Afterbattle(m);
};
public String toString(){
return name + " is a powerful Warrior with these stats:" +
"\nHp = " + hp +
"\nSp = " + spmp +
"\nTp = " + tp +
"\nStrength = " + str +
"\nEndurance = " + end +
"\nInteligence = " + intl +
"\nSpeed = " + spd +
"\nLuck = " + luck;
}
}