Minor fixes to capitalization, 2026 -> HTML5 naming

This commit is contained in:
Cam Spry 2026-03-02 01:44:39 -05:00
parent c87654ed7c
commit a65607b054
3 changed files with 44 additions and 23 deletions

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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> <style>
:root { :root {
--bg-main: #4b0082; --bg-main: #4b0082;
@ -332,7 +332,7 @@
<div id="layout"> <div id="layout">
<div id="header"> <div id="header">
Y.A.R.N. 2026 - Spin a story! -&nbsp;<span id="room-display"></span> Y.A.R.N. HTML5 - Spin a Story! -&nbsp;<span id="room-display"></span>
</div> </div>
<div id="main-text"> <div id="main-text">

View File

@ -128,7 +128,7 @@
<div id="about-overlay" class="hidden"> <div id="about-overlay" class="hidden">
<div id="about-box"> <div id="about-box">
<h3>What is Y.A.R.N HTML5?</h3> <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>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> <p><strong>The rules are simple:</strong></p>
<ul> <ul>

View File

@ -214,29 +214,50 @@ class YarnGame {
tallyVotes() { tallyVotes() {
if (this.round_data.length === 0) return null; if (this.round_data.length === 0) return null;
// Find winner (most votes) // 1. Award 1 point per vote to every sentence
let winner = this.round_data[0];
for (const entry of this.round_data) { for (const entry of this.round_data) {
if (entry.votes.length > winner.votes.length) { const p = this.getPlayer(entry.player_id);
winner = entry; 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 // 4. Append winning (or tied-longest) entry to the story
const winnerPlayer = this.getPlayer(winner.player_id); const storyEntry =
if (winnerPlayer) { leaders.length === 1
winnerPlayer.score += 5 + winner.votes.length; ? leaders[0]
} : leaders.reduce(
(a, b) => (b.entry_text.length > a.entry_text.length ? b : a),
// Add to story leaders[0]
if (winner.entry_text) { );
if (storyEntry?.entry_text) {
this.yarnStory.push({ this.yarnStory.push({
player: winnerPlayer ? winnerPlayer.name : "Unknown", player: this.getPlayer(storyEntry.player_id)?.name ?? "Unknown",
str: winner.entry_text str: storyEntry.entry_text
}); });
} }
return winner; return leaders.length === 1 ? leaders[0] : null; // return single winner or null on tie
} }
checkGameOver() { checkGameOver() {
@ -421,8 +442,8 @@ io.on('connection', (socket) => {
const game = games[currentRoom]; const game = games[currentRoom];
if (!game || game.gameHost !== playerId) return; if (!game || game.gameHost !== playerId) return;
if (game.players.length < 2 && settings.botCount == 0) { if ((game.players.length + settings.botCount) < 3) {
socket.emit('error', { message: 'Need at least 2 players to start' }); socket.emit('error', { message: 'Need at least 3 players to start' });
return; return;
} }