Connect game phases, implement gameplay, add lobby commands, remove perks
- Fix GameSession.determineNextPhase() to cycle through all 4 phases - Implement GameplayPhase with generator tracking and win/lose conditions - MapBuilder now uses the game world instead of the first world - Add /dbd lobby (teleport to lobby) and /dbd setlobby (set lobby spawn) - Remove all perk classes (IPerk, PerkRegistry, 7 perk implementations) - Fix HexTotem to not reference removed HexRuinPerk
This commit is contained in:
parent
34e0aebd5d
commit
d0ed8a5fe7
18 changed files with 132 additions and 808 deletions
|
|
@ -1,36 +1,92 @@
|
|||
package dev.loki.phase;
|
||||
|
||||
import dev.loki.core.GameSession;
|
||||
import dev.loki.objective.Generator;
|
||||
import dev.loki.objective.GeneratorManager;
|
||||
import dev.loki.player.BasePlayer;
|
||||
import dev.loki.player.PlayerState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GameplayPhase implements Phase {
|
||||
private int gameTicks;
|
||||
private final GeneratorManager generatorManager;
|
||||
private int tickCounter;
|
||||
private boolean shouldEnd;
|
||||
private boolean allGensDone;
|
||||
|
||||
public GameplayPhase(GeneratorManager generatorManager) {
|
||||
this.generatorManager = generatorManager;
|
||||
this.tickCounter = 0;
|
||||
this.shouldEnd = false;
|
||||
this.allGensDone = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter(GameSession session) {
|
||||
Bukkit.broadcastMessage("[DBD] Игра началась! Выжившие, чините генераторы!");
|
||||
gameTicks = 0;
|
||||
shouldEnd = false;
|
||||
tickCounter = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(GameSession session) {
|
||||
gameTicks++;
|
||||
// TODO: Check endgame conditions
|
||||
tickCounter++;
|
||||
|
||||
generatorManager.tick();
|
||||
|
||||
if (tickCounter % 20 == 0) {
|
||||
checkGeneratorProgress(session);
|
||||
checkWinConditions(session);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGeneratorProgress(GameSession session) {
|
||||
if (allGensDone) return;
|
||||
|
||||
if (generatorManager.areAllRequiredCompleted()) {
|
||||
allGensDone = true;
|
||||
Bukkit.broadcastMessage("[DBD] §a§lВсе генераторы починены! Открывайте ворота!");
|
||||
for (BasePlayer bp : session.getPlayers().values()) {
|
||||
Player p = bp.getPlayer();
|
||||
if (p != null) {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkWinConditions(GameSession session) {
|
||||
int aliveSurvivors = 0;
|
||||
int escapedSurvivors = 0;
|
||||
boolean killerDead = true;
|
||||
|
||||
for (BasePlayer bp : session.getPlayers().values()) {
|
||||
if (bp.isKiller()) {
|
||||
killerDead = false;
|
||||
continue;
|
||||
}
|
||||
PlayerState state = bp.getState();
|
||||
if (state == PlayerState.ESCAPED) {
|
||||
escapedSurvivors++;
|
||||
} else if (state != PlayerState.DEAD && state != PlayerState.HOOKED) {
|
||||
aliveSurvivors++;
|
||||
}
|
||||
}
|
||||
|
||||
boolean allSurvivorsDead = (aliveSurvivors == 0 && escapedSurvivors == 0);
|
||||
|
||||
if (allSurvivorsDead || escapedSurvivors == session.getPlayerCount() - 1) {
|
||||
shouldEnd = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit(GameSession session) {
|
||||
Bukkit.broadcastMessage("[DBD] Игра завершена!");
|
||||
Bukkit.broadcastMessage("[DBD] §6Игровая фаза завершена!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return shouldEnd;
|
||||
}
|
||||
|
||||
public void forceEnd() {
|
||||
shouldEnd = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue