Skip to content

Commit

Permalink
feat: requeue on game end
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakShearman committed Mar 10, 2024
1 parent c926092 commit 83a4ea6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
implementation("dev.emortal.minestom:game-sdk:8ef77c3")
implementation("dev.emortal.minestom:game-sdk:8bda683")
}

java {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/emortal/minestom/minesweeper/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static void main(String[] args) {
return GameSdkConfig.builder()
.minPlayers(MIN_PLAYERS)
.maxGames(MAX_GAMES)
.finishBehaviour(GameSdkConfig.FinishBehaviour.REQUEUE)
.gameCreator(info -> new MinesweeperGame(info, mapManager.createMap()))
.build();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package dev.emortal.minestom.minesweeper.game;

import dev.emortal.minestom.core.utils.KurushimiMinestomUtils;
import dev.emortal.minestom.gamesdk.config.GameCreationInfo;
import dev.emortal.minestom.gamesdk.game.Game;
import dev.emortal.minestom.gamesdk.game.GameFinishedEvent;
import dev.emortal.minestom.gamesdk.util.GameWinLoseMessages;
import dev.emortal.minestom.minesweeper.map.BoardMap;
import dev.emortal.minestom.minesweeper.map.MapManager;
Expand Down Expand Up @@ -72,13 +74,13 @@ public void win() {
Title title = Title.title(
Component.text("VICTORY!", NamedTextColor.GOLD, TextDecoration.BOLD),
Component.text(GameWinLoseMessages.randomVictory(), NamedTextColor.GRAY),
Title.Times.times(Duration.ZERO, Duration.ofSeconds(2), Duration.ofSeconds(4))
Title.Times.times(Duration.ZERO, Duration.ofSeconds(3), Duration.ofSeconds(6))
);
for (Player player : this.getPlayers()) {
player.showTitle(title);
}

this.map.instance().scheduler().buildTask(this::finish).delay(TaskSchedule.seconds(6)).schedule();
this.map.instance().scheduler().buildTask(this::finish).delay(TaskSchedule.seconds(8)).schedule();
}

public void lose() {
Expand All @@ -91,6 +93,6 @@ public void lose() {
player.showTitle(title);
}

this.map.instance().scheduler().buildTask(this::finish).delay(TaskSchedule.seconds(6)).schedule();
this.map.instance().scheduler().buildTask(this::finish).delay(TaskSchedule.seconds(4)).schedule();
}
}

0 comments on commit 83a4ea6

Please sign in to comment.