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 {
|
||||
|
||||
private static int score = 0;
|
||||
private static int maxScore = 99999999;
|
||||
|
||||
public static int getScore() {
|
||||
return score;
|
||||
|
@ -13,13 +14,19 @@ public class Score {
|
|||
}
|
||||
|
||||
public static void addScore(int score) {
|
||||
if (Score.score != 99999999)
|
||||
Score.score += score;
|
||||
if (Score.score + score >= Score.maxScore) {
|
||||
Score.setScore(Score.maxScore);
|
||||
} else if (Score.score != Score.maxScore) {
|
||||
Score.score += score;
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeScore(int score) {
|
||||
if (Score.score != 0)
|
||||
Score.score -= score;
|
||||
if (Score.score - score <= 0) {
|
||||
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.shieldPoints = 0;
|
||||
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);
|
||||
}
|
||||
if(GameConfig.DEBUG) System.out.println(this + " ist gestorben. RIP");
|
||||
|
|
Loading…
Reference in New Issue