darkstormgames / darkstormgames/mkcentral-api

Improve Player data variant detection logic

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
bug enhancement
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.