diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java index f6a387245..5444a3704 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java @@ -25,7 +25,7 @@ public void create() { } /** - * Initialises the currency labels + * Initialises the engineer count display * Positions it on the stage using a table */ private void addActors() { @@ -51,6 +51,9 @@ private void addActors() { stage.addActor(table); } + /** + * Updates the engineer count on the UI component + */ public void updateCount() { String text = String.format("%d", ServiceLocator.getGameEndService().getEngineerCount()); engineerTb.getLabel().setText(text); @@ -58,7 +61,7 @@ public void updateCount() { @Override protected void draw(SpriteBatch batch) { - + // handled by stage } @Override diff --git a/source/core/src/main/com/csse3200/game/services/GameEndService.java b/source/core/src/main/com/csse3200/game/services/GameEndService.java index 82a9143ee..bc11eec44 100644 --- a/source/core/src/main/com/csse3200/game/services/GameEndService.java +++ b/source/core/src/main/com/csse3200/game/services/GameEndService.java @@ -10,15 +10,26 @@ public class GameEndService { private EngineerCountDisplay display; + /** + * Constructor for the Game End Service + */ public GameEndService() { this.engineerCount = 5; this.display = new EngineerCountDisplay(); } + /** + * Returns the number of engineers left + * @return (int) engineer count + */ public int getEngineerCount() { return engineerCount; } + /** + * Updates engineer count and the UI display + * If engineer count is 0, the game is over. + */ public void updateEngineerCount() { engineerCount -= 1; display.updateCount(); @@ -29,10 +40,17 @@ public void updateEngineerCount() { } } + /** + * Returns the game over state + * @return (boolean) true if the game is over; false otherwise + */ public boolean hasGameEnded() { return gameOver; } + /** + * Returns the Engineer Count UI component + */ public EngineerCountDisplay getDisplay() { return display; }