-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDOT.java
More file actions
173 lines (146 loc) · 4.93 KB
/
DOT.java
File metadata and controls
173 lines (146 loc) · 4.93 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
import java.util.*;
public class DOT {
private ArrayList<DOTMatrix> players = new ArrayList<>();
private ArrayList<HOTMatrix> playersHOT = new ArrayList<>();
public void dealOutDamage(int currentRound){
//System.out.println("Dealing out DOT Damage for Round " + currentRound);
if(players.size() == 0){
//System.out.println("Array is Empty");
return;
}
for(int i=0;i<players.size();i++){
DOTMatrix currentMatrix = players.get(i);
//System.out.println(currentMatrix.toString());
if((currentRound > currentMatrix.shouldEnd())){
System.out.println(String.format("%s no longer feel the effects of %s", currentMatrix.target().getName(), Items.getDamageTypeName(currentMatrix.damageType())));
players.remove(i);
continue;
}
currentMatrix.target().Damage(currentMatrix.damage(), currentMatrix.damageType(),null);
}
}
public void addPlayer(Player target, int damage, int damageType, int rounds, int currentRound){
//System.out.println("Adding Player " + target.getName() + " to Damage Over Time");
if(target.getHealth() == 0){
return;
}
if(target.getName() == "You"){
System.out.println(String.format("%s are now under the affects of %s", target.getName(),Items.getDamageTypeName(damageType)));
} else {
System.out.println(String.format("%s is now under the affects of %s", target.getName(),Items.getDamageTypeName(damageType)));
}
if(isPlayerInForDamageType(target, damageType)){
return;
}
DOTMatrix playerDOT = new DOTMatrix(target, damage, damageType, rounds, currentRound);
//System.out.println(playerDOT.toString());
players.add(playerDOT);
return;
}
public void addHealPlayer(Player target, int heal, int rounds, int currentRound){
if(target.getHealth() <= 0){
return;
}
HOTMatrix playerHOT = new HOTMatrix(target,heal,rounds,currentRound);
playersHOT.add(playerHOT);
return;
}
public int size(){
return players.size();
}
public boolean isPlayerInForDamageType(Player player, int damageType){
if(players.size() == 0){
return false;
}
boolean isTrue = false;
for(int i=0;i<players.size();i++){
DOTMatrix cur = players.get(i);
if(cur.target().getID() == player.getID()){
if(cur.damageType() == damageType){
isTrue = true;
}
}
}
return isTrue;
}
public boolean isPlayerAlreadyHOT(Player player){
if(playersHOT.size() == 0){
return false;
}
boolean isTrue = false;
for(int i=0;i<playersHOT.size();i++){
if(player.getID() == playersHOT.get(i).target().getID()){
isTrue = true;
}
}
return isTrue;
}
public void reset(){
players.clear();
}
}
class DOTMatrix{
private Player target;
private int damage;
private int damageType;
private int roundsDOTApplies;
private int started;
DOTMatrix(Player target, int damage, int damageType, int rounds, int started){
this.target = target;
this.damage = damage;
this.damageType = damageType;
this.roundsDOTApplies = rounds;
this.started = started;
}
public Player target(){
return this.target;
}
public int damage(){
return this.damage;
}
public int damageType(){
return this.damageType;
}
public int time(){
return this.roundsDOTApplies;
}
public int started(){
return this.started;
}
public int shouldEnd(){
return this.started+this.roundsDOTApplies;
}
public String toString(){
return String.format("Target: %s, Damage: %s, DamageType %s, Time: %s, Started: %s", target.getName(), this.damage, Items.getDamageTypeName(this.damageType),this.roundsDOTApplies,this.started);
}
}
class HOTMatrix {
private Player target;
private int heal;
private int roundsDOTApplies;
private int started;
HOTMatrix(Player target, int heal, int rounds, int started){
this.target = target;
this.heal = heal;
this.roundsDOTApplies = rounds;
this.started = started;
}
public Player target(){
return this.target;
}
public int heal(){
return this.heal;
}
public int time(){
return this.roundsDOTApplies;
}
public int started(){
return this.started;
}
public int shouldEnd(){
return this.started+this.roundsDOTApplies;
}
public String toString(){
return String.format("Target: %s, heal: %s, Time: %s, Started: %s", target.getName(), this.heal, this.roundsDOTApplies, this.started);
}
}