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.data.constant.Characteristic; |
24
|
|
|
import fr.quatrevieux.araknemu.game.exploration.ExplorationPlayer; |
25
|
|
|
import fr.quatrevieux.araknemu.game.exploration.map.cell.ExplorationMapCell; |
26
|
|
|
import fr.quatrevieux.araknemu.game.item.effect.UseEffect; |
27
|
|
|
import fr.quatrevieux.araknemu.network.game.out.info.Information; |
28
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Effect handler for add characteristic |
32
|
|
|
*/ |
33
|
|
|
public final class AddCharacteristicEffect implements UseEffectHandler { |
34
|
|
|
private final Characteristic characteristic; |
35
|
|
|
|
36
|
1 |
|
private final RandomUtil random = new RandomUtil(); |
37
|
|
|
|
38
|
1 |
|
public AddCharacteristicEffect(Characteristic characteristic) { |
39
|
1 |
|
this.characteristic = characteristic; |
40
|
1 |
|
} |
41
|
|
|
|
42
|
|
|
@Override |
43
|
|
|
public void apply(UseEffect effect, ExplorationPlayer caster) { |
44
|
1 |
|
final int value = random.rand(effect.arguments()); |
45
|
1 |
|
final Information info = Information.characteristicBoosted(characteristic, value); |
46
|
|
|
|
47
|
1 |
|
caster.player().properties().characteristics().base().add(characteristic, value); |
48
|
|
|
|
49
|
1 |
|
if (info != null) { |
50
|
1 |
|
caster.send(info); |
51
|
|
|
} |
52
|
1 |
|
} |
53
|
|
|
|
54
|
|
|
@Override |
55
|
|
|
public boolean check(UseEffect effect, ExplorationPlayer caster) { |
56
|
1 |
|
return true; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
@Override |
60
|
|
|
public boolean checkTarget(UseEffect effect, ExplorationPlayer caster, @Nullable ExplorationPlayer target, @Nullable ExplorationMapCell cell) { |
61
|
1 |
|
return false; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|