-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCastSpellList.java
More file actions
85 lines (73 loc) · 2.63 KB
/
CastSpellList.java
File metadata and controls
85 lines (73 loc) · 2.63 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
import java.util.*;
public class CastSpellList {
private ArrayList<SpellCast> casters = new ArrayList<>();
public void castMultiTurnSpell(Player player, Player target, int curRound, int lasts){
if(!player.getType().getName().equals("Mage")){
return;
}
casters.add(new SpellCast(player, target, curRound, lasts));
}
public void castMultiTurnSpell(Player player, int curRound, int lasts){
if(!player.getType().getName().equals("Mage")){
return;
}
casters.add(new SpellCast(player, curRound, lasts));
}
public void castSpells(){
for(int i=0;i<casters.size();i++){
SpellCast spellCasts = casters.get(i);
if(spellCasts.playerCasting().getMana() < spellCasts.playerCasting().getSpell().castCost()){
casters.remove(i);
System.out.println(String.format("%s ran out of mana while casting %s", spellCasts.playerCasting().getName(), spellCasts.playerCasting().getSpell().castCost()));
}
//System.out.println(spellCasts.started() + spellCasts.turns() + ", " + Game.currentSubRound);
if(spellCasts.started()+spellCasts.turns() <= Game.currentSubRound){
Staff hand = (Staff)spellCasts.playerCasting().getHand();
hand.useItem(spellCasts.playerCasting(), spellCasts.spellTarget(),false);
casters.remove(i);
} else {
spellCasts.playerCasting().removeMana(spellCasts.playerCasting().getSpell().castCost());
}
}
}
public boolean isPlayerCastingSpell(Player player){
boolean isTrue = false;
for(int i=0;i<casters.size();i++){
SpellCast cast = casters.get(i);
if(cast.playerCasting().getID() == player.getID()){
isTrue = true;
}
}
return isTrue;
}
}
class SpellCast {
private Player caster;
private Player target;
private int started;
private int turns;
public SpellCast(Player caster, Player target, int curRound, int turns){
this.caster = caster;
this.target = target;
this.started = curRound;
this.turns = turns;
}
public SpellCast(Player caster, int curRound, int turns){
this.caster = caster;
this.target = null;
this.started = curRound;
this.turns = turns;
}
public Player playerCasting(){
return this.caster;
}
public Player spellTarget(){
return this.target;
}
public int started(){
return this.started;
}
public int turns(){
return this.turns;
}
}