darkstormgames / darkstormgames/mkcentral-api
Improve Player data variant detection logic
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
### Description
The Player constructor currently has incomplete logic for determining whether a player object represents "full" or "list" data variants. The detection currently checks for the presence of certain keys but needs proper validation.
Location
File: `src/lib/Player.ts` (line ~88)
### Current Implementation
The code currently checks if all "full" keys are present:
```TypeScript
const fullKeys = ["roles", "rosters", "ban_info", "user_settings", "name_changes", "notes"];
const hasAllFullKeys = fullKeys.every((k) => k in obj);
```
### Tasks
- [ ] Document the exact differences between "full" and "list" player objects from the API
- [ ] Implement comprehensive key availability checks for both variants
- [ ] Add validation to ensure the correct PlayerDataKind is assigned
- [ ] Consider adding unit tests for different player object shapes
### Notes
This improvement will help ensure the DataKind and IsFull properties accurately reflect the type of data loaded, preventing potential issues when accessing properties that may not be present in certain variants.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.