Conversation
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')) |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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', | ||
| }); |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
Let's put this on true and let people disable it as desired.
Added client-side misclick prevention, which interrupts an unexpected Approve or Reject vote with a SweetAlert