reiniciar por room, finished ya no estorba, control total desde el dashboard
This commit is contained in:
@@ -73,13 +73,9 @@ export class GameRoom extends Room<GameState> {
|
||||
// Reset to round 1 and clear decisions when variant changes
|
||||
this.state.currentRound = 1;
|
||||
this.state.resetRound();
|
||||
// Reset game status if it was finished
|
||||
if (this.state.gameStatus === GameStatus.FINISHED) {
|
||||
this.state.gameStatus = GameStatus.PLAYING;
|
||||
}
|
||||
// Update metadata with new variant and round
|
||||
// Update metadata with new variant and round (don't special-case FINISHED)
|
||||
this.setMetadata({
|
||||
gameStatus: this.state.gameStatus === GameStatus.WAITING ? 'waiting' : 'playing',
|
||||
gameStatus: this.state.gameStatus === GameStatus.WAITING ? 'waiting' : (this.state.gameStatus === GameStatus.PAUSED ? 'paused' : (this.state.gameStatus === GameStatus.FINISHED ? 'finished' : 'playing')),
|
||||
currentRound: this.state.currentRound,
|
||||
currentVariant: this.state.currentVariant
|
||||
});
|
||||
@@ -478,20 +474,6 @@ export class GameRoom extends Room<GameState> {
|
||||
});
|
||||
// Notify dashboard of game end
|
||||
broadcastDashboardUpdate();
|
||||
|
||||
// Clear UUID -> current room mapping and reconnection tokens for participants
|
||||
try {
|
||||
const { NameManager } = require("../utils/nameManager");
|
||||
const toClear: string[] = [];
|
||||
this.state.players.forEach((p) => {
|
||||
const u = (p as any)?.uuid;
|
||||
if (u) toClear.push(u);
|
||||
});
|
||||
toClear.forEach(u => {
|
||||
NameManager.getInstance().clearCurrentRoom(u);
|
||||
NameManager.getInstance().clearReconnectToken(u);
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private resolveP2Action() {
|
||||
@@ -583,12 +565,9 @@ export class GameRoom extends Room<GameState> {
|
||||
this.state.currentRound = 1;
|
||||
this.state.resetRound();
|
||||
|
||||
if (this.state.gameStatus === GameStatus.FINISHED) {
|
||||
this.state.gameStatus = GameStatus.PLAYING;
|
||||
}
|
||||
|
||||
// Update metadata without altering FINISHED status
|
||||
this.setMetadata({
|
||||
gameStatus: this.state.gameStatus === GameStatus.WAITING ? 'waiting' : 'playing',
|
||||
gameStatus: this.state.gameStatus === GameStatus.WAITING ? 'waiting' : (this.state.gameStatus === GameStatus.PAUSED ? 'paused' : (this.state.gameStatus === GameStatus.FINISHED ? 'finished' : 'playing')),
|
||||
currentRound: this.state.currentRound,
|
||||
currentVariant: this.state.currentVariant
|
||||
});
|
||||
|
||||
@@ -80,8 +80,7 @@ export class LobbyRoom extends Room<LobbyState> {
|
||||
if (currentRoomId) {
|
||||
const rooms = await matchMaker.query({ roomId: currentRoomId });
|
||||
const room = rooms[0];
|
||||
const status = room?.metadata?.gameStatus || "waiting";
|
||||
if (room && status !== "finished") {
|
||||
if (room) {
|
||||
const token = NameManager.getInstance().getReconnectToken(uuid);
|
||||
if (token) { client.send("resumeReconnection", { token }); }
|
||||
else { client.send("resumeGame", { roomId: currentRoomId }); }
|
||||
@@ -146,8 +145,7 @@ export class LobbyRoom extends Room<LobbyState> {
|
||||
if (currentRoomId) {
|
||||
const rooms = await matchMaker.query({ roomId: currentRoomId });
|
||||
const room = rooms[0];
|
||||
const status = room?.metadata?.gameStatus || "waiting";
|
||||
if (room && status !== "finished") {
|
||||
if (room) {
|
||||
const token = NameManager.getInstance().getReconnectToken(options.uuid);
|
||||
if (token) {
|
||||
client.send("resumeReconnection", { token });
|
||||
|
||||
Reference in New Issue
Block a user