|
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-2020 Vincent Quatrevieux |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
package fr.quatrevieux.araknemu.game.item.effect.use; |
|
21
|
|
|
|
|
22
|
|
|
import fr.arakne.utils.value.helper.RandomUtil; |
|
23
|
|
|
import fr.quatrevieux.araknemu.game.exploration.ExplorationPlayer; |
|
24
|
|
|
import fr.quatrevieux.araknemu.game.exploration.interaction.action.environment.LaunchFirework; |
|
25
|
|
|
import fr.quatrevieux.araknemu.game.exploration.map.cell.ExplorationMapCell; |
|
26
|
|
|
import fr.quatrevieux.araknemu.game.item.effect.UseEffect; |
|
27
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
|
28
|
|
|
import org.checkerframework.checker.nullness.util.NullnessUtil; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Effect for fireworks |
|
32
|
|
|
*/ |
|
33
|
1 |
|
public final class FireworkEffect implements UseEffectHandler { |
|
34
|
1 |
|
private final RandomUtil random = new RandomUtil(); |
|
35
|
|
|
|
|
36
|
|
|
@Override |
|
37
|
|
|
public void apply(UseEffect effect, ExplorationPlayer caster) { |
|
38
|
|
|
throw new UnsupportedOperationException("Cannot apply firework on self"); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
@Override |
|
42
|
|
|
public void applyToTarget(UseEffect effect, ExplorationPlayer caster, @Nullable ExplorationPlayer target, @Nullable ExplorationMapCell cell) { |
|
43
|
1 |
|
caster.interactions().push( |
|
44
|
|
|
new LaunchFirework( |
|
45
|
|
|
caster, |
|
46
|
1 |
|
NullnessUtil.castNonNull(cell).id(), |
|
47
|
1 |
|
effect.arguments()[2], |
|
48
|
1 |
|
random.rand(effect.arguments()) |
|
49
|
|
|
) |
|
50
|
|
|
); |
|
51
|
1 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
@Override |
|
54
|
|
|
public boolean check(UseEffect effect, ExplorationPlayer caster) { |
|
55
|
1 |
|
return false; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
@Override |
|
59
|
|
|
public boolean checkTarget(UseEffect effect, ExplorationPlayer caster, @Nullable ExplorationPlayer target, @Nullable ExplorationMapCell cell) { |
|
60
|
1 |
|
return cell != null; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|