From 60a390d446485486d866ed5b014cc9c5afc0b82f Mon Sep 17 00:00:00 2001 From: Fedor Glazov Date: Fri, 9 Apr 2021 16:23:57 +0200 Subject: [PATCH] Conflate together turrets of same aircraft into one id. --- src/mod_rating_by_type/report.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mod_rating_by_type/report.py b/src/mod_rating_by_type/report.py index e505404..b9f7d67 100644 --- a/src/mod_rating_by_type/report.py +++ b/src/mod_rating_by_type/report.py @@ -40,16 +40,22 @@ def record_hits(target, attacker, ammo): target.sortie.ammo_breakdown[ALL_TAKEN] += 1 if attacker: + attacker_id = attacker.id + if attacker.cls == 'aircraft_turret' and attacker.parent and attacker.parent.sortie: + # Multiple turrets of an aircraft are counted together! + # That's why we take the aircraft's sortie. + attacker_id = attacker.parent.sortie.index + ammo_breakdown = target.sortie.ammo_breakdown if ammo_breakdown[LAST_DMG_OBJECT] is None and ammo_breakdown[LAST_DMG_SORTIE] is None: ammo_breakdown[DMG_FROM_ONE_SOURCE] = True else: if attacker.sortie and attacker.sortie.index != ammo_breakdown[LAST_DMG_SORTIE]: ammo_breakdown[DMG_FROM_ONE_SOURCE] = False - if attacker.id != target.sortie.ammo_breakdown[LAST_DMG_OBJECT]: + if attacker_id != target.sortie.ammo_breakdown[LAST_DMG_OBJECT]: ammo_breakdown[DMG_FROM_ONE_SOURCE] = False - ammo_breakdown[LAST_DMG_OBJECT] = attacker.id + ammo_breakdown[LAST_DMG_OBJECT] = attacker_id if attacker.sortie: ammo_breakdown[LAST_DMG_SORTIE] = attacker.sortie.index @@ -78,6 +84,7 @@ def default_ammo_breakdown(): DMG_FROM_ONE_SOURCE: False, LAST_DMG_SORTIE: None, LAST_DMG_OBJECT: None, + LAST_TURRET_ACCOUNT: None, }