diff --git a/public/index.html b/public/index.html
index 9693a3f..2b9263c 100644
--- a/public/index.html
+++ b/public/index.html
@@ -332,7 +332,7 @@
@@ -370,7 +370,7 @@
// Get room name from URL
const pathParts = window.location.pathname.split('/').filter(p => p);
const roomName = pathParts[0] || 'default';
- document.getElementById('room-display').textContent = ` — Room: ${roomName}`;
+ document.getElementById('room-display').textContent = `Room: ${roomName}`;
// Get or create player UUID
let playerUUID = getCookie('yarn_player_uuid');
@@ -746,12 +746,12 @@
}
function startGame() {
- const scoreLimit = parseInt(document.getElementById('score-limit').value) || 25;
+ const scoreLimit = parseInt(document.getElementById('score-limit').value) || 100;
const timeLimit = parseInt(document.getElementById('time-limit').value) || 60;
socket.emit('startGame', {
- scoreLimit: Math.max(10, Math.min(100, scoreLimit)),
- timeLimit: Math.max(15, Math.min(180, timeLimit))
+ scoreLimit: Math.max(10, Math.min(9999, scoreLimit)),
+ timeLimit: Math.max(15, Math.min(600, timeLimit))
});
}
diff --git a/server.js b/server.js
index f85ef00..115173a 100644
--- a/server.js
+++ b/server.js
@@ -23,10 +23,12 @@ class YarnGame {
this.inProgress = false;
this.gameHost = null;
this.gameSettings = {
- scoreLimit: 25,
- timeLimit: 60
+ scoreLimit: 50,
+ timeLimit: 60,
+ botCount: 0
};
this.players = []; // { player_id, name, score, socketId }
+ this.disconnectedPlayers = []; // So people can keep their score when they reconnect
this.yarnStory = []; // { player: "", str: "" }
this.chat = []; // { id, name, msg }
this.round_data = []; // { entry_text, player_id, votes: [] }
@@ -42,7 +44,19 @@ class YarnGame {
if (existingPlayer) {
existingPlayer.socketId = socketId;
existingPlayer.name = name;
+ console.log(`Existing player ${name} reconnected to game ${this.roomName}.`)
return existingPlayer;
+ } else {
+ console.log(`New player ${name} joined game ${this.roomName}.`)
+ }
+
+ const existingDisconnectedPlayer = this.disconnectedPlayers.find(p => p.player_id === playerId);
+ if (existingDisconnectedPlayer) {
+ existingDisconnectedPlayer.socketId = socketId;
+ existingDisconnectedPlayer.name = name;
+ this.players.push(existingDisconnectedPlayer);
+ console.log(`Existing recently-disconnected player ${name} reconnected to game ${this.roomName}.`)
+ return existingDisconnectedPlayer;
}
const player = {
@@ -64,13 +78,17 @@ class YarnGame {
removePlayer(playerId) {
const index = this.players.findIndex(p => p.player_id === playerId);
if (index !== -1) {
- this.players.splice(index, 1);
+ const removed = this.players.splice(index, 1);
+ this.disconnectedPlayers.push(removed[0]);
// Assign new host if host left
if (this.gameHost === playerId && this.players.length > 0) {
this.gameHost = this.players[0].player_id;
}
}
+ if (this.players.length > 0) {
+ console.log(`Player ${this.players[index].name} dropped.`)
+ }
return this.players.length;
}
@@ -241,6 +259,7 @@ class YarnGame {
// Get or create a game room
function getOrCreateGame(roomName) {
if (!games[roomName]) {
+ console.log(`Creating new room with name ${roomName}`)
games[roomName] = new YarnGame(roomName);
}
return games[roomName];
@@ -317,6 +336,7 @@ io.on('connection', (socket) => {
return;
}
+ console.log(`Starting new game with settings ${JSON.stringify(settings)}`)
game.startGame(settings);
io.to(currentRoom).emit('gameStarted', game.getState());
@@ -403,6 +423,7 @@ io.on('connection', (socket) => {
io.to(currentRoom).emit('gameState', game.getState());
// Clean up empty rooms
+ console.log(`Removing empty room ${currentRoom}`)
if (remaining === 0) {
if (game.timer) clearInterval(game.timer);
delete games[currentRoom];