Minor fixes to capitalization, 2026 -> HTML5 naming
This commit is contained in:
parent
c87654ed7c
commit
a65607b054
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>YARN 2026 – Spin a Story!</title>
|
||||
<title>Y.A.R.N. HTML5 – Spin a Story!</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg-main: #4b0082;
|
||||
|
|
@ -332,7 +332,7 @@
|
|||
<div id="layout">
|
||||
|
||||
<div id="header">
|
||||
Y.A.R.N. 2026 - Spin a story! - <span id="room-display"></span>
|
||||
Y.A.R.N. HTML5 - Spin a Story! - <span id="room-display"></span>
|
||||
</div>
|
||||
|
||||
<div id="main-text">
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@
|
|||
<div id="about-overlay" class="hidden">
|
||||
<div id="about-box">
|
||||
<h3>What is Y.A.R.N HTML5?</h3>
|
||||
<p>Y.A.R.N 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.</p>
|
||||
<p>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.</p>
|
||||
<p><strong>Y.A.R.N. HTML5</strong> 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.</p>
|
||||
<p><strong>The rules are simple:</strong></p>
|
||||
<ul>
|
||||
|
|
|
|||
61
server.js
61
server.js
|
|
@ -213,30 +213,51 @@ class YarnGame {
|
|||
|
||||
tallyVotes() {
|
||||
if (this.round_data.length === 0) return null;
|
||||
|
||||
// Find winner (most votes)
|
||||
let winner = this.round_data[0];
|
||||
|
||||
// 1. Award 1 point per vote to every sentence
|
||||
for (const entry of this.round_data) {
|
||||
if (entry.votes.length > winner.votes.length) {
|
||||
winner = entry;
|
||||
const p = this.getPlayer(entry.player_id);
|
||||
if (p) p.score += entry.votes.length;
|
||||
}
|
||||
|
||||
// 2. Find the top vote count
|
||||
const maxVotes = Math.max(...this.round_data.map(e => e.votes.length));
|
||||
const leaders = this.round_data.filter(e => e.votes.length === maxVotes);
|
||||
|
||||
// 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;
|
||||
} else {
|
||||
// Tie: longest gets +2, rest +1
|
||||
const longest = leaders.reduce(
|
||||
(a, b) => (b.entry_text.length > a.entry_text.length ? b : a),
|
||||
leaders[0]
|
||||
);
|
||||
for (const l of leaders) {
|
||||
const p = this.getPlayer(l.player_id);
|
||||
if (p) p.score += l === longest ? 2 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Award points
|
||||
const winnerPlayer = this.getPlayer(winner.player_id);
|
||||
if (winnerPlayer) {
|
||||
winnerPlayer.score += 5 + winner.votes.length;
|
||||
}
|
||||
|
||||
// Add to story
|
||||
if (winner.entry_text) {
|
||||
|
||||
// 4. Append winning (or tied-longest) entry to the story
|
||||
const storyEntry =
|
||||
leaders.length === 1
|
||||
? leaders[0]
|
||||
: leaders.reduce(
|
||||
(a, b) => (b.entry_text.length > a.entry_text.length ? b : a),
|
||||
leaders[0]
|
||||
);
|
||||
if (storyEntry?.entry_text) {
|
||||
this.yarnStory.push({
|
||||
player: winnerPlayer ? winnerPlayer.name : "Unknown",
|
||||
str: winner.entry_text
|
||||
player: this.getPlayer(storyEntry.player_id)?.name ?? "Unknown",
|
||||
str: storyEntry.entry_text
|
||||
});
|
||||
}
|
||||
|
||||
return winner;
|
||||
|
||||
return leaders.length === 1 ? leaders[0] : null; // return single winner or null on tie
|
||||
}
|
||||
|
||||
checkGameOver() {
|
||||
|
|
@ -421,8 +442,8 @@ io.on('connection', (socket) => {
|
|||
|
||||
const game = games[currentRoom];
|
||||
if (!game || game.gameHost !== playerId) return;
|
||||
if (game.players.length < 2 && settings.botCount == 0) {
|
||||
socket.emit('error', { message: 'Need at least 2 players to start' });
|
||||
if ((game.players.length + settings.botCount) < 3) {
|
||||
socket.emit('error', { message: 'Need at least 3 players to start' });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue