launchPerTurn()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
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-2020 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.game.spell.boost.spell;
21
22
import fr.arakne.utils.value.Interval;
23
import fr.quatrevieux.araknemu.game.spell.SpellConstraints;
24
import fr.quatrevieux.araknemu.game.spell.boost.SpellModifiers;
25
26
/**
27
 * Spell constraints with modifiers
28
 */
29
public final class BoostedSpellConstraints implements SpellConstraints {
30
    private final SpellConstraints constraints;
31
    private final SpellModifiers modifiers;
32
33 1
    public BoostedSpellConstraints(SpellConstraints constraints, SpellModifiers modifiers) {
34 1
        this.constraints = constraints;
35 1
        this.modifiers = modifiers;
36 1
    }
37
38
    @Override
39
    public Interval range() {
40 1
        return constraints.range().modify(modifiers.range());
41
    }
42
43
    @Override
44
    public boolean lineLaunch() {
45 1
        return constraints.lineLaunch() && !modifiers.launchOutline();
46
    }
47
48
    @Override
49
    public boolean lineOfSight() {
50 1
        return constraints.lineOfSight() && !modifiers.lineOfSight();
51
    }
52
53
    @Override
54
    public boolean freeCell() {
55 1
        return constraints.freeCell();
56
    }
57
58
    @Override
59
    public int launchPerTurn() {
60 1
        return constraints.launchPerTurn() + modifiers.launchPerTurn();
61
    }
62
63
    @Override
64
    public int launchPerTarget() {
65 1
        return constraints.launchPerTarget() + modifiers.launchPerTarget();
66
    }
67
68
    @Override
69
    public int launchDelay() {
70 1
        final int base = modifiers.hasFixedDelay()
71 1
            ? modifiers.fixedDelay()
72 1
            : constraints.launchDelay()
73
        ;
74
75 1
        return base - modifiers.delay();
76
    }
77
78
    @Override
79
    public int[] requiredStates() {
80 1
        return constraints.requiredStates();
81
    }
82
83
    @Override
84
    public int[] forbiddenStates() {
85 1
        return constraints.forbiddenStates();
86
    }
87
}
88