Created
August 4, 2020 00:02
-
-
Save Noxville/60f6103c3512c6dd854ae4ed3d50a2b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from os import listdir | |
from os.path import isfile, join | |
import os | |
dir_path = os.path.dirname(os.path.realpath(__file__)) | |
onlyfiles = [f for f in listdir(dir_path) if isfile(join(dir_path, f)) and ".json" in f] | |
unordered = [] | |
for f in onlyfiles: | |
unordered.append((int(f.split(".")[0]), f)) | |
ignored, seen = {}, {} | |
kills, deaths = {}, {} | |
for idx, f in enumerate(sorted(unordered)): | |
with open(f[1], encoding='utf-8') as fin: | |
print(fin.name + " ({}/{})".format(1 + idx, len(unordered))) | |
j = json.load(fin) | |
pay = j['payload']['payload'] | |
cla = [pay['type'], pay['subject'], pay['action']] | |
claS = " | ".join(cla) | |
seen[claS] = 1 + seen.get(claS, 0) | |
if claS == 'GAME_EVENT | PLAYER | KILL': | |
killer = pay['payload']['killer'] | |
killerS = killer.replace('npc_dota_hero_', '') if killer else 'unknown' | |
kills[killerS] = kills.get(killerS, 0) + 1 | |
victim = pay['payload']['victim'] | |
victimS = victim.replace('npc_dota_hero_', '') if victim else 'unknown' | |
deaths[victimS] = deaths.get(victimS, 0) + 1 | |
if claS not in ignored: | |
print(claS) | |
print(json.dumps(j['payload']['payload']['payload'], indent=4, sort_keys=True)) | |
r = input() | |
if r == 'i': | |
ignored[claS] = True | |
print('-' * 140) | |
for _ in range(80): | |
print('\n') | |
print("\n\nEvent Frequency Counts") | |
for k, v in seen.items(): | |
print("{}: {}".format(k, v)) | |
print("\n\nKills: ") | |
for k, v in kills.items(): | |
print("{}: {}".format(k, v)) | |
print("\n\nDeaths: ") | |
for k, v in deaths.items(): | |
print("{}: {}".format(k, v)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment