mejoras de UX

This commit is contained in:
2025-08-16 18:02:16 -06:00
parent abe0d3d81f
commit c1c2a70217
3 changed files with 189 additions and 13 deletions

View File

@@ -77,18 +77,45 @@ export class GameRoom extends Room<GameState> {
// Reset to round 1 and clear decisions when variant changes
this.state.currentRound = 1;
this.state.resetRound();
// Update metadata with new variant and round (don't special-case FINISHED)
// Reset player tokens while preserving shame tokens
this.state.players.forEach((player, sessionId) => {
const currentShameTokens = player.shameTokens || 0;
if (player.role === 'P1') {
player.pavoTokens = 10;
player.eloteTokens = 0;
} else if (player.role === 'P2') {
player.pavoTokens = 0;
player.eloteTokens = 10;
}
// Preserve shame tokens
player.shameTokens = currentShameTokens;
});
// If game was finished, restart it
if (this.state.gameStatus === GameStatus.FINISHED) {
this.state.gameStatus = GameStatus.PLAYING;
}
// Update metadata with new status
const statusString = this.state.gameStatus === GameStatus.WAITING ? 'waiting' :
(this.state.gameStatus === GameStatus.PAUSED ? 'paused' :
(this.state.gameStatus === GameStatus.FINISHED ? 'finished' : 'playing'));
this.setMetadata({
gameStatus: this.state.gameStatus === GameStatus.WAITING ? 'waiting' : (this.state.gameStatus === GameStatus.PAUSED ? 'paused' : (this.state.gameStatus === GameStatus.FINISHED ? 'finished' : 'playing')),
gameStatus: statusString,
currentRound: this.state.currentRound,
currentVariant: this.state.currentVariant
});
// G2: Force offer by default
if (variant === 'G2') {
this.state.forcedByP2 = true;
}
this.broadcast("variantChanged", { variant });
this.sysChat(`🔄 Variante cambiada a ${variant}`, 'variant_change');
this.sysChat(`🔄 Variante cambiada a ${variant} - Juego reiniciado`, 'variant_change');
});
// P1 proposes a variable offer (offer -> P2, request <- from P2)