Webhost: add total player location counts to tracker API (#5441)
This commit is contained in:
@@ -52,6 +52,12 @@ class PlayerStatus(TypedDict):
|
|||||||
status: ClientStatus
|
status: ClientStatus
|
||||||
|
|
||||||
|
|
||||||
|
class PlayerLocationsTotal(TypedDict):
|
||||||
|
team: int
|
||||||
|
player: int
|
||||||
|
total_locations: int
|
||||||
|
|
||||||
|
|
||||||
@api_endpoints.route("/tracker/<suuid:tracker>")
|
@api_endpoints.route("/tracker/<suuid:tracker>")
|
||||||
@cache.memoize(timeout=60)
|
@cache.memoize(timeout=60)
|
||||||
def tracker_data(tracker: UUID) -> dict[str, Any]:
|
def tracker_data(tracker: UUID) -> dict[str, Any]:
|
||||||
@@ -195,9 +201,16 @@ def static_tracker_data(tracker: UUID) -> dict[str, Any]:
|
|||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
|
||||||
|
player_locations_total: list[PlayerLocationsTotal] = []
|
||||||
|
for team, players in all_players.items():
|
||||||
|
for player in players:
|
||||||
|
player_locations_total.append(
|
||||||
|
{"team": team, "player": player, "total_locations": len(tracker_data.get_player_locations(player))})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"groups": groups,
|
"groups": groups,
|
||||||
"datapackage": tracker_data._multidata["datapackage"],
|
"datapackage": tracker_data._multidata["datapackage"],
|
||||||
|
"player_locations_total": player_locations_total,
|
||||||
}
|
}
|
||||||
|
|
||||||
# It should be exceedingly rare that slot data is needed, so it's separated out.
|
# It should be exceedingly rare that slot data is needed, so it's separated out.
|
||||||
|
|||||||
@@ -383,6 +383,8 @@ Will provide a dict of static tracker data with the following keys:
|
|||||||
- item_link groups and their players (`groups`)
|
- item_link groups and their players (`groups`)
|
||||||
- The datapackage hash for each game (`datapackage`)
|
- The datapackage hash for each game (`datapackage`)
|
||||||
- This hash can then be sent to the datapackage API to receive the appropriate datapackage as necessary
|
- This hash can then be sent to the datapackage API to receive the appropriate datapackage as necessary
|
||||||
|
- The number of checks found vs. total checks available per player (`player_locations_total`)
|
||||||
|
- Same logic as the multitracker template: found = len(player_checks_done.locations) / total = player_locations_total.total_locations (all available checks).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```json
|
```json
|
||||||
@@ -412,7 +414,19 @@ Example:
|
|||||||
"The Messenger": {
|
"The Messenger": {
|
||||||
"checksum": "6991cbcda7316b65bcb072667f3ee4c4cae71c0b",
|
"checksum": "6991cbcda7316b65bcb072667f3ee4c4cae71c0b",
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"player_locations_total": [
|
||||||
|
{
|
||||||
|
"player": 1,
|
||||||
|
"team" : 0,
|
||||||
|
"total_locations": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"player": 2,
|
||||||
|
"team" : 0,
|
||||||
|
"total_locations": 20
|
||||||
|
}
|
||||||
|
],
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user