|
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.fighter.operation; |
|
21
|
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.Fighter; |
|
23
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.invocation.InvocationFighter; |
|
24
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.monster.MonsterFighter; |
|
25
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.player.PlayerFighter; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Operation to apply on a fighter creature |
|
29
|
|
|
* Implements the visitor pattern |
|
30
|
|
|
* |
|
31
|
|
|
* @see Fighter#apply(FighterOperation) |
|
32
|
|
|
*/ |
|
33
|
|
|
public interface FighterOperation { |
|
34
|
|
|
/** |
|
35
|
|
|
* Apply the operation to a PlayerFighter |
|
36
|
|
|
*/ |
|
37
|
|
|
public default void onPlayer(PlayerFighter fighter) { |
|
38
|
1 |
|
onGenericFighter(fighter); |
|
39
|
1 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Apply the operation to a MonsterFighter |
|
43
|
|
|
*/ |
|
44
|
|
|
public default void onMonster(MonsterFighter fighter) { |
|
45
|
1 |
|
onGenericFighter(fighter); |
|
46
|
1 |
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Apply the operation to an InvocationFighter |
|
50
|
|
|
*/ |
|
51
|
|
|
public default void onInvocation(InvocationFighter fighter) { |
|
52
|
|
|
onGenericFighter(fighter); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Apply the operation to a generic fighter type |
|
57
|
|
|
*/ |
|
58
|
1 |
|
public default void onGenericFighter(Fighter fighter) {} |
|
59
|
|
|
} |
|
60
|
|
|
|