1
|
|
|
/* |
2
|
|
|
* This file is part of Araknemu. |
3
|
|
|
* |
4
|
|
|
* Araknemu is free software: you can redistribute it and/or modify |
5
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
6
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
7
|
|
|
* (at your option) any later version. |
8
|
|
|
* |
9
|
|
|
* Araknemu is distributed in the hope that it will be useful, |
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12
|
|
|
* GNU Lesser General Public License for more details. |
13
|
|
|
* |
14
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
15
|
|
|
* along with Araknemu. If not, see <https://www.gnu.org/licenses/>. |
16
|
|
|
* |
17
|
|
|
* Copyright (c) 2017-2019 Vincent Quatrevieux |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
package fr.quatrevieux.araknemu.network.game.out.fight.action; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.buff.Buff; |
23
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.PassiveFighter; |
24
|
|
|
import fr.quatrevieux.araknemu.game.fight.map.FightCell; |
25
|
|
|
import fr.quatrevieux.araknemu.game.spell.Spell; |
26
|
|
|
import org.apache.commons.lang3.StringUtils; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Effect of a fight action |
30
|
|
|
*/ |
31
|
|
|
public final class ActionEffect { |
32
|
|
|
private final int id; |
33
|
|
|
private final PassiveFighter caster; |
34
|
|
|
private final Object[] arguments; |
35
|
|
|
|
36
|
1 |
|
public ActionEffect(int id, PassiveFighter caster, Object... arguments) { |
37
|
1 |
|
this.id = id; |
38
|
1 |
|
this.caster = caster; |
39
|
1 |
|
this.arguments = arguments; |
40
|
1 |
|
} |
41
|
|
|
|
42
|
|
|
@Override |
43
|
|
|
public String toString() { |
44
|
1 |
|
return "GA;" + id + ";" + caster.id() + ";" + StringUtils.join(arguments, ","); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Send used movement points after a movement |
49
|
|
|
* |
50
|
|
|
* @param fighter The fighter |
51
|
|
|
* @param quantity The MP quantity |
52
|
|
|
*/ |
53
|
|
|
public static ActionEffect usedMovementPoints(PassiveFighter fighter, int quantity) { |
54
|
1 |
|
return new ActionEffect(129, fighter, fighter.id(), -quantity); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Send used action points after an action |
59
|
|
|
* |
60
|
|
|
* @param fighter The fighter |
61
|
|
|
* @param quantity The AP quantity |
62
|
|
|
*/ |
63
|
|
|
public static ActionEffect usedActionPoints(PassiveFighter fighter, int quantity) { |
64
|
1 |
|
return new ActionEffect(102, fighter, fighter.id(), -quantity); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Change target life |
69
|
|
|
* |
70
|
|
|
* @param caster The effect castet |
71
|
|
|
* @param target The target |
72
|
|
|
* @param quantity The life points difference. Negative for damage, Positive for heal |
73
|
|
|
*/ |
74
|
|
|
public static ActionEffect alterLifePoints(PassiveFighter caster, PassiveFighter target, int quantity) { |
75
|
1 |
|
return new ActionEffect(100, caster, target.id(), quantity); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Critical hit for spell |
80
|
|
|
* |
81
|
|
|
* @param caster The spell caster |
82
|
|
|
* @param spell The launched spell |
83
|
|
|
*/ |
84
|
|
|
public static ActionEffect criticalHitSpell(PassiveFighter caster, Spell spell) { |
85
|
1 |
|
return new ActionEffect(301, caster, spell.id()); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Critical hit for close combat cast |
90
|
|
|
* |
91
|
|
|
* @param caster The weapon caster |
92
|
|
|
*/ |
93
|
|
|
public static ActionEffect criticalHitCloseCombat(PassiveFighter caster) { |
94
|
1 |
|
return new ActionEffect(304, caster); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* A fighter die |
99
|
|
|
* |
100
|
|
|
* @param caster The spell caster |
101
|
|
|
* @param fighter The dead fighter |
102
|
|
|
*/ |
103
|
|
|
public static ActionEffect fighterDie(PassiveFighter caster, PassiveFighter fighter) { |
104
|
1 |
|
return new ActionEffect(103, caster, fighter.id()); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Teleport a fighter |
109
|
|
|
* |
110
|
|
|
* @param caster The spell caster |
111
|
|
|
* @param fighter The teleport fighter |
112
|
|
|
* @param target The target cell |
113
|
|
|
*/ |
114
|
|
|
public static ActionEffect teleport(PassiveFighter caster, PassiveFighter fighter, FightCell target) { |
115
|
1 |
|
return new ActionEffect(4, caster, fighter.id(), target.id()); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* The fighter skip the next turn |
120
|
|
|
* |
121
|
|
|
* @param caster The buff caster |
122
|
|
|
* @param fighter The target fighter |
123
|
|
|
*/ |
124
|
|
|
public static ActionEffect skipNextTurn(PassiveFighter caster, PassiveFighter fighter) { |
125
|
1 |
|
return new ActionEffect(140, caster, fighter.id()); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* The fighter return the spell |
130
|
|
|
* |
131
|
|
|
* @param fighter The fighter |
132
|
|
|
* @param success true is the spell is successfully returned |
133
|
|
|
*/ |
134
|
|
|
public static ActionEffect returnSpell(PassiveFighter fighter, boolean success) { |
135
|
1 |
|
return new ActionEffect(106, fighter, fighter.id(), success ? "1" : "0"); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Buff effect for characteristic change |
140
|
|
|
* |
141
|
|
|
* @param buff The applied buff |
142
|
|
|
*/ |
143
|
|
|
public static ActionEffect buff(Buff buff, int value) { |
144
|
1 |
|
return new ActionEffect(buff.effect().effect(), buff.caster(), buff.target().id(), value, buff.effect().duration()); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Add action points for the current turn |
149
|
|
|
* |
150
|
|
|
* @param fighter The fighter |
151
|
|
|
* @param quantity The AP quantity |
152
|
|
|
*/ |
153
|
|
|
public static ActionEffect addActionPoints(PassiveFighter fighter, int quantity) { |
154
|
1 |
|
return new ActionEffect(120, fighter, fighter.id(), quantity); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Remove action points for the current turn |
159
|
|
|
* |
160
|
|
|
* @param fighter The fighter |
161
|
|
|
* @param quantity The AP quantity |
162
|
|
|
*/ |
163
|
|
|
public static ActionEffect removeActionPoints(PassiveFighter fighter, int quantity) { |
164
|
1 |
|
return new ActionEffect(168, fighter, fighter.id(), -quantity); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Add movement points for the current turn |
169
|
|
|
* |
170
|
|
|
* @param fighter The fighter |
171
|
|
|
* @param quantity The MP quantity |
172
|
|
|
*/ |
173
|
|
|
public static ActionEffect addMovementPoints(PassiveFighter fighter, int quantity) { |
174
|
1 |
|
return new ActionEffect(128, fighter, fighter.id(), quantity); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Remove movement points for the current turn |
179
|
|
|
* |
180
|
|
|
* @param fighter The fighter |
181
|
|
|
* @param quantity The MP quantity |
182
|
|
|
*/ |
183
|
|
|
public static ActionEffect removeMovementPoints(PassiveFighter fighter, int quantity) { |
184
|
1 |
|
return new ActionEffect(169, fighter, fighter.id(), -quantity); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Suffered damage value is reduced |
189
|
|
|
* |
190
|
|
|
* @param fighter The fighter |
191
|
|
|
* @param value The reduction value |
192
|
|
|
*/ |
193
|
|
|
public static ActionEffect reducedDamage(PassiveFighter fighter, int value) { |
194
|
1 |
|
return new ActionEffect(105, fighter, fighter.id(), value); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Add state to the fighter |
199
|
|
|
* |
200
|
|
|
* @param fighter The fighter |
201
|
|
|
* @param state The state id to add |
202
|
|
|
*/ |
203
|
|
|
public static ActionEffect addState(PassiveFighter fighter, int state) { |
204
|
1 |
|
return new ActionEffect(950, fighter, fighter.id(), state, 1); |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Remove state from the fighter |
209
|
|
|
* |
210
|
|
|
* @param fighter The fighter |
211
|
|
|
* @param state The state id to remove |
212
|
|
|
*/ |
213
|
|
|
public static ActionEffect removeState(PassiveFighter fighter, int state) { |
214
|
1 |
|
return new ActionEffect(950, fighter, fighter.id(), state, 0); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Remove all buffs that can be removed from the target |
219
|
|
|
* |
220
|
|
|
* @param caster The caster |
221
|
|
|
* @param target The target |
222
|
|
|
*/ |
223
|
|
|
public static ActionEffect dispelBuffs(PassiveFighter caster, PassiveFighter target) { |
224
|
1 |
|
return new ActionEffect(132, caster, target.id()); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* The fighter has been slided (i.e. move back or front) by the caster |
229
|
|
|
* |
230
|
|
|
* @param caster The spell caster |
231
|
|
|
* @param target The target (which has moved) |
232
|
|
|
* @param destination The destination cell |
233
|
|
|
*/ |
234
|
|
|
public static ActionEffect slide(PassiveFighter caster, PassiveFighter target, FightCell destination) { |
235
|
1 |
|
return new ActionEffect(5, caster, target.id(), destination.id()); |
236
|
|
|
} |
237
|
|
|
} |
238
|
|
|
|