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.ai.simulation.effect; |
21
|
|
|
|
22
|
|
|
import fr.arakne.utils.value.Interval; |
23
|
|
|
import fr.quatrevieux.araknemu.data.constant.Characteristic; |
24
|
|
|
import fr.quatrevieux.araknemu.game.fight.ai.simulation.CastSimulation; |
25
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.CastScope; |
26
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.EffectValue; |
27
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.ActiveFighter; |
28
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.PassiveFighter; |
29
|
|
|
import fr.quatrevieux.araknemu.game.spell.effect.SpellEffect; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Simulate simple heal effect |
33
|
|
|
* |
34
|
|
|
* @see fr.quatrevieux.araknemu.game.fight.castable.effect.handler.heal.HealHandler |
35
|
|
|
*/ |
36
|
1 |
|
public final class HealSimulator implements EffectSimulator { |
37
|
|
|
@Override |
38
|
|
|
public void simulate(CastSimulation simulation, CastScope.EffectScope effect) { |
39
|
1 |
|
final ActiveFighter caster = simulation.caster(); |
40
|
1 |
|
final int boost = caster.characteristics().get(Characteristic.INTELLIGENCE); |
41
|
1 |
|
final int fixed = caster.characteristics().get(Characteristic.HEALTH_BOOST); |
42
|
|
|
|
43
|
1 |
|
for (PassiveFighter target : effect.targets()) { |
44
|
1 |
|
final SpellEffect spellEffect = effect.effect(); |
45
|
1 |
|
final Interval value = EffectValue.create(spellEffect, simulation.caster(), target) |
46
|
1 |
|
.percent(boost) |
47
|
1 |
|
.fixed(fixed) |
48
|
1 |
|
.interval() |
49
|
|
|
; |
50
|
|
|
|
51
|
1 |
|
final int duration = spellEffect.duration(); |
52
|
|
|
|
53
|
1 |
|
if (duration == 0) { |
54
|
1 |
|
simulation.addHeal(value, target); |
55
|
|
|
} else { |
56
|
|
|
// Limit duration to 10 |
57
|
1 |
|
simulation.addHealBuff(value, duration < 1 || duration > 10 ? 10 : duration, target); |
58
|
|
|
} |
59
|
1 |
|
} |
60
|
1 |
|
} |
61
|
|
|
} |
62
|
|
|
|