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-2021 Vincent Quatrevieux |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
package fr.quatrevieux.araknemu.game.fight.castable.effect.handler.heal; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.data.constant.Characteristic; |
23
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.CastScope; |
24
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.EffectValue; |
25
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.buff.Buff; |
26
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.buff.BuffHook; |
27
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.handler.EffectHandler; |
28
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.ActiveFighter; |
29
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.PassiveFighter; |
30
|
|
|
import fr.quatrevieux.araknemu.game.spell.effect.SpellEffect; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Handle basic heal effect |
34
|
|
|
* |
35
|
|
|
* This effect is boosted by {@link Characteristic#INTELLIGENCE} and {@link Characteristic#HEALTH_BOOST} |
36
|
|
|
*/ |
37
|
1 |
View Code Duplication |
public final class HealHandler implements EffectHandler, BuffHook { |
|
|
|
|
38
|
|
|
@Override |
39
|
|
|
public void handle(CastScope cast, CastScope.EffectScope effect) { |
40
|
1 |
|
for (PassiveFighter target : effect.targets()) { |
41
|
1 |
|
apply(cast.caster(), effect.effect(), target); |
42
|
1 |
|
} |
43
|
1 |
|
} |
44
|
|
|
|
45
|
|
|
@Override |
46
|
|
|
public void buff(CastScope cast, CastScope.EffectScope effect) { |
47
|
1 |
|
for (PassiveFighter target : effect.targets()) { |
48
|
1 |
|
target.buffs().add(new Buff(effect.effect(), cast.action(), cast.caster(), target, this)); |
49
|
1 |
|
} |
50
|
1 |
|
} |
51
|
|
|
|
52
|
|
|
@Override |
53
|
|
|
public boolean onStartTurn(Buff buff) { |
54
|
1 |
|
apply(buff.caster(), buff.effect(), buff.target()); |
55
|
|
|
|
56
|
1 |
|
return true; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
private void apply(ActiveFighter caster, SpellEffect effect, PassiveFighter target) { |
60
|
1 |
|
final EffectValue value = new EffectValue(effect) |
61
|
1 |
|
.percent(caster.characteristics().get(Characteristic.INTELLIGENCE)) |
62
|
1 |
|
.fixed(caster.characteristics().get(Characteristic.HEALTH_BOOST)) |
63
|
|
|
; |
64
|
|
|
|
65
|
1 |
|
target.life().alter(caster, value.value()); |
66
|
1 |
|
} |
67
|
|
|
} |
68
|
|
|
|