Activision / cwl-data

Call of Duty World League Player Data
BSD 3-Clause "New" or "Revised" License
50 stars 23 forks source link

Created a script to compute factoids for COD:WW2 tournaments #8

Closed lot9s closed 6 years ago

lot9s commented 6 years ago

To create this script, I used compute-factoids.py as a base and made the following changes:

saturnboy commented 6 years ago

@lot9s thanks for this...but let's not make a separate file, instead let's merge these two factoid helpers together (ex: include --title flag for iw or ww2, a block of total stats to compute per title, a block of record stats to compute per title, etc)

lot9s commented 6 years ago

@saturnboy Okay! Will do. I'll submit a different pull request at a later time after making this happen.

Before closing this pull request, could you please clarify what you meant by, "...a block of total stats to compute per title, a block of record stats to compute per title, etc"? Are you suggesting that the script should accept a list of stats to compute from the command line?

saturnboy commented 6 years ago

@lot9s I was thinking something like this:

TITLES = {
    'iw': {'modes': ['hp', 'snd', 'upl']},
    'ww2': {'modes': ['hp', 'snd', 'ctf']}
}
TOTALS = {
    'base': ['kills', 'deaths', 'assists', 'hits', 'shots'],
    'hp': ['hill time (s)'],
    'snd': ['bomb plants', 'bomb defuses'],
    'upl': ['uplink dunks', 'uplink throws', 'uplink points'],
    'ctf': ['ctf captures', 'ctf returns', 'ctf pickups', 'ctf defends', 'ctf kill carriers', 'ctf flag carry time (s)']
}

def find_totals(rows, title):
    """Compute stat totals by summing over the entire tournament."""
    totals = {k:0 for k in [k for l in [TOTALS[i] for i in ['base'] + TITLES[title]['modes']] for k in l]}
    for row in rows:
        for k in totals:
            totals[k] += int(row[k])

    return totals

Or maybe this is simpler and better:

TOTALS = {
    'iw':  ['kills', 'deaths', 'assists', 'hits', 'shots', 'hill time (s)', 'bomb plants', 'bomb defuses', 'uplink dunks', 'uplink throws', 'uplink points'],
    'ww2': ['kills', 'deaths', 'assists', 'hits', 'shots', 'hill time (s)', 'bomb plants', 'bomb defuses', 'ctf captures', 'ctf returns', 'ctf pickups', 'ctf defends', 'ctf kill carriers', 'ctf flag carry time (s)']
}

def find_totals(rows, title):
    """Compute stat totals by summing over the entire tournament."""
    totals = {k:0 for k in TOTALS[title]}
    for row in rows:
        for k in totals:
            totals[k] += int(row[k])

    return totals

Also, no need to close, the theme of this branch is "improved factoids for ww2", so just keep going..

lot9s commented 6 years ago

@saturnboy I took some time this afternoon to make the desired changes to the factoid script. Please take a look to make sure that it all checks out.