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

fr.quatrevieux.araknemu.game.fight.castable.effect.buff.BuffEffect   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 81.25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 39
dl 0
loc 76
ccs 13
cts 16
cp 0.8125
rs 10
c 1
b 0
f 0
wmc 12

12 Methods

Rating   Name   Duplication   Size   Complexity  
A effect() 0 3 1
A probability() 0 3 1
A area() 0 3 1
A fixed(SpellEffect,int) 0 2 1
A BuffEffect(SpellEffect,int,int) 0 4 1
A duration() 0 3 1
A target() 0 3 1
A special() 0 3 1
A min() 0 3 1
A text() 0 3 1
A max() 0 3 1
A withCustomEffect(SpellEffect,int,int) 0 2 1
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