Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2950cd4
school stuff idk not done yet
ANewProfile Feb 13, 2026
16b486b
added stop on power to solo
Feb 16, 2026
2ac3e67
updating scoring in stopOnPower to 10 for correct, -5 incorrect inter…
Feb 16, 2026
79b63c3
added stop on power to mp
Feb 16, 2026
5bfb203
chore: fix formatting
Feb 16, 2026
0bbbb0c
chore: cleanup unnecessary comments
Feb 16, 2026
30d1810
Merge pull request #3 from benjiec/feature/stop-on-power
ANewProfile Feb 16, 2026
3d31035
started working on cleaning up formatting things
ANewProfile Mar 7, 2026
b9cfc1d
working on fixing formatting
ANewProfile Mar 12, 2026
80bb814
indentation fix
ANewProfile Mar 12, 2026
95b6975
finished fixing MultiplayerTossupBonusClient.js
ANewProfile Mar 12, 2026
586c8fe
minor changes
ANewProfile Mar 12, 2026
ea645d7
actually last fix to MultiplayerTossupBonusClient.js
ANewProfile Mar 12, 2026
6783f30
Update MultiplayerTossupBonusClient.js
ANewProfile Mar 12, 2026
d5339c6
indentation, just testing the PR
ANewProfile Mar 12, 2026
1374753
Finished fixing bulk of room.html
ANewProfile Mar 13, 2026
c6f9491
finished room.html
ANewProfile Mar 13, 2026
7ab29bf
final edits to room.html
ANewProfile Mar 13, 2026
fa8d651
Bulk of room.jsx
ANewProfile Mar 14, 2026
458cee3
minor fixes of room.jsx
ANewProfile Mar 14, 2026
f3536d6
bulk of SoloTossupClient.js
ANewProfile Mar 14, 2026
5187acd
minor fixes for SoloTossupClient.js
ANewProfile Mar 14, 2026
62029c3
bulk of TossupBonusClient.js
ANewProfile Mar 14, 2026
a0ca1e2
minor fixes of TossupBonusClient.js
ANewProfile Mar 14, 2026
0babc13
somewhat bulk of TossupClient.js i think
ANewProfile Mar 14, 2026
d47a3c8
bulk of TossupClient.js
ANewProfile Mar 14, 2026
ea7fb27
fix indentation and imports of TossupRoom.js
ANewProfile Mar 14, 2026
d1e3ff7
bulk of TossupRoom.js
ANewProfile Mar 14, 2026
b4b8294
minor fixes of TossupRoom.js
ANewProfile Mar 14, 2026
cbfa487
minor fixes in multiplayer
geoffrey-wu Mar 15, 2026
fd3546f
Merge branch 'main' into main
geoffrey-wu Mar 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions client/play/TossupClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const TossupClientMixin = (ClientClass) => class extends ClientClass {
case 'start-next-tossup': return this.startNextTossup(data);
case 'toggle-powermark-only': return this.togglePowermarkOnly(data);
case 'toggle-rebuzz': return this.toggleRebuzz(data);
case 'toggle-stop-on-power': return this.toggleStopOnPower(data);
case 'update-question': return this.updateQuestion(data);
default: return super.onmessage(message);
}
Expand Down Expand Up @@ -91,6 +92,10 @@ export const TossupClientMixin = (ClientClass) => class extends ClientClass {
document.getElementById('toggle-rebuzz').checked = rebuzz;
}

toggleStopOnPower ({ stopOnPower }) {
document.getElementById('toggle-stop-on-power').checked = stopOnPower;
}

updateQuestion ({ word }) {
if (word === '(*)' || word === '[*]' || word === '(+)') { return; }
document.getElementById('question').innerHTML += word + ' ';
Expand Down Expand Up @@ -129,6 +134,11 @@ function attachEventListeners (room, socket) {
this.blur();
socket.sendToServer({ type: 'toggle-rebuzz', rebuzz: this.checked });
});

document.getElementById('toggle-stop-on-power').addEventListener('click', function () {
this.blur();
socket.sendToServer({ type: 'toggle-stop-on-power', stopOnPower: this.checked });
});
}

const TossupClient = TossupClientMixin(QuestionClient);
Expand Down
7 changes: 7 additions & 0 deletions client/play/mp/MultiplayerTossupBonusClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const MultiplayerClientMixin = (ClientClass) => class extends ClientClass
case 'toggle-lock': return this.toggleLock(data);
case 'toggle-login-required': return this.toggleLoginRequired(data);
case 'toggle-public': return this.togglePublic(data);
case 'toggle-stop-on-power': return this.toggleStopOnPower(data);
default: return super.onmessage(event.data);
}
}
Expand Down Expand Up @@ -226,6 +227,7 @@ export const MultiplayerClientMixin = (ClientClass) => class extends ClientClass
this.setMode({ mode });
this.setReadingSpeed({ readingSpeed: settings.readingSpeed });
this.setStrictness({ strictness: settings.strictness });
this.toggleStopOnPower({ stopOnPower: settings.stopOnPower });

if (settings.controlled) {
this.toggleControlled({ controlled: settings.controlled });
Expand Down Expand Up @@ -744,6 +746,11 @@ export const MultiplayerClientMixin = (ClientClass) => class extends ClientClass
});
}

toggleStopOnPower ({ stopOnPower, username }) {
this.logEventConditionally(username, `${stopOnPower ? 'enabled' : 'disabled'} stop on power`);
super.toggleStopOnPower({ stopOnPower });
}

vkInit ({ targetUsername, threshold }) {
this.logEventConditionally(`A votekick has been started against user ${targetUsername} and needs ${threshold} votes to succeed.`);
}
Expand Down
4 changes: 4 additions & 0 deletions client/play/mp/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ <h1 id="funny-toast-text" class="me-auto text-danger"></h1>
<input class="form-check-input" id="toggle-rebuzz" type="checkbox" role="switch">
<label class="form-check-label" for="toggle-rebuzz">Allow rebuzzes</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" id="toggle-stop-on-power" type="checkbox" role="switch">
<label class="form-check-label" for="toggle-stop-on-power">Stop on power</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" id="toggle-skip" type="checkbox" role="switch">
<label class="form-check-label" for="toggle-skip">Allow skips</label>
Expand Down
5 changes: 5 additions & 0 deletions client/play/tossups/SoloTossupClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ export default class SoloTossupClient extends TossupClient {
window.localStorage.setItem('singleplayer-tossup-settings', JSON.stringify({ ...this.room.settings, version: settingsVersion }));
}

toggleStopOnPower ({ stopOnPower }) {
super.toggleStopOnPower({ stopOnPower });
window.localStorage.setItem('singleplayer-tossup-settings', JSON.stringify({ ...this.room.settings, version: settingsVersion }));
}

setMode ({ mode }) {
switch (mode) {
case MODE_ENUM.SET_NAME:
Expand Down
4 changes: 4 additions & 0 deletions client/play/tossups/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ <h1 id="funny-toast-text" class="me-auto text-danger"></h1>
<input class="form-check-input" id="toggle-rebuzz" type="checkbox" role="switch">
<label class="form-check-label" for="toggle-rebuzz">Allow rebuzzes</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" id="toggle-stop-on-power" type="checkbox" role="switch">
<label class="form-check-label" for="toggle-stop-on-power">Stop on power</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" id="toggle-show-history" type="checkbox" role="switch" checked>
<label class="form-check-label" for="toggle-show-history">Show question history</label>
Expand Down
1 change: 1 addition & 0 deletions client/play/tossups/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ if (window.localStorage.getItem('singleplayer-tossup-settings')) {
socket.sendToServer({ type: 'set-reading-speed', ...savedSettings });
socket.sendToServer({ type: 'toggle-ai-mode', ...savedSettings });
socket.sendToServer({ type: 'toggle-rebuzz', ...savedSettings });
socket.sendToServer({ type: 'toggle-stop-on-power', ...savedSettings });
socket.sendToServer({ type: 'toggle-timer', ...savedSettings });
socket.sendToServer({ type: 'toggle-type-to-answer', ...savedSettings });
} catch {
Expand Down
22 changes: 21 additions & 1 deletion quizbowl/TossupRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const TossupRoomMixin = (QuestionRoomClass) => class extends QuestionRoom
this.paused = false;
this.questionSplit = [];
this.tossup = {};
this.stopOnPowerEnded = false;
this.tossupProgress = TOSSUP_PROGRESS_ENUM.NOT_STARTED;
this.wordIndex = 0;

Expand All @@ -30,6 +31,7 @@ export const TossupRoomMixin = (QuestionRoomClass) => class extends QuestionRoom
this.settings = {
...this.settings,
rebuzz: false,
stopOnPower: false,
readingSpeed: 50
};

Expand All @@ -56,6 +58,7 @@ export const TossupRoomMixin = (QuestionRoomClass) => class extends QuestionRoom
case 'set-reading-speed': return this.setReadingSpeed(userId, message);
case 'toggle-powermark-only': return this.togglePowermarkOnly(userId, message);
case 'toggle-rebuzz': return this.toggleRebuzz(userId, message);
case 'toggle-stop-on-power': return this.toggleStopOnPower(userId, message);
default: return super.message(userId, message);
}
}
Expand Down Expand Up @@ -201,6 +204,17 @@ export const TossupRoomMixin = (QuestionRoomClass) => class extends QuestionRoom
}

const word = this.questionSplit[this.wordIndex];

// stop reading and start timer if power and stopOnPower is enabled
if ((word === '(*)' || word === '[*]') && this.settings.stopOnPower) {
this.stopOnPowerEnded = true;
this.startServerTimer(DEAD_TIME_LIMIT * 10,
(time) => this.emitMessage({ type: 'timer-update', timeRemaining: time }),
() => this.revealTossupAnswer()
);
return;
}

this.wordIndex++;
this.emitMessage({ type: 'update-question', word });

Expand Down Expand Up @@ -236,7 +250,7 @@ export const TossupRoomMixin = (QuestionRoomClass) => class extends QuestionRoom

scoreTossup ({ givenAnswer }) {
const celerity = this.questionSplit.slice(this.wordIndex).join(' ').length / this.tossup.question.length;
const endOfQuestion = (this.wordIndex === this.questionSplit.length);
const endOfQuestion = this.settings.stopOnPower ? this.stopOnPowerEnded : (this.wordIndex === this.questionSplit.length);
const superpowerIndex = this.questionSplit.indexOf('(+)');
const powerIndex = Math.max(this.questionSplit.indexOf('(*)'), this.questionSplit.indexOf('[*]'));
const inSuperpower = superpowerIndex !== -1 && superpowerIndex >= this.wordIndex;
Expand Down Expand Up @@ -296,6 +310,12 @@ export const TossupRoomMixin = (QuestionRoomClass) => class extends QuestionRoom
const username = this.players[userId]?.username;
this.emitMessage({ type: 'toggle-rebuzz', rebuzz, username });
}

toggleStopOnPower (userId, { stopOnPower }) {
this.settings.stopOnPower = stopOnPower;
const username = this.players[userId].username;
this.emitMessage({ type: 'toggle-stop-on-power', stopOnPower, username });
}
};

const TossupRoom = TossupRoomMixin(QuestionRoom);
Expand Down