More Error Handling for Score
This commit is contained in:
parent
d36e1901e6
commit
e928543e3f
@ -3,6 +3,7 @@ package de.teamteamteam.spacescooter.datastructure;
|
|||||||
public class Score {
|
public class Score {
|
||||||
|
|
||||||
private static int score = 0;
|
private static int score = 0;
|
||||||
|
private static int maxScore = 99999999;
|
||||||
|
|
||||||
public static int getScore() {
|
public static int getScore() {
|
||||||
return score;
|
return score;
|
||||||
@ -13,13 +14,19 @@ public class Score {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void addScore(int score) {
|
public static void addScore(int score) {
|
||||||
if (Score.score != 99999999)
|
if (Score.score + score >= Score.maxScore) {
|
||||||
Score.score += score;
|
Score.setScore(Score.maxScore);
|
||||||
|
} else if (Score.score != Score.maxScore) {
|
||||||
|
Score.score += score;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeScore(int score) {
|
public static void removeScore(int score) {
|
||||||
if (Score.score != 0)
|
if (Score.score - score <= 0) {
|
||||||
Score.score -= score;
|
Score.setScore(0);
|
||||||
|
} else if (Score.score != 0) {
|
||||||
|
Score.score -= score;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public abstract class LivingEntity extends Entity implements Collidable, Hittabl
|
|||||||
this.healthPoints = 0;
|
this.healthPoints = 0;
|
||||||
this.shieldPoints = 0;
|
this.shieldPoints = 0;
|
||||||
Score.addScore(ScorePoints);
|
Score.addScore(ScorePoints);
|
||||||
if(this instanceof Enemy){ // Add 1 credit for the shop
|
if(this instanceof Enemy){ // Add 1 credit for the shop
|
||||||
Credits.setCredits(Credits.getCredits() + 1);
|
Credits.setCredits(Credits.getCredits() + 1);
|
||||||
}
|
}
|
||||||
if(GameConfig.DEBUG) System.out.println(this + " ist gestorben. RIP");
|
if(GameConfig.DEBUG) System.out.println(this + " ist gestorben. RIP");
|
||||||
|
Loading…
Reference in New Issue
Block a user