-
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
Counting game #535
base: main
Are you sure you want to change the base?
Counting game #535
Conversation
added COUNTING_CHANNEL_ID requirement to vars.json users must work together to count as high as possible coins will be awarded based on the highest number counted to
a certain number must be reached in order for coins to be awarded coins will now be awarded to all participants KNOWN ERRORS: floating point issue for numbers when coins are being awarded
src/events/messageCreate.ts
Outdated
const IRC_USER_ID: string = vars.IRC_USER_ID; | ||
const PDF_FILE_PATH = 'tmp/resume.pdf'; | ||
const HEIC_FILE_PATH = 'tmp/img.heic'; | ||
const CONVERTED_IMG_PATH = 'tmp/img.jpg'; | ||
|
||
// Variables and constants associated with the counting game | ||
const coinsPerMessage = 0.1; // Number of coins awarded = coinsPerMessage * highest counting number * messages sent by user |
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.
Change this to 0.25 to avoid floating point errors (ex. 18.900000000000002).
} | ||
|
||
if (reasonForFailure) { | ||
return endCountingGame(client, message, reasonForFailure); |
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.
Subtract currentCountingNumber by 1 when the game ends because this value of currentCountingNumber was not actually reached.
src/events/messageCreate.ts
Outdated
const IRC_USER_ID: string = vars.IRC_USER_ID; | ||
const PDF_FILE_PATH = 'tmp/resume.pdf'; | ||
const HEIC_FILE_PATH = 'tmp/img.heic'; | ||
const CONVERTED_IMG_PATH = 'tmp/img.jpg'; | ||
|
||
// Variables and constants associated with the counting game | ||
const coinsPerMessage = 0.1; // Number of coins awarded = coinsPerMessage * highest counting number * messages sent by user |
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.
In general, we prefer to keep all constant variable names capitalized and snake-cased (see above format).
|
||
const ANNOUNCEMENTS_CHANNEL_ID: string = vars.ANNOUNCEMENTS_CHANNEL_ID; | ||
const RESUME_CHANNEL_ID: string = vars.RESUME_CHANNEL_ID; | ||
const COUNTING_CHANNEL_ID: string = vars.COUNTING_CHANNEL_ID; |
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 also add this variable into config/vars.template.json for future devs.
Great job! Functionality looks great, please see some of the comments we left above for some minor changes. |
suggestions have been completed: constants have been refactored - counting channel id added to vars template - currentCountingNumber gets decremented on game end as well, now each individual user can only the MINIMUM of the following: - 2 coins per number counted - 20 coins per message sent - the normal calculation formula this should plateau the number of coins earned as the numbers increase this is also to prevent very active users from gaining a large amount of coins, and very inactive players sending a single message in a high-count game and earning hundreds of coins e.g., in a game where the count is 1000, - a user that sent 100 messages will earn 2000 coins, as opposed to normal 10000 - a user that sends one single message will earn 20 coins, as opposed to 100 it should be noted that, once the counting number is very high (500+), the standard formula will no longer be relevant, and each user will be capped from either of the two aforementioned methods (which may or may not be desirable)
To fulfill the following request: https://github.com/orgs/uwcsc/projects/2/views/1?filterQuery=counting&pane=issue&itemId=10192321
Added a counting game to codeybot. In this game, users take turns counting higher and higher numbers in a dedicated text channel. The game continues until a user...
The bot will react accordingly to messages and award coins on a game over.
Adjustable variables:
countingAuthorDelay: the number of messages that must be sent before a user can count again
coinsPerMessage: the number of coins awarded per message. A game over will reward this many coins to each user:
(coinsPerMessage) * (highest number counted) * (messages sent by user)
coinAwardNumberThreshold: the minimum number that must be counted to award coins.
DEMO: