From db67800833611baddbd4bbb1e5d7a127ee1806a5 Mon Sep 17 00:00:00 2001
From: Ba3henov <46943437+Ba3henov@users.noreply.github.com>
Date: Tue, 20 Jan 2026 08:14:35 -0800
Subject: [PATCH 1/4] Update buttonEventListeners2.js
Refactor redButtonFunction and greenButtonFunction to be async and handle button state more effectively. Introduce preventMisclick function for better user interaction.
---
assets/scripts/lobby/buttonEventListeners2.js | 193 ++++++++++--------
1 file changed, 112 insertions(+), 81 deletions(-)
diff --git a/assets/scripts/lobby/buttonEventListeners2.js b/assets/scripts/lobby/buttonEventListeners2.js
index 9a48530e4..b623de4fd 100644
--- a/assets/scripts/lobby/buttonEventListeners2.js
+++ b/assets/scripts/lobby/buttonEventListeners2.js
@@ -1,93 +1,79 @@
-function redButtonFunction() {
- console.log('red');
- // if the button isn't disabled
- if (
- document.querySelector('#red-button').classList.contains('disabled') ===
- false
- ) {
- if (isSpectator === true) {
- } else if (gameStarted === false) {
- // if we are spectating
- if (document.querySelector('#red-button').innerText === 'Spectate') {
- socket.emit('standUpFromGame');
- // remove claim status when a player sits down
- // then stands up
- socket.emit('setClaim', false);
-
- enableDisableButtons();
- }
- // we are the host, open kick menu
- else {
- // host kicking
- // Set the kick modal content
- let str = '
Select the players you want to kick.
';
-
- str += '';
+ $('#kickModalContent')[0].innerHTML = str;
}
- $('#mainRoomBox div').removeClass('highlight-avatar');
+ } else if (
+ gameData.phase === 'VotingTeam' &&
+ !(await preventMisclick('no'))
+ ) {
+ socket.emit('gameMove', ['no', []]);
+ } else if (gameData.phase === 'VotingMission') {
+ socket.emit('gameMove', ['no', []]);
}
+
+ $('#mainRoomBox div').removeClass('highlight-avatar');
}
-function greenButtonFunction() {
- // if button isn't disabled:
- if (
- document.querySelector('#green-button').classList.contains('disabled') ===
- false
- ) {
- if (isSpectator === true) {
- socket.emit('join-game', roomId);
- } else if (gameStarted === false) {
- const startGameData = {
- options: getOptions(),
- gameMode: $($('.gameModeSelect')[1]).val(),
- timeouts: {
- default: ((parseInt($('#startGameOptionsDefaultPhaseTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsDefaultPhaseTimeoutSec').val())) * 1000).toString(),
- critMission: ((parseInt($('#startGameOptionsCritMissionTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsCritMissionTimeoutSec').val())) * 1000).toString(),
- assassination: ((parseInt($('#startGameOptionsAssassinationPhaseTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsAssassinationPhaseTimeoutSec').val())) * 1000).toString(),
- },
- anonymousMode: $('#startGameOptionsAnonymousMode')[0].checked,
- };
-
- socket.emit('startGame', startGameData);
- } else if (
- gameData.phase === 'VotingTeam' ||
- gameData.phase === 'VotingMission'
- ) {
- socket.emit('gameMove', ['yes', []]);
- } else {
- socket.emit('gameMove', ['yes', getHighlightedAvatars()]);
- }
+async function greenButtonFunction() {
+ if (document.querySelector('#green-button').classList.contains('disabled') === true) {
+ return;
+ }
- $('#mainRoomBox div').removeClass('highlight-avatar');
+ if (isSpectator === true) {
+ socket.emit('join-game', roomId);
+ } else if (gameStarted === false) {
+ const startGameData = {
+ options: getOptions(),
+ gameMode: $($('.gameModeSelect')[1]).val(),
+ timeouts: {
+ default: ((parseInt($('#startGameOptionsDefaultPhaseTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsDefaultPhaseTimeoutSec').val())) * 1000).toString(),
+ critMission: ((parseInt($('#startGameOptionsCritMissionTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsCritMissionTimeoutSec').val())) * 1000).toString(),
+ assassination: ((parseInt($('#startGameOptionsAssassinationPhaseTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsAssassinationPhaseTimeoutSec').val())) * 1000).toString(),
+ },
+ anonymousMode: $('#startGameOptionsAnonymousMode')[0].checked,
+ };
+ socket.emit('startGame', startGameData);
+ } else if (
+ gameData.phase === 'VotingTeam' &&
+ !(await preventMisclick('yes'))
+ ) {
+ socket.emit('gameMove', ['yes', []]);
+ } else if (gameData.phase === 'VotingMission') {
+ socket.emit('gameMove', ['yes', []]);
+ } else if (gameData.phase === 'PickingTeam') {
+ socket.emit('gameMove', ['yes', getHighlightedAvatars()]);
}
+
+ $('#mainRoomBox div').removeClass('highlight-avatar');
}
//= =====================================
@@ -259,3 +245,48 @@ function handleTimeoutInput(inputId) {
input.value = 60;
}
}
+
+async function preventMisclick(button) {
+ if (
+ $('#optionGameplayPreventMisclicks')[0].checked === false ||
+ // only applies to 6 player
+ gameData.playerUsernamesOrdered.length !== 6
+ ) {
+ return false;
+ }
+
+ const isPlayerOnTeam = gameData.proposedTeam.includes(gameData.username);
+ const missionsToExpectOnapp = [1, 2];
+ const missionsToExpectOffrej = [1, 2, 3, 5];
+ let isVoteExpected = true;
+ let str = '';
+ if (gameData.pickNum === 5) {
+ isVoteExpected = button === 'yes';
+ str = 'Really reject hammer?'
+ } else if (
+ isPlayerOnTeam &&
+ missionsToExpectOnapp.includes(gameData.missionNum)
+ ) {
+ isVoteExpected = button === 'yes';
+ str = 'You\'re on the team!'
+ } else if (
+ !isPlayerOnTeam &&
+ missionsToExpectOffrej.includes(gameData.missionNum)
+ ) {
+ isVoteExpected = button === 'no';
+ str = 'You\'re off the team!'
+ }
+ if (isVoteExpected) {
+ return false;
+ }
+ // launch sweetalert to confirm click
+ const input = await swal({
+ title: str,
+ type: 'warning',
+ showCancelButton: true,
+ reverseButtons: true,
+ confirmButtonText: button === 'yes' ? 'Approve' : 'Reject',
+ confirmButtonColor: button === 'yes' ? '#5cb85c' : '#d9534f',
+ });
+ return !input.value;
+}
From 629c52be30c9935a06b6a6d1072225d4112fa377 Mon Sep 17 00:00:00 2001
From: Ba3henov <46943437+Ba3henov@users.noreply.github.com>
Date: Tue, 20 Jan 2026 08:14:52 -0800
Subject: [PATCH 2/4] Add gameplay option to prevent misclicks
---
assets/scripts/lobby/options.js | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/assets/scripts/lobby/options.js b/assets/scripts/lobby/options.js
index c8c71c497..9b8bea46c 100644
--- a/assets/scripts/lobby/options.js
+++ b/assets/scripts/lobby/options.js
@@ -1193,6 +1193,29 @@ var userOptions = {
);
},
},
+
+ //---------------------------------------------
+ // Gameplay
+ //---------------------------------------------
+
+ optionGameplayPreventMisclicks: {
+ defaultValue: 'false',
+ onLoad() {
+ if (docCookies.getItem('optionGameplayPreventMisclicks') === 'true') {
+ $('#optionGameplayPreventMisclicks')[0].checked = true;
+ }
+ },
+ initialiseEventListener() {
+ $('#optionGameplayPreventMisclicks')[0].addEventListener('click', () => {
+ const { checked } = $('#optionGameplayPreventMisclicks')[0];
+ docCookies.setItem(
+ 'optionGameplayPreventMisclicks',
+ checked.toString(),
+ Infinity
+ );
+ });
+ },
+ },
};
// run through each userOption load and initialiseEventListener
From 5a89265954a2c88fad55e00aaecdd79dd9afcd3f Mon Sep 17 00:00:00 2001
From: Ba3henov <46943437+Ba3henov@users.noreply.github.com>
Date: Tue, 20 Jan 2026 08:15:21 -0800
Subject: [PATCH 3/4] Add gameplay options section to header
Added gameplay options menu with prevent misclicks feature.
---
src/views/partials/header.ejs | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/views/partials/header.ejs b/src/views/partials/header.ejs
index 4040b01c0..227f02f16 100644
--- a/src/views/partials/header.ejs
+++ b/src/views/partials/header.ejs
@@ -300,6 +300,14 @@
+
+ |
+
+ Gameplay
+
+ |
+
+
|
@@ -453,7 +461,21 @@
-
+
|