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.game.fight.castable.effect.handler.characteristic; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.data.constant.Characteristic; |
23
|
|
|
import fr.quatrevieux.araknemu.game.fight.Fight; |
24
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.FightCastScope; |
25
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.EffectValue; |
26
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.buff.Buff; |
27
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.buff.BuffEffect; |
28
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.buff.BuffHook; |
29
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.handler.EffectHandler; |
30
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.Fighter; |
31
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.FighterData; |
32
|
|
|
import fr.quatrevieux.araknemu.game.spell.effect.SpellEffect; |
33
|
|
|
import fr.quatrevieux.araknemu.network.game.out.fight.action.ActionEffect; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Decrease the sight of the spell caster |
37
|
|
|
* |
38
|
|
|
* @see Characteristic#SIGHT_BOOST |
39
|
|
|
* @see DecreaseCasterSightHandler Reverse effect |
40
|
|
|
*/ |
41
|
|
View Code Duplication |
public final class DecreaseCasterSightHandler implements EffectHandler, BuffHook { |
|
|
|
|
42
|
|
|
private final Fight fight; |
43
|
|
|
|
44
|
1 |
|
public DecreaseCasterSightHandler(Fight fight) { |
45
|
1 |
|
this.fight = fight; |
46
|
1 |
|
} |
47
|
|
|
|
48
|
|
|
@Override |
49
|
|
|
public void handle(FightCastScope cast, FightCastScope.EffectScope effect) { |
50
|
1 |
|
throw new UnsupportedOperationException("Alter characteristic effect must be used as a buff"); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
@Override |
54
|
|
|
public void buff(FightCastScope cast, FightCastScope.EffectScope effect) { |
55
|
1 |
|
final SpellEffect spellEffect = effect.effect(); |
56
|
1 |
|
final Fighter caster = cast.caster(); |
57
|
|
|
|
58
|
1 |
|
caster.buffs().add(new Buff( |
59
|
1 |
|
BuffEffect.fixed(spellEffect, EffectValue.create(spellEffect, caster, caster).value()), |
60
|
1 |
|
cast.action(), |
61
|
|
|
caster, |
62
|
|
|
caster, |
63
|
|
|
this |
64
|
|
|
)); |
65
|
1 |
|
} |
66
|
|
|
|
67
|
|
|
@Override |
68
|
|
|
public void onBuffStarted(Buff buff) { |
69
|
1 |
|
final int value = buff.effect().min(); |
70
|
1 |
|
final FighterData target = buff.target(); |
71
|
|
|
|
72
|
1 |
|
target.characteristics().alter(Characteristic.SIGHT_BOOST, -value); |
73
|
1 |
|
fight.send(ActionEffect.decreaseSight(target, target, value, buff.remainingTurns())); |
74
|
1 |
|
} |
75
|
|
|
|
76
|
|
|
@Override |
77
|
|
|
public void onBuffTerminated(Buff buff) { |
78
|
1 |
|
buff.target().characteristics().alter(Characteristic.SIGHT_BOOST, buff.effect().min()); |
79
|
1 |
|
} |
80
|
|
|
} |
81
|
|
|
|