Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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")