Skip to content

Comments

Prevent misclicks#762

Closed
Ba3henov wants to merge 4 commits intovck3000:masterfrom
Ba3henov:prevent-misclicks
Closed

Prevent misclicks#762
Ba3henov wants to merge 4 commits intovck3000:masterfrom
Ba3henov:prevent-misclicks

Conversation

@Ba3henov
Copy link
Contributor

Added client-side misclick prevention, which interrupts an unexpected Approve or Reject vote with a SweetAlert

Refactor redButtonFunction and greenButtonFunction to be async and handle button state more effectively. Introduce preventMisclick function for better user interaction.
Added gameplay options menu with prevent misclicks feature.
$('#mainRoomBox div').removeClass('highlight-avatar');
} else if (
gameData.phase === 'VotingTeam' &&
!(await preventMisclick('no'))
Copy link
Owner

@vck3000 vck3000 Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of preventMisclick, can we name this confirmUserClick? That way the return type is clearer. I.e. returning true means it's ok, and returning false means stop.

Or we can call the function isMisclick as well.

socket.emit('gameMove', ['yes', []]);
} else if (gameData.phase === 'VotingMission') {
socket.emit('gameMove', ['yes', []]);
} else if (gameData.phase === 'PickingTeam') {
Copy link
Owner

@vck3000 vck3000 Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this break anything? For example when using lady of the lake? I think it's safer to keep it as the old logic where it was just an else statement.


const isPlayerOnTeam = gameData.proposedTeam.includes(gameData.username);
const missionsToCatchOnrej = [1, 2];
const missionsToCatchOffapp = [1, 2, 3, 5];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would've thought you'd want to check all missions for offapps? Or is the idea because at least one res has to approve mission 4 hammer?

}
}

async function preventMisclick(button) {
Copy link
Owner

@vck3000 vck3000 Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking good!

Can we restructure the code a bit so each check is a bit clearer?

E.g.

async function preventMisclick(button) {
    // blah check


    // Check onrej
    if (phase == "votingTeam" && button == "no")
    {
        if (isOnTeam) { str = "blah" }
    }
    // Check hammer rej
    else if (phase == "votingTeam" && pickNum === 5 && youAreRes)
    {
        str = "are you sure you wanna rej hammer"
    }
    ...
}

This way you can get rid of isVoteExpected as well which is a bit confusing as a name for what it's doing.

reverseButtons: true,
confirmButtonText: button === 'yes' ? 'Approve' : 'Reject',
confirmButtonColor: button === 'yes' ? '#5cb85c' : '#d9534f',
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a tiny text at the bottom of the swal saying "you can disable misclick prevention in settings"? Just so we don't annoy the vets :).

//---------------------------------------------

optionGameplayPreventMisclicks: {
defaultValue: 'false',
Copy link
Owner

@vck3000 vck3000 Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this on true and let people disable it as desired.

@Ba3henov Ba3henov closed this Feb 3, 2026
@Ba3henov Ba3henov deleted the prevent-misclicks branch February 3, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants