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.item.effect.use; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.game.exploration.ExplorationPlayer; |
23
|
|
|
import fr.quatrevieux.araknemu.game.exploration.map.cell.ExplorationMapCell; |
24
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.player.PlayerFighter; |
25
|
|
|
import fr.quatrevieux.araknemu.game.item.effect.UseEffect; |
26
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Effect handler for an use effect |
30
|
|
|
*/ |
31
|
|
|
public interface UseEffectHandler { |
32
|
|
|
/** |
33
|
|
|
* Apply the item effect to the caster |
34
|
|
|
* |
35
|
|
|
* @param effect The effect to apply |
36
|
|
|
* @param caster The caster |
37
|
|
|
*/ |
38
|
|
|
public void apply(UseEffect effect, ExplorationPlayer caster); |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Apply the item effect to a target player or cell |
42
|
|
|
* |
43
|
|
|
* {@link UseEffectHandler#checkTarget(UseEffect, ExplorationPlayer, ExplorationPlayer, ExplorationMapCell)} must be called before |
44
|
|
|
* |
45
|
|
|
* @param effect The effect to apply |
46
|
|
|
* @param caster The effect caster |
47
|
|
|
* @param target The effect target (can be null) |
48
|
|
|
* @param cell The target cell. null if no cell is targeted |
49
|
|
|
*/ |
50
|
1 |
|
public default void applyToTarget(UseEffect effect, ExplorationPlayer caster, @Nullable ExplorationPlayer target, @Nullable ExplorationMapCell cell) {} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Check if the effect can be used |
54
|
|
|
* |
55
|
|
|
* @param effect The effect to apply |
56
|
|
|
* @param caster The caster |
57
|
|
|
* |
58
|
|
|
* @return True if the effect can be applied or false |
59
|
|
|
*/ |
60
|
|
|
public boolean check(UseEffect effect, ExplorationPlayer caster); |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Check if the effect can be used to the target |
64
|
|
|
* |
65
|
|
|
* @param effect The effect to apply |
66
|
|
|
* @param caster The caster |
67
|
|
|
* @param target The effect target (can be null) |
68
|
|
|
* @param cell The target cell. null if no cell is targeted |
69
|
|
|
* |
70
|
|
|
* @return True if the effect can be applied or false |
71
|
|
|
*/ |
72
|
|
|
public boolean checkTarget(UseEffect effect, ExplorationPlayer caster, @Nullable ExplorationPlayer target, @Nullable ExplorationMapCell cell); |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Check if the effect can be used by a fighter during placement |
76
|
|
|
* |
77
|
|
|
* @param effect The effect to apply |
78
|
|
|
* @param fighter The fighter to check |
79
|
|
|
* |
80
|
|
|
* @return True if the effect can be applied or false |
81
|
|
|
*/ |
82
|
|
|
public default boolean checkFighter(UseEffect effect, PlayerFighter fighter) { |
83
|
1 |
|
return false; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Apply the item effect to the fighter during placement |
88
|
|
|
* |
89
|
|
|
* @param effect The effect to apply |
90
|
|
|
* @param fighter The fighter |
91
|
|
|
*/ |
92
|
|
|
public default void applyToFighter(UseEffect effect, PlayerFighter fighter) {} |
93
|
|
|
} |
94
|
|
|
|