-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdventurer.java
168 lines (135 loc) · 3.54 KB
/
Adventurer.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
import java.util.Random;
public abstract class Adventurer{
private String name;
private int HP,maxHP,attackTicker, bleedCount,sleepCount;
private double attackMultiplier;
private boolean dead;
//Abstract methods are meant to be implemented in child classes.
/*
all adventurers must have a custom special
consumable resource (mana/rage/money/witts etc)
*/
//give it a short name (fewer than 13 characters)
public abstract String getSpecialName();
//accessor methods
public abstract int getSpecial();
public abstract int getSpecialMax();
public abstract void setSpecial(int n);
public abstract String getType();
//concrete method written using abstract methods.
//refill special resource by amount, but only up to at most getSpecialMax()
public int restoreSpecial(int n){
if( n > getSpecialMax() - getSpecial()){
n = getSpecialMax() - getSpecial();
}
setSpecial(getSpecial()+n);
return n;
}
/*
all adventurers must have a way to attack enemies and
support their allys
*/
//hurt or hinder the target adventurer
public abstract String attack(Adventurer other);
/*This is an example of an improvement that you can make to allow
* for more flexible targetting.
*/
//heal or buff the party
//public abstract String support(ArrayList<Adventurer> others);
//heal or buff the target adventurer
public abstract String support(Adventurer other);
//heal or buff self
public abstract String support();
//hurt or hinder the target adventurer, consume some special resource
public abstract String specialAttack(Adventurer other);
/*
standard methods
*/
public void applyDamage(int amount){
if (this.HP - amount < 0){
this.HP = 0;
}
else{
this.HP -= amount;
}
}
public boolean isDead(){
return dead;
}
//You did it wrong if this happens.
public Adventurer(){
this("Lester-the-noArg-constructor-string");
}
public Adventurer(String name){
this(name, 10);
}
public Adventurer(String name, int hp){
this.name = name;
this.HP = hp;
this.maxHP = hp;
this.attackTicker = 0;
this.attackMultiplier = (1 + (1 / 2) * getAttackTick());
this.dead = false;
}
//toString method
public String toString(){
return (this.getName());
}
//Get Methods
public String getName(){
return name;
}
public int getAttackTick() {
return attackTicker;
}
public double getAttackMultiplier() {
return attackMultiplier;
}
public int getHP(){
return HP;
}
public int getmaxHP(){
return maxHP;
}
public void setmaxHP(int newMax){
maxHP = newMax;
}
public boolean dead() {
return dead;
}
public int getBleedCount() {
return bleedCount;
}
public int getSleepCount() {
return sleepCount;
}
//Set Methods
public static String triggerBleed(Adventurer other) {
other.applyDamage(other.getBleedCount());
return other + " takes " + other.getBleedCount() + " points of persistant bleed damage.";
}
public void setBleedCount(int newBleedCount) {
this.bleedCount = newBleedCount;
}
public void setHP(int health){
this.HP = health;
}
public void setAttackTick(int newAttackTicker) {
this.attackTicker = newAttackTicker;
this.attackMultiplier = 1 + (.5 * getAttackTick());
}
public void setSleepCount(int newSleepCount) {
this.sleepCount = newSleepCount;
}
public void setName(String s){
this.name = s;
}
public void setDeathStatus(boolean a) {
this.dead = a;
}
public void killIfNecessary() {
if (getHP() == 0) {
setDeathStatus(true);
}
}
}