reset()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
package de.pewpewproject.lasertag.lasertaggame.state.server.implementation;
2
3
import de.pewpewproject.lasertag.lasertaggame.state.server.IMusicalChairsState;
4
5
import java.util.Map;
6
import java.util.Optional;
7
import java.util.UUID;
8
import java.util.concurrent.ConcurrentHashMap;
9
10
/**
11
 * Implementation of IMusicalChairsState for the lasertag game.
12
 *
13
 * @author Étienne Muser
14
 */
15
public class MusicalChairsState implements IMusicalChairsState {
16
17
    /**
18
     * Map mapping every player's uuid to the overall score they achieved
19
     *     key: The players uuid
20
     *     value: The overall score the player achieved
21
     */
22
    private final Map<UUID, Long> playerOverallScoreMap = new ConcurrentHashMap<>();
23
24
    @Override
25
    public void setPlayerOverallScore(UUID playerUuid, long newScore) {
26
        playerOverallScoreMap.put(playerUuid, newScore);
27
    }
28
29
    @Override
30
    public long getPlayerOverallScore(UUID playerUuid) {
31
        return Optional.ofNullable(playerOverallScoreMap.get(playerUuid)).orElse(0L);
32
    }
33
34
    @Override
35
    public void reset() {
36
37
        playerOverallScoreMap.clear();
38
    }
39
}
40