Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collab (Teams 2 and 5) Engineers/Game Loss State #139

Merged
merged 21 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
46a3c0a
Added the currency pop up to the currency task, and changed it to app…
nawal-0 Sep 10, 2023
45f0d05
Created the GameEndService, added it to the Service Locator and initi…
nawal-0 Sep 10, 2023
eb6e284
HumanWanderTask updates GameEndService
The-AhmadAA Sep 10, 2023
bdc57f9
diagrams for documentation added
The-AhmadAA Sep 10, 2023
d06551b
JUnit test for GameEndService
The-AhmadAA Sep 10, 2023
4bb07f4
removed unused gameTracking function and associated variable
The-AhmadAA Sep 10, 2023
4a95dfe
Added lose button and implemented lose screen
SonjaMcNeilly Sep 10, 2023
7f51c44
Added a display for the engineer count
nawal-0 Sep 10, 2023
a67ea57
changed display ui and implemented createButton function to avoid rep…
nawal-0 Sep 10, 2023
a52a78b
changed display sizing
nawal-0 Sep 10, 2023
12c8eb5
Merge branch 'Collab-end-game-state' of github.com:UQcsse3200/2023-st…
The-AhmadAA Sep 10, 2023
197e222
code smell fixes
The-AhmadAA Sep 10, 2023
d6868b2
merge changes from Team-5--Economy into Collab-end-game-state
The-AhmadAA Sep 10, 2023
ff68ecf
Changed display positioning to get rid of the overlap
nawal-0 Sep 11, 2023
8945c79
Implemented triggering of lose screen when engineer death limit reached
The-AhmadAA Sep 11, 2023
1d4b7b1
Merge branch 'Collab-end-game-state' of github.com:UQcsse3200/2023-st…
The-AhmadAA Sep 11, 2023
0aa5518
added function comments
nawal-0 Sep 11, 2023
35a5a3e
added setter method for engineer death limit
The-AhmadAA Sep 11, 2023
b598217
added rejection of negative engineer death limit
The-AhmadAA Sep 11, 2023
0a5af24
Merge branch 'main' into Collab-end-game-state
The-AhmadAA Sep 11, 2023
175d74f
merging main into Collab-end-game-state
The-AhmadAA Sep 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added setter method for engineer death limit
  • Loading branch information
The-AhmadAA committed Sep 11, 2023
commit 35a5a3e6a7fcbde37ee02a0b1def85c130d30c2e
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.csse3200.game.components.gamearea;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public GameEndService() {
this.display = new EngineerCountDisplay();
}

/**
* Set the engineer limit. During instantiation, limit defaults to 5.
* @param newLimit as an integer representing the maximum number of engineer deaths
*/
public void setEngineerCount(int newLimit) {
engineerCount = newLimit;
}

public int getEngineerCount() {
return engineerCount;
}
Expand All @@ -24,7 +32,6 @@ public void updateEngineerCount() {
display.updateCount();

if (engineerCount == 0) {
// loss screen
gameOver = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,53 @@
package com.csse3200.game.services;

import com.csse3200.game.extensions.GameExtension;
import com.csse3200.game.rendering.RenderService;
import com.csse3200.game.ui.UIComponent;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;

@ExtendWith(GameExtension.class)
@ExtendWith(MockitoExtension.class)
class GameEndServiceTest {

GameEndService endService;
@Mock
RenderService renderService;

@BeforeEach
void setUp() {
endService = new GameEndService();
renderService = new RenderService();
// uiComponent = spy(UIComponent.class);

ServiceLocator.registerGameEndService(endService);
ServiceLocator.registerRenderService(renderService);
}

@Test
void shouldReturnCount() {
assertEquals(5, ServiceLocator.getGameEndService().getEngineerCount());
}

// @Test
// void shouldDecrementCount() {
// ServiceLocator.getGameEndService().updateEngineerCount();
// assertEquals(4, ServiceLocator.getGameEndService().getEngineerCount());
// }
//
// @Test
// void shouldEndGame() {
// for (int i = 0; i < 5; i++) {
// ServiceLocator.getGameEndService().updateEngineerCount();
// }
// assertTrue(ServiceLocator.getGameEndService().hasGameEnded());
// }
@Test
void shouldDecrementCount() {
ServiceLocator.getGameEndService().updateEngineerCount();
assertEquals(4, ServiceLocator.getGameEndService().getEngineerCount());
}

@Test
void shouldEndGame() {
for (int i = 0; i < 5; i++) {
ServiceLocator.getGameEndService().updateEngineerCount();
}
assertTrue(ServiceLocator.getGameEndService().hasGameEnded());
}
}