-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStunList.java
More file actions
72 lines (59 loc) · 1.61 KB
/
StunList.java
File metadata and controls
72 lines (59 loc) · 1.61 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
import java.util.*;
public class StunList {
private ArrayList<Stun> stuns = new ArrayList<>();
public void checkStuns(){
for(int i=0;i<stuns.size();i++){
Stun stunnedPlayer = stuns.get(i);
if(stunnedPlayer.shouldEnd() >= Game.currentSubRound){
stuns.remove(i);
}
}
}
public boolean isPlayerStunned(Player player){
if(stuns.size() == 0){
return false;
}
boolean isTrue = false;
for(Stun stunned : stuns){
if(stunned.stunnedPlayer().getID() == player.getID()){
isTrue = true;
}
}
return isTrue;
}
public void reset(){
stuns.clear();
}
public void addPlayer(Player target, int roundStarted, int lasts){
stuns.add(new Stun(target, roundStarted, lasts));
}
public void removePlayer(Player player){
for(int i=0;i<stuns.size();i++){
if(stuns.get(i).stunnedPlayer().getID() == player.getID()){
stuns.remove(i);
}
}
}
}
class Stun {
private Player stunnedPlayer;
private int started;
private int lasts;
public Stun(Player stunTarget, int roundStarted, int lasts){
this.stunnedPlayer = stunTarget;
this.started = roundStarted;
this.lasts = lasts;
}
public Player stunnedPlayer(){
return this.stunnedPlayer;
}
public int started(){
return this.started;
}
public int lasts(){
return this.lasts;
}
public int shouldEnd(){
return this.started+this.lasts;
}
}