|
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; |
|
21
|
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.data.constant.Effect; |
|
23
|
|
|
import fr.quatrevieux.araknemu.data.value.ItemTemplateEffectEntry; |
|
24
|
|
|
import org.checkerframework.checker.index.qual.NonNegative; |
|
25
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Effect for weapon items |
|
29
|
|
|
*/ |
|
30
|
|
|
public final class WeaponEffect implements ItemEffect { |
|
31
|
|
|
private final Effect effect; |
|
32
|
|
|
private final @NonNegative int min; |
|
33
|
|
|
private final @NonNegative int max; |
|
34
|
|
|
private final @NonNegative int extra; |
|
35
|
|
|
|
|
36
|
1 |
|
public WeaponEffect(Effect effect, @NonNegative int min, @NonNegative int max, @NonNegative int extra) { |
|
37
|
1 |
|
this.effect = effect; |
|
38
|
1 |
|
this.min = min; |
|
39
|
1 |
|
this.max = max; |
|
40
|
1 |
|
this.extra = extra; |
|
41
|
1 |
|
} |
|
42
|
|
|
|
|
43
|
|
|
@Override |
|
44
|
|
|
public Effect effect() { |
|
45
|
1 |
|
return effect; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
@Override |
|
49
|
|
|
public ItemTemplateEffectEntry toTemplate() { |
|
50
|
1 |
|
return new ItemTemplateEffectEntry(effect, min, max, extra, "1d" + (max - min + 1) + "+" + (min - 1)); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public @NonNegative int min() { |
|
54
|
1 |
|
return min; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public @NonNegative int max() { |
|
58
|
1 |
|
return max; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public @NonNegative int extra() { |
|
62
|
1 |
|
return extra; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
@Override |
|
66
|
|
|
public boolean equals(@Nullable Object o) { |
|
67
|
1 |
|
if (this == o) { |
|
68
|
1 |
|
return true; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
1 |
|
if (o == null || getClass() != o.getClass()) { |
|
72
|
1 |
|
return false; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
1 |
|
final WeaponEffect that = (WeaponEffect) o; |
|
76
|
|
|
|
|
77
|
1 |
|
return min == that.min |
|
78
|
|
|
&& max == that.max |
|
79
|
|
|
&& extra == that.extra |
|
80
|
|
|
&& effect == that.effect |
|
81
|
|
|
; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
@Override |
|
85
|
|
|
public int hashCode() { |
|
86
|
1 |
|
int result = effect.hashCode(); |
|
87
|
|
|
|
|
88
|
1 |
|
result = 31 * result + min; |
|
89
|
1 |
|
result = 31 * result + max; |
|
90
|
1 |
|
result = 31 * result + extra; |
|
91
|
|
|
|
|
92
|
1 |
|
return result; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
@Override |
|
96
|
|
|
public String toString() { |
|
97
|
1 |
|
return "WeaponEffect{" + effect + ":" + min + ", " + max + ", " + extra + '}'; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|