|
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.exploration.creature; |
|
21
|
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.game.exploration.ExplorationPlayer; |
|
23
|
|
|
import fr.quatrevieux.araknemu.game.exploration.npc.GameNpc; |
|
24
|
|
|
import fr.quatrevieux.araknemu.game.monster.group.MonsterGroup; |
|
25
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Operation to apply on a creature |
|
29
|
|
|
* |
|
30
|
|
|
* @param <R> The result type of the operation. |
|
31
|
|
|
* This value must be returned by the {@link ExplorationCreature#apply(Operation)} method |
|
32
|
|
|
* The type must be Boolean for apply on map using {@link fr.quatrevieux.araknemu.game.exploration.map.cell.ExplorationMapCell#apply(Operation)} |
|
33
|
|
|
*/ |
|
34
|
|
|
public interface Operation<R> { |
|
35
|
|
|
/** |
|
36
|
|
|
* Apply the operation on an exploration player |
|
37
|
|
|
*/ |
|
38
|
|
|
public default @Nullable R onExplorationPlayer(ExplorationPlayer player) { |
|
39
|
1 |
|
return onCreature(player); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Apply the operation on a NPC |
|
44
|
|
|
*/ |
|
45
|
|
|
public default @Nullable R onNpc(GameNpc npc) { |
|
46
|
1 |
|
return onCreature(npc); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Apply the operation on a monster group |
|
51
|
|
|
*/ |
|
52
|
|
|
public default @Nullable R onMonsterGroup(MonsterGroup monsterGroup) { |
|
53
|
1 |
|
return onCreature(monsterGroup); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Generic operation to apply to all creatures |
|
58
|
|
|
*/ |
|
59
|
|
|
public default @Nullable R onCreature(ExplorationCreature creature) { |
|
60
|
1 |
|
return null; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|