shuffle players implementado correctamente
This commit is contained in:
@@ -68,6 +68,7 @@ class ColyseusService {
|
||||
} else {
|
||||
// No client-side persistence; user must confirm name once per session
|
||||
}
|
||||
// Resume request is now triggered by Lobby.vue after listeners are attached
|
||||
});
|
||||
|
||||
room.onMessage("nameUpdated", (data) => {
|
||||
@@ -186,6 +187,37 @@ class ColyseusService {
|
||||
}
|
||||
}
|
||||
|
||||
async joinShuffledGameRoom(roomId: string, role: string, playerName: string, playerColor: string): Promise<Room> {
|
||||
try {
|
||||
const uuid = this.getUuidFromPath();
|
||||
console.log(`[Colyseus] Joining shuffled room ${roomId} as ${role} with UUID ${uuid}`);
|
||||
|
||||
// Update local values
|
||||
this.playerName.value = playerName;
|
||||
this.playerColor.value = playerColor;
|
||||
|
||||
const gameRoom = await this.client.joinById(roomId, {
|
||||
playerName,
|
||||
playerColor,
|
||||
uuid,
|
||||
isShuffleJoin: true,
|
||||
role
|
||||
});
|
||||
|
||||
try { this.sessionId.value = (gameRoom as any).sessionId || this.sessionId.value; } catch {}
|
||||
this.gameRoom.value = gameRoom;
|
||||
this.currentRoom = gameRoom;
|
||||
|
||||
// Register reconnection token on server for this UUID
|
||||
try { (gameRoom as any).send("registerReconnection", (gameRoom as any).reconnectionToken || ""); } catch {}
|
||||
|
||||
return gameRoom;
|
||||
} catch (error) {
|
||||
console.error("Failed to join shuffled game room:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
sendClick(): void {
|
||||
if (this.gameRoom.value) {
|
||||
this.gameRoom.value.send("click");
|
||||
|
||||
Reference in New Issue
Block a user