Passed
Push — master ( 6700dd...d2c69e )
by Vincent
05:34 queued 12s
created

withCustomEffect(SpellEffect,int,int)   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
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.castable.effect.buff;
21
22
import fr.quatrevieux.araknemu.game.spell.effect.SpellEffect;
23
import fr.quatrevieux.araknemu.game.spell.effect.area.SpellEffectArea;
24
import fr.quatrevieux.araknemu.game.spell.effect.target.EffectTarget;
25
26
/**
27
 * Overrides effect parameters for buff effect
28
 */
29
public final class BuffEffect implements SpellEffect {
30
    private final SpellEffect baseEffect;
31
32
    private final int effect;
33
    private final int value;
34
35 1
    private BuffEffect(SpellEffect baseEffect, int effect, int value) {
36 1
        this.baseEffect = baseEffect;
37 1
        this.effect = effect;
38 1
        this.value = value;
39 1
    }
40
41
    @Override
42
    public int effect() {
43 1
        return effect;
44
    }
45
46
    @Override
47
    public int min() {
48 1
        return value;
49
    }
50
51
    @Override
52
    public int max() {
53 1
        return 0;
54
    }
55
56
    @Override
57
    public int special() {
58 1
        return 0;
59
    }
60
61
    @Override
62
    public int duration() {
63 1
        return baseEffect.duration();
64
    }
65
66
    @Override
67
    public int probability() {
68
        return 0;
69
    }
70
71
    @Override
72
    public String text() {
73 1
        return null;
74
    }
75
76
    @Override
77
    public SpellEffectArea area() {
78
        return baseEffect.area();
79
    }
80
81
    @Override
82
    public EffectTarget target() {
83
        return baseEffect.target();
84
    }
85
86
    /**
87
     * Set a fixed effect value
88
     *
89
     * @param baseEffect The spell effect
90
     * @param value The applied value
91
     */
92
    public static BuffEffect fixed(SpellEffect baseEffect, int value) {
93 1
        return new BuffEffect(baseEffect, baseEffect.effect(), value);
94
    }
95
96
    /**
97
     * Define an effect with custom effect id and a fixed value
98
     *
99
     * @param baseEffect The spell effect
100
     * @param effect The overridden effect id
101
     * @param value The applied value
102
     */
103
    public static BuffEffect withCustomEffect(SpellEffect baseEffect, int effect, int value) {
104 1
        return new BuffEffect(baseEffect, effect, value);
105
    }
106
}
107