當前位置: 首頁>>代碼示例>>Python>>正文


Python Parser.get_player_id_list方法代碼示例

本文整理匯總了Python中parsing.parser.Parser.get_player_id_list方法的典型用法代碼示例。如果您正苦於以下問題:Python Parser.get_player_id_list方法的具體用法?Python Parser.get_player_id_list怎麽用?Python Parser.get_player_id_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在parsing.parser.Parser的用法示例。


在下文中一共展示了Parser.get_player_id_list方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse_spawn

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def parse_spawn(self, elements):
     """
     Either starts the parsing of ALL spawns found in the specified
     match or just one of them and displays the results in the other
     frames accordingly.
     """
     self.clear_data_widgets()
     self.main_window.middle_frame.statistics_numbers_var.set("")
     self.main_window.ship_frame.ship_label_var.set("No match or spawn selected yet.")
     file_name, match_index, spawn_index = elements[0], int(elements[1]), int(elements[2])
     lines = Parser.read_file(file_name)
     player_list = Parser.get_player_id_list(lines)
     player_name = Parser.get_player_name(lines)
     file_cube, match_timings, spawn_timings = Parser.split_combatlog(lines, player_list)
     match = file_cube[match_index]
     spawn = match[spawn_index]
     results = list(spawnstats.spawn_statistics(
         file_name, spawn, spawn_timings[match_index][spawn_index]))
     results[1] = Parser.parse_player_reaction_time(spawn, player_name)
     orig = len(results[1])
     results[1] = ScreenParser.build_spawn_events(
         file_name, match_timings[::2][match_index], spawn_timings[match_index][spawn_index], spawn, player_name)
     print("[FileFrame] ScreenParser built {} events. Total: {}".format(len(results[1]) - orig, len(results[1])))
     self.update_widgets_spawn(*results)
     arguments = (file_name, match_timings[::2][match_index], spawn_timings[match_index][spawn_index])
     string = FileHandler.get_features_string(*arguments)
     self.main_window.middle_frame.screen_label_var.set(string)
     self.main_window.middle_frame.update_timeline(
         file_name, match_index, spawn_index, match_timings, spawn_timings, file_cube)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:31,代碼來源:fileframe.py

示例2: parse_ship_descriptor

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def parse_ship_descriptor(ship: Ship, line: dict, lines: list, event: tuple):
     """
     Parse an event_descriptor of the SHIP type. Supports ability,
     component and crew type operations.
     :param ship: Ship instance for the spawn described by lines
     :param line: Trigger line dictionary
     :param lines: List of lines in this spawn
     :param event: Event descriptor tuple (PatternParser docstring)
     :return: The result of results this SHIP event descriptor
     """
     if event[0] != Patterns.SHIP:
         raise InvalidDescriptor(event)
     event_type, args = event[1], event[2:]  # "ability", "component", "crew"
     # Parse Component selected
     if event_type == "component":
         # Component must be selected on the Ship for this spawn
         component, = args
         return PatternParser.get_component_in_ship(lines, ship, component)
     # Parse Crew selected
     elif event_type == "crew":
         crew, = args
         return PatternParser.get_crew_in_ship(ship, crew)
     # Parse Ability Available
     elif event_type == "ability":
         return PatternParser.parse_ability_availability(line, lines, event, ship)
     # Parse ship type selected
     elif event_type == "type":
         # TODO: Optimize usage
         player = Parser.get_player_id_list(lines)
         abs_dict = Parser.get_abilities_dict(lines, player)
         ship_name = ship.name if ship is None else Parser.get_ship_for_dict(abs_dict)
         ship_type, = args
         return get_ship_category(ship_name) == ship_type
     raise InvalidDescriptor(event)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:36,代碼來源:patterns.py

示例3: get_component_in_ship

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def get_component_in_ship(lines: list, ship: Ship, component: (str, Component)):
     """Return whether a component is found within a Ship instance"""
     if isinstance(component, Component):
         name, category = component.name, component.category
     else:  # str
         name = component
         category = PatternParser.get_component_category(component)
     player = Parser.get_player_id_list(lines)
     abilities = Parser.get_abilities_dict(lines, player)
     if name in abilities:
         return True
     if ship is None:
         return False  # Ship option not available at results time
     if category not in ship:
         return False  # Configured improperly at results time
     categories = (category,)
     if "Weapon" in category:  # Extend to double primaries/secondaries
         categories += (category[0] + "2",)
     # Loop over categories
     result = False
     for category in categories:
         if category not in ship:  # Double primaries/secondaries
             continue
         component = ship[category]
         if not isinstance(component, Component):  # Improper config
             print("[PatternParser] Improperly configured Ship instance:", ship, component)
             continue
         if component.name == name:
             result = True
             break
         continue
     return result
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:34,代碼來源:patterns.py

示例4: get_ability_markers

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def get_ability_markers(spawn_list, ship_stats):
     """
     Parse a spawn list of lines and take the Engine, Shield, Systems
     and CoPilot ability activations and create markers for them to
     be put in the TimeLine.
     """
     # TODO: Use ship_statistics to create availability markers
     categories = ["engines", "shields", "copilot", "systems"]
     player_id_list = Parser.get_player_id_list(spawn_list)
     results = {key: [] for key in categories}
     # Activation markers
     for line in spawn_list:
         if not isinstance(line, dict):
             line = Parser.line_to_dictionary(line)
         ability = line["ability"]
         if (line["source"] != line["target"] or line["source"] not in player_id_list or
                 "AbilityActivate" not in line["effect"]):
             continue
         if ability in abilities.copilots:
             category = "copilot"
         elif ability in abilities.shields:
             category = "shields"
         elif ability in abilities.systems:
             category = "systems"
         elif ability in abilities.engines:
             category = "engines"
         else:
             continue
         start = FileHandler.datetime_to_float(line["time"])
         args = ("abilities", start, start + 1/60)
         kwargs = {"background": FileHandler.colors[category]}
         results[category].append((args, kwargs))
     return results
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:35,代碼來源:filehandler.py

示例5: parse_spawn

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def parse_spawn(self, file: str, match_i: int, spawn_i: int):
     """
     Either starts the results of ALL spawns found in the specified
     match or just one of them and displays the results in the other
     frames accordingly.
     """
     print("[FileFrame] Parsing '{}', match {}, spawn {}".format(file, match_i, spawn_i))
     self.main_window.middle_frame.statistics_numbers_var.set("")
     self.main_window.ship_frame.ship_label_var.set("No match or spawn selected yet.")
     lines = Parser.read_file(file)
     player_list = Parser.get_player_id_list(lines)
     player_name = Parser.get_player_name(lines)
     file_cube, match_timings, spawn_timings = Parser.split_combatlog(lines, player_list)
     match = file_cube[match_i]
     spawn = match[spawn_i]
     results = list(spawnstats.spawn_statistics(
         file, spawn, spawn_timings[match_i][spawn_i]))
     results[1] = Parser.parse_player_reaction_time(spawn, player_name)
     orig = len(results[1])
     results[1] = ScreenParser.build_spawn_events(
         file, match_timings[::2][match_i], spawn_timings[match_i][spawn_i], spawn, player_name)
     print("[FileFrame] ScreenParser built {} events. Total: {}".format(len(results[1]) - orig, len(results[1])))
     self.update_widgets_spawn(*results)
     arguments = (file, match_timings[::2][match_i], spawn_timings[match_i][spawn_i])
     string = FileHandler.get_features_string(*arguments)
     self.main_window.middle_frame.screen_label_var.set(string)
     self.main_window.middle_frame.update_timeline(
         file, match_i, spawn_i, match_timings, spawn_timings, file_cube)
     match_timing = datetime.combine(Parser.parse_filename(file).date(), match_timings[::2][match_i].time())
     self.main_window.middle_frame.scoreboard.update_match(match_timing)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:32,代碼來源:file.py

示例6: _build_tracking_effects

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def _build_tracking_effects(events: list, screen_data: dict, ship: ShipStats):
     """Determine tracking penalty for each primary weapon event"""
     active_ids = Parser.get_player_id_list(events)
     distance = screen_data["distance"]
     primary = "PrimaryWeapon"
     for i, event in enumerate(events):
         if "custom" in event and event["custom"] is True:
             continue
         if "Primary Weapon Swap" in event["ability"] and event["self"] is True:
             primary = "PrimaryWeapon2" if primary == "PrimaryWeapon" else "PrimaryWeapon"
             continue
         ctg = Parser.get_event_category(event, active_ids)
         if ctg != "dmgd_pri":
             continue
         key = min(distance.keys(), key=lambda k: abs((k - event["time"]).total_seconds()))
         if abs((key - event["time"]).total_seconds()) > 0.5:
             continue
         if primary not in ship:
             continue
         tracking = ship[primary]["trackingAccuracyLoss"] * (distance[key] / 10) * 100
         del events[i]
         event["effects"] = (
             ("", "Tracking", "Penalty", "-{:.0f}%".format(tracking), "", "spvp_improvedfiringarctrackingbonus"),
         )
         events.append(event)
     return events
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:28,代碼來源:screen.py

示例7: test_get_effects_ability_eligible

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def test_get_effects_ability_eligible(self):
     with open(self.FILE) as fi:
         lindex = fi.readlines()
         index = lindex.index(self.EFFECT)
         no_effect = lindex.index(self.LINE)
     lines = Parser.read_file(self.FILE)
     player = Parser.get_player_id_list(lines)
     line = Parser.line_to_dictionary(lines[index], player)
     effect = Parser.get_effects_ability(line, lines, "2963000049645")
     self.assertIsInstance(effect, dict)
     self.assertTrue(len(effect) > 0)
     # Tests get_effects_eligible
     self.assertFalse(Parser.get_effects_ability(lines[no_effect], lines, "2963000048240"))
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:15,代碼來源:test_parser.py

示例8: insert_spawn

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def insert_spawn(self, spawn, player_name, active_ids: list = None):
     """Insert the events of a spawn into the Treeview"""
     self.delete_all()
     if len(spawn) == 0:
         raise ValueError("Invalid spawn passed.")
     spawn = spawn if isinstance(spawn[0], dict) else [Parser.line_to_dictionary(line) for line in spawn]
     start_time = spawn[0]["time"]
     active_ids = Parser.get_player_id_list(spawn) if active_ids is None else active_ids
     for line in spawn:
         if "custom" not in line or line["custom"] is False:
             line_event_dict = Parser.line_to_event_dictionary(line, active_ids, spawn)
         else:
             line_event_dict = line
         self.insert_event(line_event_dict, player_name, active_ids, start_time)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:16,代碼來源:time_view.py

示例9: spawn_statistics

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [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

示例10: parse_file

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def parse_file(self, file_name):
     """
     Function either sets the file and calls add_matches to add the
     matches found in the file to the matches_listbox, or starts the
     parsing of all files found in the specified folder and displays
     the results in the other frames.
     """
     self.clear_data_widgets()
     self.main_window.middle_frame.statistics_numbers_var.set("")
     self.main_window.ship_frame.ship_label_var.set("No match or spawn selected yet.")
     lines = Parser.read_file(file_name)
     player_list = Parser.get_player_id_list(lines)
     file_cube, _, _ = Parser.split_combatlog(lines, player_list)
     results = filestats.file_statistics(file_name)
     self.update_widgets(*results)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:17,代碼來源:fileframe.py

示例11: get_spawn

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def get_spawn(self):
     """
     Get the spawn from the selection in the file_tree
     :return: list of event strings, player_list, spawn timing and
         match timing
     """
     selection = self.file_tree.selection()[0]
     elements = selection.split(" ")
     if len(elements) is not 3:
         tkinter.messagebox.showinfo("Requirement", "Please select a spawn to view the events of.")
         return
     lines = Parser.read_file(elements[0])
     player_list = Parser.get_player_id_list(lines)
     file_cube, match_timings, spawn_timings = Parser.split_combatlog(lines, player_list)
     match_index, spawn_index = int(elements[1]), int(elements[2])
     return (file_cube[match_index][spawn_index], player_list, spawn_timings[match_index][spawn_index],
             match_timings[match_index])
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:19,代碼來源:fileframe.py

示例12: file_statistics

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
def file_statistics(file_name, sharing_db=None):
    """
    Puts the statistics found in a file_cube from
    Parser.split_combatlog() into a format that is usable by the
    FileFrame to display them to the user
    """
    lines = Parser.read_file(file_name)
    player_list = Parser.get_player_id_list(lines)
    file_cube, match_timings, spawn_timings = Parser.split_combatlog(lines, player_list)
    # Read sharing_db
    lines = Parser.read_file(file_name, sharing_db)
    name = Parser.get_player_name(lines)
    (abilities_dict, dmg_d, dmg_t, dmg_s, healing, hitcount, critcount,
     crit_luck, enemies, enemy_dmg_d, enemy_dmg_t, ships, uncounted) = \
        Parser.parse_file(file_cube, player_list)
    total = 0
    start = None
    for timing in match_timings:
        if start is not None:
            total += (timing - start).total_seconds()
            start = None
            continue
        start = timing
    minutes, seconds = divmod(total, 60)

    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}"
    stat_string = stat_string.format(
        name=name,
        enemies=len([enemy for enemy in enemies if enemy in enemy_dmg_t and enemy_dmg_t[enemy] > 0]),
        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=sum(len(match) for match in file_cube),
        minutes=minutes,
        seconds=seconds,
        dps=dmg_d / total,
    )
    return abilities_dict, stat_string, ships, enemies, enemy_dmg_d, enemy_dmg_t, uncounted
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:47,代碼來源:filestats.py

示例13: parse_match

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def parse_match(self, file: str, match_i: int):
     """
     Either adds sets the match and calls add_spawns to add the
     spawns found in the match or starts the results of all files
     found in the specified file and displays the results in the
     other frames.
     """
     print("[FileFrame] Parsing file '{}', match {}".format(file, match_i))
     self.main_window.middle_frame.statistics_numbers_var.set("")
     self.main_window.ship_frame.ship_label_var.set("No match or spawn selected yet.")
     lines = Parser.read_file(file)
     player_list = Parser.get_player_id_list(lines)
     file_cube, match_timings, _ = Parser.split_combatlog(lines, player_list)
     player_name = Parser.get_player_name(lines)
     match = file_cube[match_i]
     results = matchstats.match_statistics(file, match, match_timings[::2][match_i])
     self.update_widgets(*results)
     match_list = Parser.build_spawn_from_match(match)
     self.main_window.middle_frame.time_view.insert_spawn(match_list, player_name)
     match_timing = datetime.combine(Parser.parse_filename(file).date(), match_timings[::2][match_i].time())
     self.main_window.middle_frame.scoreboard.update_match(match_timing)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:23,代碼來源:file.py

示例14: parse_match

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def parse_match(self, elements: list):
     """
     Either adds sets the match and calls add_spawns to add the
     spawns found in the match or starts the parsing of all files
     found in the specified file and displays the results in the
     other frames.
     :param elements: specifies file and match
     """
     self.clear_data_widgets()
     self.main_window.middle_frame.statistics_numbers_var.set("")
     self.main_window.ship_frame.ship_label_var.set("No match or spawn selected yet.")
     file_name, match_index = elements[0], int(elements[1])
     lines = Parser.read_file(file_name)
     player_list = Parser.get_player_id_list(lines)
     file_cube, match_timings, _ = Parser.split_combatlog(lines, player_list)
     player_name = Parser.get_player_name(lines)
     match = file_cube[match_index]
     results = matchstats.match_statistics(file_name, match, match_timings[::2][match_index])
     self.update_widgets(*results)
     match_list = Parser.build_spawn_from_match(match)
     self.main_window.middle_frame.time_view.insert_spawn(match_list, player_name)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:23,代碼來源:fileframe.py

示例15: _process_new_file

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_player_id_list [as 別名]
 def _process_new_file(self):
     """Backlog only the lines of a match that are match lines"""
     print("[LogStalker] Processing new file.")
     lines = self.read_file(self.path, 0)
     if len(lines) == 0:
         return
     player_list = Parser.get_player_id_list(lines)
     file_cube, _, _ = Parser.split_combatlog(lines, player_list)
     if len(file_cube) == 0:
         print("[LogStalker] No matches in this file")
         self._read_so_far = len(lines)
         return
     last_line = file_cube[-1][-1][-1]
     if last_line["time"] == lines[-1]["time"]:
         print("[LogStalker] Match still active")
         # Last line is still a match line
         match_len = sum(len(spawn) for spawn in file_cube[-1])
         self._read_so_far = len(lines) - match_len
         return
     # Last line is no longer a match
     print("[LogStalker] Last line is not a match event")
     self._read_so_far = len(lines)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:24,代碼來源:logstalker.py


注:本文中的parsing.parser.Parser.get_player_id_list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。