fr.quatrevieux.araknemu.game.monster.reward.DefaultMonsterGradesReward   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A kamas() 0 3 1
A items() 0 3 1
A DefaultMonsterGradesReward(MonsterRewardData,List) 0 3 1
A grade(int) 0 3 1
A experience(int) 0 4 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-2020 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.game.monster.reward;
21
22
import fr.arakne.utils.value.Interval;
23
import fr.quatrevieux.araknemu.data.world.entity.monster.MonsterRewardData;
24
import fr.quatrevieux.araknemu.data.world.entity.monster.MonsterRewardItem;
25
import org.checkerframework.checker.index.qual.NonNegative;
26
import org.checkerframework.checker.index.qual.Positive;
27
28
import java.util.List;
29
30
/**
31
 * Base implementation for grade set rewards
32
 */
33
public final class DefaultMonsterGradesReward implements MonsterGradesReward {
34
    private final MonsterRewardData data;
35
    private final List<MonsterRewardItem> items;
36
37 1
    public DefaultMonsterGradesReward(MonsterRewardData data, List<MonsterRewardItem> items) {
38 1
        this.data = data;
39 1
        this.items = items;
40 1
    }
41
42
    @Override
43
    public Interval kamas() {
44 1
        return data.kamas();
45
    }
46
47
    @Override
48
    @SuppressWarnings("array.access.unsafe.high.range") // Grade number is safe
49
    public @NonNegative long experience(@Positive int gradeNumber) {
50 1
        return data.experiences()[gradeNumber - 1];
51
    }
52
53
    @Override
54
    public List<MonsterRewardItem> items() {
55 1
        return items;
56
    }
57
58
    @Override
59
    public MonsterReward grade(@Positive int gradeNumber) {
60 1
        return new DefaultMonsterReward(this, gradeNumber);
61
    }
62
}
63