-
Notifications
You must be signed in to change notification settings - Fork 1
/
Fighter.java
194 lines (185 loc) · 6.27 KB
/
Fighter.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
190
191
192
193
194
/*
* The Fighter program is an extension from the Character program.
*
* @author Ben Whitten
* @version 1.0
* @since 2021-1-15
*/
//=============================================================================
public class Fighter extends Character {
//===========================================================================
// If their various abilities are ready.
public boolean isSecondWindReady = true;
public boolean isProtectionReady = true;
public boolean isActionSurgeReady = true;
//===========================================================================
/**
* Setting a bunch of various variables from Character.
*/
public Fighter() {
super();
maxHitPoints = 112; //12
currentHitPoints = 112; //12
armorClass = 13; //Chain Shirt.
// Ability Scores.
strength = 20;
dexterity = 14;
constitution = 20;
intelligence = 11;
wisdom = 13;
charisma = 10;
// Proficiencies.
proficiencies.add("Str");
proficiencies.add("Con");
proficiencies.add("Athletics");
proficiencies.add("Intimidation");
proficiencies.add("Acrobatics");
proficiencies.add("Animal Handling");
proficiencies.add("Survival");
experiencePoints = 0;
}
//===========================================================================
/**
* Printing out what the fighter can do.
*/
public String choices() {
String choices = "[1 = Run] [2 = Attack] [3 = Dodge]";
if (super.level > 1) {
choices += " [4 = Action Surge]";
}
return choices + " [N = Nothing]";
}
//===========================================================================
/**
* Changing their choice from int so string.
*/
public String makeChoice(String playerChoice) {
if (playerChoice.equals("1")) {
return "Run";
} else if (playerChoice.equals("2")) {
return "Attack";
} else if (playerChoice.equals("3")) {
super.dodge = true;
return "Dodge";
} else if (playerChoice.equals("4")) {
return "Action Surge";
} else if (playerChoice.equals("n") || playerChoice.equals("N")) {
return "Nothing";
} else {
return "Invlaid";
}
}
//===========================================================================
/**
* Bonus action options.
*/
public static String bonusActions() {
return "[1 = Second Wind] [2 = Attack] [N = Nothing]";
}
//===========================================================================
/**
* Second wind.
*/
public String secondWind(int roll) {
if (isSecondWindReady) {
isSecondWindReady = false;
currentHitPoints += roll + super.level;
if (currentHitPoints > maxHitPoints) {
currentHitPoints = maxHitPoints;
return "\u001B[32m" + name + " got their second wind! " + name
+ " returned to max health!\u001B[0m";
}
return "\u001B[32m" + name + " got their second wind! " + name
+ " regained " + (roll + super.level) + " hit points!\u001B[0m";
}
return "\u001B[31m" + name + " has already used second wind, finish a long"
+ " rest to use it again!\u001B[0m";
}
//===========================================================================
/**
* Action Surge.
*/
public String actionSurge() {
if (isActionSurgeReady) {
super.numberOfActions = 2;
isActionSurgeReady = false;
return super.name + " is going even further beyond his limits!";
} else {
return "Null";
}
}
//===========================================================================
/**
* Leveling up.
*/
public String levelUp() {
int levelsGained = 0;
// Level 2 ----------------------------------------------------------------
if (super.experiencePoints >= 300 && super.level == 1) {
levelsGained++;
}
// Level 3 ----------------------------------------------------------------
if (super.experiencePoints >= 900 && super.level == 2) {
levelsGained++;
}
// Level 4 ----------------------------------------------------------------
if (super.experiencePoints >= 2700 && super.level == 3) {
super.constitution += 2;
levelsGained++;
}
// Level 5 ----------------------------------------------------------------
if (super.experiencePoints >= 6500 && super.level == 4) {
super.proficiencyBonus++;
super.numberOfAttacks++;
levelsGained++;
}
// Level 6 ----------------------------------------------------------------
if (super.experiencePoints >= 14000 && super.level == 5) {
levelsGained++;
}
// Level 7 ----------------------------------------------------------------
if (super.experiencePoints >= 23000 && super.level == 6) {
levelsGained++;
}
// Level 8 ----------------------------------------------------------------
if (super.experiencePoints >= 34000 && super.level == 7) {
levelsGained++;
}
// Level 9 ----------------------------------------------------------------
if (super.experiencePoints >= 48000 && super.level == 8) {
super.level++;
super.proficiencyBonus++;
super.maxHitPoints += (6 + (((super.constitution - super.constitution
% 2) - 10) / 2));
levelsGained++;
}
// Level 10 ----------------------------------------------------------------
if (super.experiencePoints >= 64000 && super.level == 9) {
levelsGained++;
}
for (int count = 0; count <= levelsGained; count++) {
super.maxHitPoints += (6 + (((super.constitution - super.constitution
% 2) - 10) / 2));
super.level++;
super.constitution += 5;
super.strength += 5;
super.dexterity += 5;
super.intelligence += 2;
super.wisdom += 2;
super.charisma += 2;
}
if (levelsGained > 0) {
return super.name + " leveled up to level " + super.level + "!\n"
+ "-------------------------------------------------------"
+ "\nHp: " + super.maxHitPoints
+ "\nStr: " + super.strength
+ "\nCon: " + super.constitution
+ "\nDex: " + super.dexterity
+ "\nInt: " + super.intelligence
+ "\nWis: " + super.wisdom
+ "\nCha: " + super.charisma;
} else {
return "";
}
}
}