Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
UserAchievement
#9610this is a proposal for an interface to award medals from osu-web
each medal is a queueable event listener that extends
MedalUnlock
. basic flow is$event
type-hints the events it will listen forshouldHandle()
tests whether the received event is actually relevant to the medal unlock -- checks in here should be inexpensive bc it runs synchronously after the event is dispatched. if true, the handler will be queued as a jobgetApplicableUsers()
gets the users that may unlock the medal, based on the event and any info saved at queue time (getQueueableState()
)shouldUnlockForUser()
tests whether a user will unlock the medal, if they didn't have it alreadymedal unlocks won't run without a corresponding entry in
osu_achievements
whereenabled
=1, so it's safe to either add the implementation before the db entry, or add a disabled db entry first and enable it after implementation.the event-driven design is partly so medal logic is in one place, and partly so hush-hush medals can be easily dropped in from a closed-source repo and Just Work:tm:. kind of over-engineered lol but it should be easy to make lots of different kinds of medals with this. I have some random example medals & tests at https://github.com/cl8n/osu-web/tree/medal-examples and https://github.com/cl8n/osu-web-hush-hush-medals