darkstormgames / darkstormgames/mkcentral-api
Add player tournaments support to Player
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Summary
- Add a PlayerTournament class (modeled after src/lib/player/Discord.ts) and a Player.LoadTournaments method.
- Handle both Solo/Squad and Team tournaments via one class with shared fields plus type-specific optionals.
- Map snake_case to PascalCase, cache on the Player instance, and support force refresh.
Proposed changes
- New class: src/lib/player/PlayerTournament.ts
- Constructor accepts string | object and maps fields like Discord.ts.
- Shared fields: TournamentId, Name, Game, StartAt, Placement/Rank, ModeKey.
- Discriminant: Type: 'Solo' | 'Squad' | 'Team' (or IsTeamBased boolean).
- Team-only fields: TeamId, TeamName, TeamTag.
- Solo/Squad-only fields: SquadSize, Members (optional array of player ids/names).
- Player additions:
- Tournaments?: PlayerTournament[] and IsTournamentsLoaded?: boolean.
- LoadTournaments(options?: { type?: 'solo' | 'squad' | 'team' | 'all'; force?: boolean }): Promise
- Fetch tournaments endpoint(s), map to PlayerTournament[], return [] when none, cache unless force.
Acceptance criteria
- LoadTournaments returns PlayerTournament[] including both Solo/Squad and Team entries (filterable by type).
- PascalCase properties; no throw on empty results.
- Caching works; force option bypasses cache.
Tests
- Unskip and update “load tournaments separate endpoint” in player.test.ts to:
- Expect an array of PlayerTournament with PascalCase fields.
- Validate presence of shared fields (TournamentId, Name) and type-specific fields when applicable.
- Cover empty results and caching/force behavior.
Open questions
- Confirm exact API route(s) and payload shape for solo/squad vs team.
- Field names for placement/rank and start date.
- Any pagination or filters needed now.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.