implementado funcionmiento turn-based g2 flujo de forzar o no forzar

This commit is contained in:
2025-08-27 17:54:51 -06:00
parent 48046a794e
commit 80af7461a4
5 changed files with 60 additions and 41 deletions

View File

@@ -110,9 +110,10 @@ export class GameRoom extends Room<GameState> {
currentVariant: this.state.currentVariant
});
// G2: Force offer by default
// G2: start next round awaiting P2 decision, not forced by default
if (variant === 'G2') {
this.state.forcedByP2 = true;
this.state.g2ForcePending = true;
this.state.forcedByP2 = false;
}
this.broadcast("variantChanged", { variant });
this.sysChat(`🔄 Variante cambiada a ${variant} - Juego reiniciado`, 'variant_change');
@@ -171,7 +172,13 @@ export class GameRoom extends Room<GameState> {
if (!player) return;
if (player.role !== "P2") return;
this.state.forcedByP2 = !!force;
this.state.g2ForcePending = false;
// When forced, P1 must propose an offer; nothing automatic here.
// System chat feedback and dashboard update
if (this.state.currentVariant === 'G2') {
if (force) this.sysChat('📌 P2 decidió forzar a P1 a ofrecer', 'p2_force');
else this.sysChat('🕊️ P2 decidió no forzar a P1', 'p2_no_force');
}
});
// System chat helper moved to class method this.sysChat
@@ -481,9 +488,10 @@ export class GameRoom extends Room<GameState> {
currentRound: this.state.currentRound,
currentVariant: this.state.currentVariant
});
// G2: Force offer by default when starting game
// G2: awaiting P2 decision at round start (not forced by default)
if (this.state.currentVariant === 'G2') {
this.state.forcedByP2 = true;
this.state.g2ForcePending = true;
this.state.forcedByP2 = false;
}
this.broadcast("gameStart");
// System chat: start at round 1
@@ -651,7 +659,8 @@ export class GameRoom extends Room<GameState> {
});
if (variant === 'G2') {
this.state.forcedByP2 = true;
this.state.g2ForcePending = true;
this.state.forcedByP2 = false;
}
this.broadcast("variantChanged", { variant });

View File

@@ -22,6 +22,7 @@ export class GameState extends Schema {
@type("string") p1Action: string = ""; // no_offer|"" (variable offers handled via fields below)
@type("string") p2Action: string = ""; // accept|reject|snatch
@type("boolean") forcedByP2: boolean = false; // G2
@type("boolean") g2ForcePending: boolean = false; // G2: awaiting P2 decision at round start
@type("boolean") reported: boolean = false; // G4
@type("boolean") shameAssigned: boolean = false; // G3
@@ -120,7 +121,9 @@ export class GameState extends Schema {
resetRound(): void {
this.p1Action = "";
this.p2Action = "";
this.forcedByP2 = (this.currentVariant === "G2");
// In G2, start each round awaiting P2's force decision; do not force by default
this.g2ForcePending = (this.currentVariant === "G2");
this.forcedByP2 = false;
this.reported = false;
this.shameAssigned = false;
this.offerPavo = this.offerElote = 0;