AchievementLogic.java

1
package io.github.some_example_name;
2
3
/**
4
 * Core logic for achievements - no LibGDX.
5
 */
6
public class AchievementLogic {
7
8
    private float y;
9
    private final float targetY;
10
    private final float speed;
11
    private boolean visible;
12
    private boolean unlocked;
13
14
    public AchievementLogic(float startY, float targetY, float speed) {
15
        this.y = startY;
16
        this.targetY = targetY;
17
        this.speed = speed;
18
        this.visible = false;
19
        this.unlocked = false;
20
    }
21
22
    /** Unlocks achievement once */
23
    public void unlock() {
24 1 1. unlock : negated conditional → KILLED
        if (!unlocked) {
25
            unlocked = true;
26
            visible = true;
27
        }
28
    }
29
30
    /** Updates vertical animation when visible */
31
    public void update(float delta) {
32 1 1. update : negated conditional → KILLED
        if (!visible) return;
33
34 2 1. update : changed conditional boundary → SURVIVED
2. update : negated conditional → KILLED
        if (y < targetY) {
35 2 1. update : Replaced float multiplication with division → SURVIVED
2. update : Replaced float addition with subtraction → KILLED
            y += speed * delta;
36 2 1. update : changed conditional boundary → SURVIVED
2. update : negated conditional → KILLED
            if (y > targetY) {
37
                y = targetY;
38
            }
39
        }
40
    }
41
42
    /** Hides achievement */
43
    public void hide() {
44
        visible = false;
45
    }
46
47
    public boolean isUnlocked() {
48 2 1. isUnlocked : replaced boolean return with true for io/github/some_example_name/AchievementLogic::isUnlocked → KILLED
2. isUnlocked : replaced boolean return with false for io/github/some_example_name/AchievementLogic::isUnlocked → KILLED
        return unlocked;
49
    }
50
51
    public boolean isVisible() {
52 2 1. isVisible : replaced boolean return with false for io/github/some_example_name/AchievementLogic::isVisible → KILLED
2. isVisible : replaced boolean return with true for io/github/some_example_name/AchievementLogic::isVisible → KILLED
        return visible;
53
    }
54
55
    public float getY() {
56 1 1. getY : replaced float return with 0.0f for io/github/some_example_name/AchievementLogic::getY → KILLED
        return y;
57
    }
58
}

Mutations

24

1.1
Location : unlock
Killed by : io.github.some_example_name.AchievementLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.AchievementLogicTest]/[method:unlockSetsUnlockedAndVisible()]
negated conditional → KILLED

32

1.1
Location : update
Killed by : io.github.some_example_name.AchievementLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.AchievementLogicTest]/[method:updateMovesTowardsTarget()]
negated conditional → KILLED

34

1.1
Location : update
Killed by : none
changed conditional boundary → SURVIVED

2.2
Location : update
Killed by : io.github.some_example_name.AchievementLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.AchievementLogicTest]/[method:updateMovesTowardsTarget()]
negated conditional → KILLED

35

1.1
Location : update
Killed by : none
Replaced float multiplication with division → SURVIVED

2.2
Location : update
Killed by : io.github.some_example_name.AchievementLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.AchievementLogicTest]/[method:updateMovesTowardsTarget()]
Replaced float addition with subtraction → KILLED

36

1.1
Location : update
Killed by : none
changed conditional boundary → SURVIVED

2.2
Location : update
Killed by : io.github.some_example_name.AchievementLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.AchievementLogicTest]/[method:updateClampsAtTarget()]
negated conditional → KILLED

48

1.1
Location : isUnlocked
Killed by : io.github.some_example_name.QuizAchievementIntegrationTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizAchievementIntegrationTest]/[method:incorrectQuizAnswerDoesNotUnlockAchievement()]
replaced boolean return with true for io/github/some_example_name/AchievementLogic::isUnlocked → KILLED

2.2
Location : isUnlocked
Killed by : io.github.some_example_name.AchievementLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.AchievementLogicTest]/[method:unlockSetsUnlockedAndVisible()]
replaced boolean return with false for io/github/some_example_name/AchievementLogic::isUnlocked → KILLED

52

1.1
Location : isVisible
Killed by : io.github.some_example_name.AchievementLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.AchievementLogicTest]/[method:unlockSetsUnlockedAndVisible()]
replaced boolean return with false for io/github/some_example_name/AchievementLogic::isVisible → KILLED

2.2
Location : isVisible
Killed by : io.github.some_example_name.AchievementLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.AchievementLogicTest]/[method:hideMakesInvisible()]
replaced boolean return with true for io/github/some_example_name/AchievementLogic::isVisible → KILLED

56

1.1
Location : getY
Killed by : io.github.some_example_name.AchievementLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.AchievementLogicTest]/[method:updateClampsAtTarget()]
replaced float return with 0.0f for io/github/some_example_name/AchievementLogic::getY → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0