Skip to content

Commit c4de7c2

Browse files
committed
chore(game): improve parameter usage
1 parent 04c592c commit c4de7c2

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

game/src/main/java/net/onelitefeather/cygnus/Cygnus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private void initPhases() {
165165
gameMapProvider.getGameMap(),
166166
gameMapProvider.getActiveInstance().get()
167167
);
168-
LobbyPhase lobbyPhase = new LobbyPhase(gameMapLoader, staminaInitializer, this.gameConfig.lobbyTime(), this.gameConfig.minPlayers());
168+
LobbyPhase lobbyPhase = new LobbyPhase(gameMapLoader, staminaInitializer, this.gameConfig);
169169
this.linearPhaseSeries.add(lobbyPhase);
170170
this.linearPhaseSeries.add(new WaitingPhase(this.view, instanceSwitch, teamInitializer));
171171
this.linearPhaseSeries.add(new GamePhase(this.view, this::finishGame, this.gameConfig.gameTime()));

game/src/main/java/net/onelitefeather/cygnus/phase/LobbyPhase.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.onelitefeather.cygnus.phase;
22

3+
import net.onelitefeather.cygnus.common.config.GameConfig;
34
import net.theevilreaper.aves.util.functional.VoidConsumer;
45
import net.theevilreaper.xerus.api.phase.TickDirection;
56
import net.theevilreaper.xerus.api.phase.TimedPhase;
@@ -15,10 +16,23 @@
1516
import static net.onelitefeather.cygnus.common.config.GameConfig.FORCE_START_TIME;
1617

1718
/**
19+
* Represents the lobby phase of the game.
20+
*
21+
* <p>During this phase the game waits until enough players joined to start the
22+
* match countdown. The phase updates the player level and experience bar to
23+
* visualize the remaining time until the game starts.</p>
24+
*
25+
* <p>The phase can be paused automatically if the required player count is not
26+
* reached anymore. It also supports force starting the game with a reduced
27+
* countdown duration.</p>
28+
*
29+
* <p>While the countdown is running, the game map loading and stamina
30+
* initialization are triggered at specific countdown timestamps.</p>
31+
*
1832
* @author theEvilReaper
1933
* @version 1.0.0
2034
* @since 1.0.0
21-
**/
35+
*/
2236
public final class LobbyPhase extends TimedPhase {
2337

2438
private static final ConnectionManager CONNECTION_MANAGER = MinecraftServer.getConnectionManager();
@@ -33,14 +47,13 @@ public final class LobbyPhase extends TimedPhase {
3347
public LobbyPhase(
3448
VoidConsumer gameMapLoading,
3549
VoidConsumer staminaInstantiation,
36-
int lobbyTime,
37-
int minPlayers
50+
GameConfig gameConfig
3851
) {
3952
super("Lobby", ChronoUnit.SECONDS, 1);
4053
this.gameMapLoading = gameMapLoading;
4154
this.staminaInstantiation = staminaInstantiation;
42-
this.lobbyTime = lobbyTime;
43-
this.minPlayers = minPlayers;
55+
this.lobbyTime = gameConfig.lobbyTime();
56+
this.minPlayers = gameConfig.minPlayers();
4457
this.setPaused(true);
4558
this.setCurrentTicks(lobbyTime);
4659
this.setTickDirection(TickDirection.DOWN);

0 commit comments

Comments
 (0)