-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add QuizBot #262
base: main
Are you sure you want to change the base?
add QuizBot #262
Conversation
users can add and remove a bot to a multiplayer room, the bot answers questions
c46252a
to
a37ee92
Compare
a37ee92
to
5b3cd34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few nitpicks from a security standpoint. I love this PR idea, keep it up!
@@ -769,7 +778,7 @@ function upsertPlayerItem(player) { | |||
playerItem.id = `list-group-${userId}`; | |||
playerItem.innerHTML = ` | |||
<div class="d-flex justify-content-between"> | |||
<span id="username-${userId}">${escapeHTML(username)}</span> | |||
<span id="username-${userId}">${player.userId == 'QuizBotId' ? '<i class="fa-solid fa-robot"></i> ' : ''}${escapeHTML(username)}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't userIDs be spoofed by a user if directly connecting to the WebSocket?
isOnline: true, // You might want to always consider the bot as online | ||
}; | ||
|
||
upsertPlayerItem(quizBotPlayer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't the server send this player instead of the client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might've misunderstood how these are added, if so, my bad.
@@ -185,6 +192,15 @@ class TossupRoom { | |||
const type = message.type || ''; | |||
|
|||
switch (type) { | |||
case 'bot-difficulty': | |||
this.settings.botDifficulty = message.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add invalidations for what this can be, from what I can tell a user could input a string as a value here.
type: 'join', | ||
isNew: true, | ||
userId: 'QuizBotId', | ||
username: '🤖QuizBot🤖', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This username should be blacklisted from account creation or names in public games, as that could lead to impersonation/abuse.
+ how hard would it be to add to singleplayer? |
A bot solution for issue #10. It's not true artificial intelligence, but this lets users play against the computer.
Like @geoffrey-wu said,
The bot difficulty is in a range from 0-100, just like reading speed. You can think of the difficulty as the percentage of the question that is unread when the bot buzzes in. So if difficulty is set to 90, the bot will buzz in when 90% of the question is unread. At 100% the bot buzzes in instantly and at 0 it doesn't buzz in at all.
I made this a feature for multiplayer rooms instead of single player. I just find myself using a multiplayer room by myself instead of single player mode. Could be personal preference though