Complete Stage 1: Core Game Loop
- Add GameState enum (LOBBY, ROLE_ASSIGN, IN_GAME, ENDING) - Add Phase interface with enter/tick/exit/isComplete - Add GameSession with tick-based phase machine - Add GameEventBus for internal events - Add GameManager for session lifecycle - Add all phases: LobbyPhase, RoleAssignPhase, GameplayPhase, EndgamePhase - Add role assignment: RoleAssigner, RoleQueue, SpawnPosition - Add BasePlayer, Survivor, Killer, PlayerState - Add DBDCommand with /dbd join/leave/create/forcestart/stop - Update mdbd.java with GameManager and command registration - Add command definition to paper-plugin.yml - Mark Stage 1 complete in PLAN.md
This commit is contained in:
parent
53f3f6e9da
commit
82ed455cd2
20 changed files with 884 additions and 8 deletions
74
src/main/java/dev/loki/phase/LobbyPhase.java
Normal file
74
src/main/java/dev/loki/phase/LobbyPhase.java
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
package dev.loki.phase;
|
||||
|
||||
import dev.loki.config.GameConfig;
|
||||
import dev.loki.core.GameSession;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class LobbyPhase implements Phase {
|
||||
private final GameConfig config;
|
||||
private int countdown;
|
||||
private int secondsLeft;
|
||||
private boolean started;
|
||||
|
||||
public LobbyPhase(GameConfig config) {
|
||||
this.config = config;
|
||||
this.secondsLeft = config.getLobbyCountdown();
|
||||
this.countdown = 0;
|
||||
this.started = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter(GameSession session) {
|
||||
Bukkit.broadcast(Component.text("[DBD] Лобби открыто! Используйте /dbd join", NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(GameSession session) {
|
||||
int playerCount = session.getPlayerCount();
|
||||
int minPlayers = config.getMinPlayers();
|
||||
|
||||
if (playerCount < minPlayers) {
|
||||
secondsLeft = config.getLobbyCountdown();
|
||||
countdown = 0;
|
||||
started = false;
|
||||
return;
|
||||
}
|
||||
|
||||
countdown++;
|
||||
if (countdown >= 20) {
|
||||
countdown = 0;
|
||||
secondsLeft--;
|
||||
|
||||
if (secondsLeft <= 5 || secondsLeft % 10 == 0) {
|
||||
Bukkit.broadcast(Component.text(
|
||||
"[DBD] До начала: " + secondsLeft + " сек. (" + playerCount + "/" + minPlayers + ")",
|
||||
NamedTextColor.YELLOW));
|
||||
}
|
||||
}
|
||||
|
||||
if (secondsLeft <= 0) {
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit(GameSession session) {
|
||||
Bukkit.broadcast(Component.text("[DBD] Игра начинается!", NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return started;
|
||||
}
|
||||
|
||||
public void forceStart() {
|
||||
secondsLeft = 0;
|
||||
started = true;
|
||||
}
|
||||
|
||||
public int getSecondsLeft() {
|
||||
return secondsLeft;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue