Peacock icon indicating copy to clipboard operation
Peacock copied to clipboard

feat: Add API to simplify creation of global challenges

Open Yanrishatum opened this issue 1 year ago • 1 comments

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

Yanrishatum avatar May 11 '24 18:05 Yanrishatum

I like this! I'd be willing to merge if nobody has any other feedback on the API design.

RDIL avatar May 14 '24 14:05 RDIL

Changes from initial draft:

  • controller.challengeService.globalGroups is now controller.challengeService.globalMergeGroups to make it clearer what it does.
  • The classic, elusive and H1/H2 escalation challenges merges are now removed in favor of using new API (code simplification)
  • Added registerChallengeList method, 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 hasGroup method to check if group is registered.

The example plugin is ready, but I'm not sure where to put it.

Yanrishatum avatar May 27 '24 06:05 Yanrishatum

I think the place for that would be on the WIP plugin development guide on the website

RDIL avatar May 27 '24 18:05 RDIL