Adds name changing feature. Tweaks timing rules.

This commit is contained in:
Cam Spry committed 2026-03-02 06:07:09 -05:00
1 parent f1e9470710
commit 2f5cdbfaa7
4 files changed
+40 -18

No files matched your search

+14 -9
View File
@@ -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);
}
}