| 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.Texture; | |
| 6 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; | |
| 7 | ||
| 8 | /** | |
| 9 | * Handles achievement rendering and input. | |
| 10 | */ | |
| 11 | public class Achievement { | |
| 12 | ||
| 13 | private final Texture texture; | |
| 14 | private final AchievementLogic logic; | |
| 15 | ||
| 16 | private static Achievement activeAchievement; | |
| 17 | ||
| 18 | public Achievement(String image) { | |
| 19 | texture = new Texture(image); | |
| 20 | logic = new AchievementLogic( | |
| 21 |
1
1. <init> : removed negation → NO_COVERAGE |
-texture.getHeight(), // start off-screen |
| 22 | 20f, // target Y | |
| 23 | 2000f // animation speed | |
| 24 | ); | |
| 25 | } | |
| 26 | ||
| 27 | /** Unlocks and shows achievement */ | |
| 28 | public void unlock() { | |
| 29 |
2
1. unlock : negated conditional → NO_COVERAGE 2. unlock : negated conditional → NO_COVERAGE |
if (activeAchievement != null && activeAchievement != this) { |
| 30 |
1
1. unlock : removed call to io/github/some_example_name/Achievement::invisible → NO_COVERAGE |
activeAchievement.invisible(); |
| 31 | } | |
| 32 | activeAchievement = this; | |
| 33 |
1
1. unlock : removed call to io/github/some_example_name/AchievementLogic::unlock → NO_COVERAGE |
logic.unlock(); |
| 34 | } | |
| 35 | ||
| 36 | /** Shows achievement without unlocking */ | |
| 37 | public void show() { | |
| 38 |
2
1. show : negated conditional → NO_COVERAGE 2. show : negated conditional → NO_COVERAGE |
if (activeAchievement != null && activeAchievement != this) { |
| 39 |
1
1. show : removed call to io/github/some_example_name/Achievement::invisible → NO_COVERAGE |
activeAchievement.invisible(); |
| 40 | } | |
| 41 | activeAchievement = this; | |
| 42 |
1
1. show : removed call to io/github/some_example_name/AchievementLogic::unlock → NO_COVERAGE |
logic.unlock(); |
| 43 | } | |
| 44 | ||
| 45 | /** Hides achievement */ | |
| 46 | public void invisible() { | |
| 47 |
1
1. invisible : removed call to io/github/some_example_name/AchievementLogic::hide → NO_COVERAGE |
logic.hide(); |
| 48 | } | |
| 49 | ||
| 50 | /** Updates animation and input */ | |
| 51 | public void update(float delta) { | |
| 52 |
1
1. update : removed call to io/github/some_example_name/AchievementLogic::update → NO_COVERAGE |
logic.update(delta); |
| 53 | ||
| 54 |
2
1. update : negated conditional → NO_COVERAGE 2. update : negated conditional → NO_COVERAGE |
if (logic.isVisible() && Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) { |
| 55 |
1
1. update : removed call to io/github/some_example_name/AchievementLogic::hide → NO_COVERAGE |
logic.hide(); |
| 56 | } | |
| 57 | } | |
| 58 | ||
| 59 | /** Draws achievement if visible */ | |
| 60 | public void draw(SpriteBatch batch, float screenWidth) { | |
| 61 |
1
1. draw : negated conditional → NO_COVERAGE |
if (!logic.isVisible()) return; |
| 62 | ||
| 63 | float scaleX = 0.2f; | |
| 64 | float scaleY = 0.4f; | |
| 65 | ||
| 66 |
1
1. draw : removed call to com/badlogic/gdx/graphics/g2d/SpriteBatch::draw → NO_COVERAGE |
batch.draw( |
| 67 | texture, | |
| 68 | 5, | |
| 69 | -15, | |
| 70 |
1
1. draw : Replaced float multiplication with division → NO_COVERAGE |
texture.getWidth() * scaleX, |
| 71 |
1
1. draw : Replaced float multiplication with division → NO_COVERAGE |
texture.getHeight() * scaleY |
| 72 | ); | |
| 73 | } | |
| 74 | ||
| 75 | public boolean isUnlocked() { | |
| 76 |
2
1. isUnlocked : replaced boolean return with true for io/github/some_example_name/Achievement::isUnlocked → NO_COVERAGE 2. isUnlocked : replaced boolean return with false for io/github/some_example_name/Achievement::isUnlocked → NO_COVERAGE |
return logic.isUnlocked(); |
| 77 | } | |
| 78 | ||
| 79 | public void dispose() { | |
| 80 |
1
1. dispose : removed call to com/badlogic/gdx/graphics/Texture::dispose → NO_COVERAGE |
texture.dispose(); |
| 81 | } | |
| 82 | } | |
Mutations | ||
| 21 |
1.1 |
|
| 29 |
1.1 2.2 |
|
| 30 |
1.1 |
|
| 33 |
1.1 |
|
| 38 |
1.1 2.2 |
|
| 39 |
1.1 |
|
| 42 |
1.1 |
|
| 47 |
1.1 |
|
| 52 |
1.1 |
|
| 54 |
1.1 2.2 |
|
| 55 |
1.1 |
|
| 61 |
1.1 |
|
| 66 |
1.1 |
|
| 70 |
1.1 |
|
| 71 |
1.1 |
|
| 76 |
1.1 2.2 |
|
| 80 |
1.1 |