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

Prevent back-to-back combo breaking in the counting game #808

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

theimperious1
Copy link
Collaborator

@theimperious1 theimperious1 commented Jul 7, 2024

This PR should prevent the same user being able to break combos back to back, regardless of which counting game mode they originally broke the combo of.

UPDATE: This now should prevent the last 4 people to have broken the combo from breaking it again. It also fixes formatting issues in the warning before breaking a combo.

Fix #695.

@LunaUrsa
Copy link
Contributor

I like the general idea here, but i don't like storing an object as a string in the database

Instead, let's stretch those prisma legs, can you please make a new table for combo breakers? Something like:

`
model counting {
...
breakers counting_breaks[]

}

model counting_breaks {
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
user_id String
game_id String @db.Uuid
count Int
last_broken_at DateTime @default(now()) @db.Timestamptz(6)

user users @relation(fields: [user_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "counting_userid_foreign")
game counting @relation(fields: [game_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "counting_guildid_foreign")

@@unique([user_id, game_id], map: "counting_userid_gameid_unique")
}`

This way it's more extensible and 'proper': Maybe one day we'll want to get a list of how many times each person has broken the combo or something

When you're done, you'll need to create a new migration file that will modify the database. In the package.json there's the 'db:migrateDev' npm script. You'll want to modify 'welcome_fix' to like 'counting_breakers' and then run the script

Just to explain: We use a postgres database, and prisma is a layer between us and the database. We still use migration files to manage the database, but prisma makes it easy and lets us modify the schema file to be what we want it to be, and prisma takes care of generating the migration files for us, so we don't need to actually write (or debug) SQL

Thank you!

@LunaUrsa LunaUrsa assigned LunaUrsa and theimperious1 and unassigned LunaUrsa Jul 13, 2024
@theimperious1 theimperious1 removed their assignment Jul 16, 2024
@LunaUrsa LunaUrsa marked this pull request as draft August 5, 2024 14:16
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.

Add discouragement to breaking the counting channel
2 participants