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


Python Parser.get_event_category方法代码示例

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


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

示例1: _build_tracking_effects

# 需要导入模块: from parsing.parser import Parser [as 别名]
# 或者: from parsing.parser.Parser import get_event_category [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

示例2: insert_event

# 需要导入模块: from parsing.parser import Parser [as 别名]
# 或者: from parsing.parser.Parser import get_event_category [as 别名]
 def insert_event(self, line: dict, player_name, active_ids, start_time):
     """Insert a new line into the Treeview"""
     if line is None or line["type"] == Parser.LINE_EFFECT:
         return
     source, target = \
         map(partial(self.process_player, player_name, active_ids), (line["source"], line["target"]))
     source, target = map(self.format_id, (source, target))
     values = (
         TimeView.format_time_diff(line["time"], start_time),
         source, target,
         line["ability"],
         line["amount"] if line["amount"] != 0 else ""
     )
     tag = Parser.get_event_category(line, active_ids)
     if line["ability"].lower() not in self.icons and "icon" not in line:
         print("[TimeView] {} missing icon".format(line["ability"]))
         image = self.icons["default"]
     elif line["ability"].lower() in self.icons:
         image = self.icons[line["ability"].lower()]
     elif "icon" in line:
         d = self._icons if line["icon"] in self._icons else self.icons
         image = d[line["icon"].lower()]
     else:
         print("[TimeView] Missing Icon for: '{}'".format(line["ability"]))
         return
     iid = (repr(line["time"]) + line["source"] + line["target"] +
            line["effect"] + str(self.index))
     ref, start = map(partial(datetime.combine, datetime(1970, 1, 1).date()),
                      (line["time"].time(), start_time.time()))
     index = int((ref - start).total_seconds() * 10e3)
     self._contents.append(index)
     index = list(sorted(self._contents)).index(index)
     self.insert("", index, values=values, tags=(tag,), image=image, iid=iid)
     self.index += 1
     if "effects" not in line or line["effects"] is None:
         return
     if "custom" not in line or line["custom"] is False:
         self.insert_effects_for_event(iid, line, tag)
     else:
         self.insert_effects(iid, line["effects"], tag)
开发者ID:RedFantom,项目名称:GSF-Parser-Public,代码行数:42,代码来源:time_view.py

示例3: test_get_event_category

# 需要导入模块: from parsing.parser import Parser [as 别名]
# 或者: from parsing.parser.Parser import get_event_category [as 别名]
 def test_get_event_category(self):
     line = Parser.line_to_dictionary(self.LINE)
     self.assertEqual(Parser.get_event_category(line, "2963000048240"), "dmgt_pri")
     line = Parser.line_to_dictionary(self.EFFECT)
     self.assertEqual(Parser.get_event_category(line, "2963000049645"), "other")
开发者ID:RedFantom,项目名称:GSF-Parser-Public,代码行数:7,代码来源:test_parser.py


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