feat: Add API to simplify creation of global challenges
Scope
This PR aims to provide plguin creators a way to create global challenges that act along the lines of Arcade challenge group, where it shows all challenges regardless of location. Exact API is up to debate, and it's more to kickstart discussion on how to better implement it. Right now it's mirroring the way challenge packs are implemented.
Current API usage example:
controller.challengeService.globalGroups.set('group-key', {
allLocations: true,
gameVersions: ["h3"],
groupId: 'group-key',
location: "GLOBAL_GROUP_LOCATION"
})
With allLocations flag it will add the global challenge group location always, regardless if there are any challenges from that group linked to the location. (Use case: Roulette mod)
Otherwise it will do so only if location contains challenges from the same challenge group. (Example: Classic challenges)
Test Plan
- [ ] Finalize API (discussion)
- [ ] Implement proper API
- [ ] Test it
- [ ] Provide example plugin showcasing both additiong of custom challenges and creation of global challenges.
Checklist
- [ ] I have run Prettier to reformat any changed files
- [ ] I have verified my changes work
I like this! I'd be willing to merge if nobody has any other feedback on the API design.
Changes from initial draft:
controller.challengeService.globalGroupsis nowcontroller.challengeService.globalMergeGroupsto make it clearer what it does.- The
classic,elusiveand H1/H2 escalation challenges merges are now removed in favor of using new API (code simplification) - Added
registerChallengeListmethod, because regular register did a lot of needless work. Simplifies registration of multiple challenges at once as well as marginally speeds up server boot as it has to do less work when registering challenges. - Added
hasGroupmethod to check if group is registered.
The example plugin is ready, but I'm not sure where to put it.
I think the place for that would be on the WIP plugin development guide on the website