Esempio n. 1
0
def parse_matchdata(js: dict, m: Match) -> None:
    m.crewscore = js['crewscore']
    m.data_version = js['data_revision']
    m.mastermode = js['mastermode']
    m.tickermode = js['tickermode']
    # m.modes_string = js['mixed_gamemodes']
    if len(js['mixed_gamemodes']) > 0:
        m.modes_string = '|'.join(js['mixed_gamemodes'])
    else:
        m.modes_string = js['tickermode']
    m.mapname = js['mapname']
    m.crates_ordered = js['crates_ordered']
    m.blood_spilled = js['blood_spilled']
    m.artifacts_discovered = js['artifacts_discovered']
    # terrible bad hotfix
    if 'tech_total' in js:
        m.tech_total = js['tech_total']
    # end bad hotfix
    if 'stationname' in js:
        m.station_name = js['stationname']
    m.borgs_at_roundend = js['borgs_at_roundend']
    m.remaining_heads = js['heads_at_roundend']
    m.nuked = boolify(js['nuked'])

    # Time stamp parsing
    m.start_datetime = timestamp_to_datetime(js['round_start_time'])
    m.end_datetime = timestamp_to_datetime(js['round_end_time'])
    m.round_length = (m.end_datetime - m.start_datetime).total_seconds()

    # cult
    m.cult_runes_written = js['cult_runes_written']
    m.cult_runes_nulled = js['cult_runes_nulled']
    m.cult_runes_fumbled = js['cult_runes_fumbled']
    m.cult_converted = js['cult_converted']
    m.cult_tomes_created = js['cult_tomes_created']
    m.cult_narsie_summoned = boolify(js['cult_narsie_summoned'])
    m.cult_narsie_corpses_fed = js['narsie_corpses_fed']
    m.cult_surviving_cultists = js['cult_surviving_cultists']
    m.cult_deconverted = js['cult_deconverted']

    # xeno
    m.xeno_eggs_laid = js['xeno_eggs_laid']
    m.xeno_faces_hugged = js['xeno_faces_hugged']
    m.xeno_faces_protected = js['xeno_faces_protected']

    # Blob
    m.blob_wins = boolify(js['blob_wins'])
    m.blob_spawned_blob_players = js['blob_spawned_blob_players']
    m.blob_spores_spawned = js['blob_spores_spawned']
    m.blob_res_generated = js['blob_res_generated']

    # Malf
    m.malf_won = boolify(js['malf_won'])
    m.malf_shunted = boolify(js['malf_shunted'])
    for mod in js['malf_modules']:
        modid = MalfModule.get_or_add(mod)
        match_mod = MatchMalfModule(match_id=m.id, module_id=modid.id)
        db.add(match_mod)

    # Revsquad
    m.revsquad_won = boolify(js['revsquad_won'])
    for item in js['revsquad_items']:
        itemid = RevsquadItem.get_or_add(item)
        rev_item = MatchRevsquadItem(match_id=m.id, item_id=itemid.id)
        db.add(rev_item)

    # And finally...
    db.flush()
Esempio n. 2
0
def lineparse_blobstats(line: Text, match: models.Match):
    match.blob_wins = line[1]
    match.blob_spawned_blob_players = line[2]
    match.spores_spawned = line[3]
    match.res_generated = line[3]