text stringlengths 1 93.6k |
|---|
# https://github.com/fetus-hina/stat.ink/wiki/Spl3-API:-Battle-%EF%BC%8D-Post
|
payload = {}
|
battle = battle["vsHistoryDetail"]
|
## UUID ##
|
##########
|
try:
|
full_id = utils.b64d(battle["id"])
|
payload["uuid"] = str(uuid.uuid5(utils.S3S_NAMESPACE, full_id[-52:])) # input format: <YYYYMMDD>T<HHMMSS>_<uuid>
|
except TypeError:
|
print("Couldn't get the battle ID. This is likely an error on Nintendo's end; running the script again may fix it. Exiting.")
|
print('\nDebug info:')
|
print(json.dumps(battle))
|
sys.exit(1)
|
## MODE ##
|
##########
|
mode = battle["vsMode"]["mode"]
|
if mode == "REGULAR":
|
payload["lobby"] = "regular"
|
elif mode == "BANKARA":
|
if battle["bankaraMatch"]["mode"] == "OPEN":
|
payload["lobby"] = "bankara_open"
|
elif battle["bankaraMatch"]["mode"] == "CHALLENGE":
|
payload["lobby"] = "bankara_challenge"
|
elif mode == "PRIVATE":
|
payload["lobby"] = "private"
|
elif mode == "FEST":
|
if utils.b64d(battle["vsMode"]["id"]) in (6, 8): # open or tricolor
|
payload["lobby"] = "splatfest_open"
|
elif utils.b64d(battle["vsMode"]["id"]) == 7:
|
payload["lobby"] = "splatfest_challenge" # pro
|
elif mode == "X_MATCH":
|
payload["lobby"] = "xmatch"
|
elif mode == "LEAGUE": # challenge
|
payload["lobby"] = "event"
|
## RULE ##
|
##########
|
rule = battle["vsRule"]["rule"]
|
if rule == "TURF_WAR":
|
payload["rule"] = "nawabari" # could be splatfest too
|
elif rule == "AREA":
|
payload["rule"] = "area"
|
elif rule == "LOFT":
|
payload["rule"] = "yagura"
|
elif rule == "GOAL":
|
payload["rule"] = "hoko"
|
elif rule == "CLAM":
|
payload["rule"] = "asari"
|
elif rule == "TRI_COLOR":
|
payload["rule"] = "tricolor"
|
## STAGE ##
|
###########
|
payload["stage"] = utils.b64d(battle["vsStage"]["id"])
|
## WEAPON, K/D/A/S, PLAYER & TEAM TURF INKED ##
|
###############################################
|
for i, player in enumerate(battle["myTeam"]["players"]): # specified again in set_scoreboard()
|
if player["isMyself"] == True:
|
payload["weapon"] = utils.b64d(player["weapon"]["id"])
|
payload["inked"] = player["paint"]
|
payload["species"] = player["species"].lower()
|
payload["rank_in_team"] = i+1
|
# crowns (x rank and splatfest 'dragon') set in set_scoreboard()
|
if player["result"] is not None: # null if player disconnect
|
payload["kill_or_assist"] = player["result"]["kill"]
|
payload["assist"] = player["result"]["assist"]
|
payload["kill"] = payload["kill_or_assist"] - payload["assist"]
|
payload["death"] = player["result"]["death"]
|
payload["special"] = player["result"]["special"]
|
payload["signal"] = player["result"]["noroshiTry"] # ultra signal attempts in tricolor TW
|
break
|
try:
|
our_team_inked, their_team_inked = 0, 0
|
for player in battle["myTeam"]["players"]:
|
our_team_inked += player["paint"]
|
for player in battle["otherTeams"][0]["players"]:
|
their_team_inked += player["paint"]
|
payload["our_team_inked"] = our_team_inked
|
payload["their_team_inked"] = their_team_inked
|
except: # one of these might be able to be null? doubtful but idk lol
|
pass
|
## RESULT ##
|
############
|
result = battle["judgement"]
|
if result == "WIN":
|
payload["result"] = "win"
|
elif result in ("LOSE", "DEEMED_LOSE"):
|
payload["result"] = "lose"
|
elif result == "EXEMPTED_LOSE":
|
payload["result"] = "exempted_lose" # doesn't count toward stats
|
elif result == "DRAW":
|
payload["result"] = "draw"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.