当前位置: 首页>>代码示例>>Python>>正文


Python Parser.parse_spawn方法代码示例

本文整理汇总了Python中parsing.parser.Parser.parse_spawn方法的典型用法代码示例。如果您正苦于以下问题:Python Parser.parse_spawn方法的具体用法?Python Parser.parse_spawn怎么用?Python Parser.parse_spawn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在parsing.parser.Parser的用法示例。


在下文中一共展示了Parser.parse_spawn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: spawn_statistics

# 需要导入模块: from parsing.parser import Parser [as 别名]
# 或者: from parsing.parser.Parser import parse_spawn [as 别名]
def spawn_statistics(file_name, spawn, spawn_timing, sharing_db=None):
    """Build strings to show in the StatsFrame"""
    # Retrieve required data
    lines = Parser.read_file(file_name, sharing_db)
    player_numbers = Parser.get_player_id_list(lines)
    (abilities_dict, dmg_t, dmg_d, healing, dmg_s, enemies, critcount,
     crit_luck, hitcount, ships_list, enemy_dmg_d, enemy_dmg_t) = \
        Parser.parse_spawn(spawn, player_numbers)
    name = Parser.get_player_name(lines)
    # Build the statistics string
    stat_string = "{name}\n{enemies} enemies\n{dmg_d}\n{dmg_t}\n{dmg_r:.1f} : 1.0\n" \
                  "{dmg_s}\n{healing}\n{hitcount}\n{critcount}\n{crit_luck:.2f}\n" \
                  "{deaths}\n{minutes}:{seconds:.0f}\n{dps:.1f}"
    start = spawn_timing
    finish = Parser.line_to_dictionary(spawn[-1])["time"]
    delta = finish - start
    minutes, seconds = divmod(delta.total_seconds(), 60)
    killsassists = sum(True if enemy_dmg_t[enemy] > 0 else False for enemy in enemies if enemy in enemy_dmg_t)
    stat_string = stat_string.format(
        name=name,
        enemies=killsassists,
        dmg_d=dmg_d,
        dmg_t=dmg_t,
        dmg_r=dmg_d / dmg_t if dmg_t != 0 else 0,
        dmg_s=dmg_s,
        healing=healing,
        hitcount=hitcount,
        critcount=critcount,
        crit_luck=critcount / hitcount if hitcount != 0 else 0,
        deaths="-",
        minutes=minutes,
        seconds=seconds,
        dps=dmg_d / delta.total_seconds() if delta.total_seconds() != 0 else 0
    )
    # Build the components list
    components = {key: "" for key in abilities.component_types}
    for component in [ability for ability in abilities_dict.keys() if ability in abilities.components]:
        for type in components.keys():
            if component not in getattr(abilities, type):
                continue
            # Dual primary/secondary weapons
            if components[type] != "":
                components[type] += " / {}".format(component)
                break
            components[type] = component
            break
    components = [components[category] for category in abilities.component_types]
    # Return
    return name, spawn, abilities_dict, stat_string, ships_list, components, enemies, enemy_dmg_d, enemy_dmg_t
开发者ID:RedFantom,项目名称:GSF-Parser-Public,代码行数:51,代码来源:spawnstats.py


注:本文中的parsing.parser.Parser.parse_spawn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。