Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Counting game #535

wants to merge 5 commits into from

Conversation

w1dering
Copy link

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...

  1. sends a non-number message
  2. sends the wrong number
  3. counts too frequently (e.g. counts twice in a row)
    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

  • For instance, if set to 1, a user can only count every other number. If set to 2, a user can only count every third number
    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:
image
image

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
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
Copy link
Contributor

@davidgan1218 davidgan1218 Sep 29, 2024

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);
Copy link
Contributor

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.

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
Copy link
Contributor

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;
Copy link
Contributor

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.

@davidgan1218
Copy link
Contributor

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)
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