Skip to content

Commit

Permalink
feat: ゲーム終了後に結果発表をするように
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtakagi committed Sep 26, 2022
1 parent c98cd4b commit 5c12225
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/main/java/net/iamtakagi/pesce/PesceGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
import java.util.UUID;
import java.util.logging.Level;

import static net.iamtakagi.pesce.Pesce.broadcast;
import static net.iamtakagi.pesce.Pesce.log;
import static net.iamtakagi.pesce.Pesce.*;
import static net.iamtakagi.pesce.PesceConfig.CONFIG_YAML_DEST;
import static net.iamtakagi.pesce.PesceConfig.loadYamlConfig;

Expand Down Expand Up @@ -91,7 +90,7 @@ public PesceGame() {
// ゲームプロセス初期化
process = new GameProcess();
// プレイヤーリスト初期化
players = new LinkedList<>();
players = new LinkedList<>();
}

public PesceGame init() {
Expand Down Expand Up @@ -219,6 +218,20 @@ public void onStartState() {
if(state == GameState.ENDGAME) {
seconds = PesceGameConfig.getEndgameSeconds();
broadcast("ゲーム終了!");
// 昇順ソート
players.sort((o1, o2) -> o1.getCatches() > o2.getCatches() ? -1 : 1);
// 結果発表
StringBuilder sb = new StringBuilder()
.append(Style.HORIZONTAL_SEPARATOR).append("\n")
.append(Style.AQUA + Style.BOLD + "結果発表!").append("\n");
players.forEach(gamePlayer -> {
Player bukkitPlayer = Bukkit.getPlayer(gamePlayer.getUuid());
if(bukkitPlayer != null) {
sb.append(Style.GRAY + bukkitPlayer.getName() + ": " + Style.WHITE + gamePlayer.getCatches() + "匹").append("\n");
}
});
sb.append(Style.HORIZONTAL_SEPARATOR);
broadcastWithoutPrefix(sb.toString());
Bukkit.getOnlinePlayers().forEach(player -> {
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);
});
Expand Down

0 comments on commit 5c12225

Please sign in to comment.