@@ -789,6 +791,21 @@
updateGameBar();
}
+ // === Header Functions ===
+
+ document.getElementById('change-name-btn').addEventListener('click', () => {
+ const newName = prompt('Enter a new name (1-20 characters):', playerName);
+ if (newName && newName.trim() && newName.trim() !== playerName) {
+ socket.emit('setName', { name: newName.trim() });
+ }
+ });
+
+ document.getElementById('leave-game-btn').addEventListener('click', () => {
+ if (confirm('Are you sure you want to leave the game?')) {
+ window.location.href = '/';
+ }
+ });
+
// === Chat Functions ===
document.getElementById('chat-input').addEventListener('keypress', function(e) {
diff --git a/public/images/yarnlogo.png b/public/images/yarnlogo.png
new file mode 100644
index 0000000..9b88dbe
Binary files /dev/null and b/public/images/yarnlogo.png differ
diff --git a/public/menu.html b/public/menu.html
index 0867b57..2c263fa 100644
--- a/public/menu.html
+++ b/public/menu.html
@@ -3,7 +3,7 @@
-
+
Y.A.R.N. HTML5
@@ -104,8 +104,8 @@
-
Y.A.R.N.
-
HTML5 Edition
+

+
HTML5 Edition
@@ -127,14 +127,14 @@
-
What is Y.A.R.N HTML5?
-
Y.A.R.N (Yet Another Random Narrative) was a collaborative story-writing "parlor game" originally included in GameSpy Arcade in the early 2000s, but removed shortly thereafter due to security issues that were never resolved.
+
What is Y.A.R.N. HTML5?
+
Y.A.R.N. (Yet Another Random Narrative) was a collaborative story-writing "parlor game" originally included in GameSpy Arcade in the early 2000s, but removed shortly thereafter due to security issues that were never resolved.
Y.A.R.N. HTML5 is a modern remake of (what I can remember from) the original, designed to run in-browser, and with extra features such as (optional) LLM-based bots.
-
The rules are simple:
-
+ The rules are simple:
+
- Players have a limited amount of time to write a sentence, selected by the host at game start.
- Once all players have submitted their sentences, players have 30 seconds to vote for their favorite.
- - The player whose sentence is chosen receives 3 bonus points, and all players receive one point for each vote they received.
+ - All players receive one point for each vote their sentence receives. The player whose sentence receives the most votes is awarded 3 bonus points.
- In the case of a tie, the longest sentence receives two extra points and the other sentences tied receive 1 point each.
- When a player reaches the point limit, they win the game.
diff --git a/server.js b/server.js
index 8c79d8c..0c21469 100644
--- a/server.js
+++ b/server.js
@@ -200,8 +200,9 @@ class YarnGame {
async startVotingPhase() {
this.currentPhase = 'voting';
this.votedPlayers = new Set();
- this.timeRemaining = 30; // 30 seconds for voting
- await this.processBotVoting()
+ const entriesCount = this.round_data.length
+ this.timeRemaining = 10 * entriesCount; // 10 seconds * num of entries for voting
+ this.processBotVoting()
}
submitVote(playerId, entryIndex) {
@@ -226,10 +227,17 @@ class YarnGame {
tallyVotes() {
if (this.round_data.length === 0) return null;
+ // ----- helper to award points, possibly doubled -----
+ const givePoints = (player, pts) => {
+ if (!player) return;
+ const multiplier =
+ this.currentRound + 1 === this.gameSettings.roundLimit ? 2 : 1;
+ player.score += pts * multiplier;
+ };
+
// 1. Award 1 point per vote to every sentence
for (const entry of this.round_data) {
- const p = this.getPlayer(entry.player_id);
- if (p) p.score += entry.votes.length;
+ givePoints(this.getPlayer(entry.player_id), entry.votes.length);
}
// 2. Find the top vote count
@@ -239,9 +247,7 @@ class YarnGame {
// 3. Decide bonus points
if (leaders.length === 1) {
// Single winner: +3
- const winner = leaders[0];
- const p = this.getPlayer(winner.player_id);
- if (p) p.score += 3;
+ givePoints(this.getPlayer(leaders[0].player_id), 3);
} else {
// Tie: longest gets +2, rest +1
const longest = leaders.reduce(
@@ -249,8 +255,7 @@ class YarnGame {
leaders[0]
);
for (const l of leaders) {
- const p = this.getPlayer(l.player_id);
- if (p) p.score += l === longest ? 2 : 1;
+ givePoints(this.getPlayer(l.player_id), l === longest ? 2 : 1);
}
}