Skip to content

Commit

Permalink
added function comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nawal-0 committed Sep 11, 2023
1 parent 1d4b7b1 commit 0aa5518
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -51,14 +51,17 @@ 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);
}

@Override
protected void draw(SpriteBatch batch) {

// handled by stage
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down

0 comments on commit 0aa5518

Please sign in to comment.