apCost()   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-2019 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.game.spell.adapter;
21
22
import fr.quatrevieux.araknemu.data.world.entity.SpellTemplate;
23
import fr.quatrevieux.araknemu.game.spell.Spell;
24
import fr.quatrevieux.araknemu.game.spell.SpellConstraints;
25
import fr.quatrevieux.araknemu.game.spell.effect.SpellEffect;
26
import org.checkerframework.checker.index.qual.NonNegative;
27
import org.checkerframework.checker.index.qual.Positive;
28
29
import java.util.List;
30
31
/**
32
 * Adapt {@link fr.quatrevieux.araknemu.data.world.entity.SpellTemplate.Level} to {@link Spell}
33
 */
34
public final class SpellLevelAdapter implements Spell {
35
    private final @Positive int level;
36
    private final SpellTemplate template;
37
    private final SpellTemplate.Level data;
38
    private final List<SpellEffect> effects;
39
    private final List<SpellEffect> criticalEffects;
40
    private final SpellLevelConstraintAdapter constraints;
41
42 1
    public SpellLevelAdapter(@Positive int level, SpellTemplate template, SpellTemplate.Level data, List<SpellEffect> effects, List<SpellEffect> criticalEffects) {
43 1
        this.level = level;
44 1
        this.template = template;
45 1
        this.data = data;
46 1
        this.effects = effects;
47 1
        this.criticalEffects = criticalEffects;
48 1
        this.constraints = new SpellLevelConstraintAdapter(data);
49 1
    }
50
51
    @Override
52
    public int id() {
53 1
        return template.id();
54
    }
55
56
    @Override
57
    public int spriteId() {
58 1
        return template.sprite();
59
    }
60
61
    @Override
62
    public String spriteArgs() {
63 1
        return template.spriteArgs();
64
    }
65
66
    @Override
67
    public @Positive int level() {
68 1
        return level;
69
    }
70
71
    @Override
72
    public List<SpellEffect> effects() {
73 1
        return effects;
74
    }
75
76
    @Override
77
    public List<SpellEffect> criticalEffects() {
78 1
        return criticalEffects;
79
    }
80
81
    @Override
82
    public @NonNegative int apCost() {
83 1
        return data.apCost();
84
    }
85
86
    @Override
87
    public @NonNegative int criticalHit() {
88 1
        return data.criticalHit();
89
    }
90
91
    @Override
92
    public @NonNegative int criticalFailure() {
93 1
        return data.criticalFailure();
94
    }
95
96
    @Override
97
    public boolean modifiableRange() {
98 1
        return data.modifiableRange();
99
    }
100
101
    @Override
102
    public int minPlayerLevel() {
103 1
        return data.minPlayerLevel();
104
    }
105
106
    @Override
107
    public boolean endsTurnOnFailure() {
108 1
        return data.endsTurnOnFailure();
109
    }
110
111
    @Override
112
    public SpellConstraints constraints() {
113 1
        return constraints;
114
    }
115
}
116