refactor: extracted UpdateTimer method

This commit is contained in:
Yannik Bretschneider 2021-06-06 00:39:15 +02:00
parent 4e66a4eb24
commit 6a8de34c67
2 changed files with 7 additions and 6 deletions

View File

@ -92,11 +92,11 @@ public class Lobby {
badRequests = 0; badRequests = 0;
} }
updateTimer(game.state.getActiveCharacter().type); updateTimer();
} }
void updateTimer(EntityType currentActiveCharacterType) { void updateTimer() {
var currentActiveCharacterType = game.state.getActiveCharacter().type;
if (pauseSegment.isPaused()) { if (pauseSegment.isPaused()) {
turnTimer.clear(); turnTimer.clear();
} else if (currentActiveCharacterType == EntityType.P1) { } else if (currentActiveCharacterType == EntityType.P1) {

View File

@ -35,13 +35,13 @@ class LobbyTest {
}; };
var characterConfig = mock(CharacterConfig.class); var characterConfig = mock(CharacterConfig.class);
lobby = new Lobby( lobby = spy(new Lobby(
gameID, gameID,
connection, connection,
partyConfig, partyConfig,
characterConfig, characterConfig,
scenarioConfig scenarioConfig
); ));
} }
@Test @Test
@ -51,9 +51,10 @@ class LobbyTest {
new RequestBuilder(RequestType.MoveRequest).buildGameRequest() new RequestBuilder(RequestType.MoveRequest).buildGameRequest()
}; };
var playerConnection = mock(WebSocket.class); var playerConnection = mock(WebSocket.class);
doNothing().when(lobby).updateTimer();
Participant playerOne = new Participant(playerConnection, ParticipantType.PlayerOne, "P1"); Participant playerOne = new Participant(playerConnection, ParticipantType.PlayerOne, "P1");
lobby.receiveRequests(requests, playerOne); lobby.receiveRequests(requests, playerOne);
} }
} }