CodePage.java

1
package io.github.some_example_name;
2
3
import com.badlogic.gdx.Gdx;
4
import com.badlogic.gdx.Input;
5
import com.badlogic.gdx.graphics.Color;
6
import com.badlogic.gdx.graphics.OrthographicCamera;
7
import com.badlogic.gdx.graphics.Texture;
8
import com.badlogic.gdx.graphics.g2d.BitmapFont;
9
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
10
import com.badlogic.gdx.math.Vector2;
11
12
public class CodePage {
13
14
    private Texture pageTexture;
15
    private Vector2 position;
16
    private BitmapFont font;
17
    private BitmapFont font2;
18
    private String codeHalf;
19
20
    // Logic extracted for testability
21
    private final CodePageLogic logic;
22
23
    public CodePage(float x, float y, int pageNo, String code) {
24
        this.pageTexture = new Texture("Page" + pageNo + ".png");
25
        this.codeHalf = code;
26
        this.position = new Vector2(x, y);
27
28
        this.logic = new CodePageLogic();
29
30
        font = new BitmapFont();
31 1 1. <init> : removed call to com/badlogic/gdx/graphics/g2d/BitmapFont$BitmapFontData::setScale → NO_COVERAGE
        font.getData().setScale(4f);
32 1 1. <init> : removed call to com/badlogic/gdx/graphics/g2d/BitmapFont::setColor → NO_COVERAGE
        font.setColor(Color.BLACK);
33
34
        font2 = new BitmapFont();
35 1 1. <init> : removed call to com/badlogic/gdx/graphics/g2d/BitmapFont::setColor → NO_COVERAGE
        font2.setColor(Color.BLACK);
36 1 1. <init> : removed call to com/badlogic/gdx/graphics/g2d/BitmapFont$BitmapFontData::setScale → NO_COVERAGE
        font2.getData().setScale(0.8f);
37
    }
38
39
    /**
40
     * Update attributes of page and handle interaction.
41
     */
42
    public void update(Player player, float delta) {
43 1 1. update : removed call to io/github/some_example_name/CodePageLogic::handleInteraction → NO_COVERAGE
        logic.handleInteraction(
44
            player.getPosition(),
45
            position,
46
            Gdx.input.isKeyJustPressed(Input.Keys.E)
47
        );
48
    }
49
50
    /**
51
     * Draw page in the world when not being looked at.
52
     */
53
    public void render(SpriteBatch batch) {
54 1 1. render : negated conditional → NO_COVERAGE
        if (!logic.isLooking()) {
55 1 1. render : removed call to com/badlogic/gdx/graphics/g2d/SpriteBatch::draw → NO_COVERAGE
            batch.draw(pageTexture, position.x, position.y, 15, 15);
56
        }
57
    }
58
59
    /**
60
     * Draw enlarged page and text when being looked at.
61
     */
62
    public void render2(SpriteBatch batch, OrthographicCamera camera) {
63
        float width = 150f;
64
        float height = 150f;
65
66 2 1. render2 : Replaced float division with multiplication → NO_COVERAGE
2. render2 : Replaced float subtraction with addition → NO_COVERAGE
        float x = camera.position.x - width / 2f;
67 2 1. render2 : Replaced float division with multiplication → NO_COVERAGE
2. render2 : Replaced float subtraction with addition → NO_COVERAGE
        float y = camera.position.y - height / 2f;
68
69 1 1. render2 : negated conditional → NO_COVERAGE
        if (logic.isLooking()) {
70 1 1. render2 : removed call to com/badlogic/gdx/graphics/g2d/SpriteBatch::draw → NO_COVERAGE
            batch.draw(pageTexture, x, y, width, height);
71 3 1. render2 : Replaced float addition with subtraction → NO_COVERAGE
2. render2 : Replaced float addition with subtraction → NO_COVERAGE
3. render2 : Replaced float subtraction with addition → NO_COVERAGE
            font.draw(batch, codeHalf, x + 35, y + height - 40);
72 2 1. render2 : Replaced float addition with subtraction → NO_COVERAGE
2. render2 : Replaced float addition with subtraction → NO_COVERAGE
            font2.draw(batch, "press E to exit", x + 35, y + 2);
73
        }
74
    }
75
76
    /**
77
     * Return if player is currently looking at the page.
78
     */
79
    public boolean getLooking() {
80 2 1. getLooking : replaced boolean return with true for io/github/some_example_name/CodePage::getLooking → NO_COVERAGE
2. getLooking : replaced boolean return with false for io/github/some_example_name/CodePage::getLooking → NO_COVERAGE
        return logic.isLooking();
81
    }
82
83
    public void dispose() {
84 1 1. dispose : removed call to com/badlogic/gdx/graphics/Texture::dispose → NO_COVERAGE
        pageTexture.dispose();
85 1 1. dispose : removed call to com/badlogic/gdx/graphics/g2d/BitmapFont::dispose → NO_COVERAGE
        font.dispose();
86 1 1. dispose : removed call to com/badlogic/gdx/graphics/g2d/BitmapFont::dispose → NO_COVERAGE
        font2.dispose();
87
    }
88
}
89

Mutations

31

1.1
Location : <init>
Killed by : none
removed call to com/badlogic/gdx/graphics/g2d/BitmapFont$BitmapFontData::setScale → NO_COVERAGE

32

1.1
Location : <init>
Killed by : none
removed call to com/badlogic/gdx/graphics/g2d/BitmapFont::setColor → NO_COVERAGE

35

1.1
Location : <init>
Killed by : none
removed call to com/badlogic/gdx/graphics/g2d/BitmapFont::setColor → NO_COVERAGE

36

1.1
Location : <init>
Killed by : none
removed call to com/badlogic/gdx/graphics/g2d/BitmapFont$BitmapFontData::setScale → NO_COVERAGE

43

1.1
Location : update
Killed by : none
removed call to io/github/some_example_name/CodePageLogic::handleInteraction → NO_COVERAGE

54

1.1
Location : render
Killed by : none
negated conditional → NO_COVERAGE

55

1.1
Location : render
Killed by : none
removed call to com/badlogic/gdx/graphics/g2d/SpriteBatch::draw → NO_COVERAGE

66

1.1
Location : render2
Killed by : none
Replaced float division with multiplication → NO_COVERAGE

2.2
Location : render2
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

67

1.1
Location : render2
Killed by : none
Replaced float division with multiplication → NO_COVERAGE

2.2
Location : render2
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

69

1.1
Location : render2
Killed by : none
negated conditional → NO_COVERAGE

70

1.1
Location : render2
Killed by : none
removed call to com/badlogic/gdx/graphics/g2d/SpriteBatch::draw → NO_COVERAGE

71

1.1
Location : render2
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

2.2
Location : render2
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

3.3
Location : render2
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

72

1.1
Location : render2
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

2.2
Location : render2
Killed by : none
Replaced float addition with subtraction → NO_COVERAGE

80

1.1
Location : getLooking
Killed by : none
replaced boolean return with true for io/github/some_example_name/CodePage::getLooking → NO_COVERAGE

2.2
Location : getLooking
Killed by : none
replaced boolean return with false for io/github/some_example_name/CodePage::getLooking → NO_COVERAGE

84

1.1
Location : dispose
Killed by : none
removed call to com/badlogic/gdx/graphics/Texture::dispose → NO_COVERAGE

85

1.1
Location : dispose
Killed by : none
removed call to com/badlogic/gdx/graphics/g2d/BitmapFont::dispose → NO_COVERAGE

86

1.1
Location : dispose
Killed by : none
removed call to com/badlogic/gdx/graphics/g2d/BitmapFont::dispose → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.15.0