diff --git a/WOTSTAT/res/scripts/client/gui/mods/wot_stat/logger/eventLogger.py b/WOTSTAT/res/scripts/client/gui/mods/wot_stat/logger/eventLogger.py index cad2bc2..9b86bf4 100644 --- a/WOTSTAT/res/scripts/client/gui/mods/wot_stat/logger/eventLogger.py +++ b/WOTSTAT/res/scripts/client/gui/mods/wot_stat/logger/eventLogger.py @@ -7,6 +7,8 @@ from ..utils import print_debug from ..load_mod import config +from ..thirdParty.dataProviderExtension import triggerEvent + class EventLogger: old_battle_event_sessions = {} battle_event_session = None # type: BattleEventSession @@ -41,6 +43,7 @@ def emit_event(self, event, arena_id=None): if self.battle_event_session: self.battle_event_session.add_event(event) + triggerEvent(event.get_dict()) eventLogger = EventLogger() diff --git a/WOTSTAT/res/scripts/client/gui/mods/wot_stat/logger/loggers/onBattleResultLogger.py b/WOTSTAT/res/scripts/client/gui/mods/wot_stat/logger/loggers/onBattleResultLogger.py index fbff763..018f185 100644 --- a/WOTSTAT/res/scripts/client/gui/mods/wot_stat/logger/loggers/onBattleResultLogger.py +++ b/WOTSTAT/res/scripts/client/gui/mods/wot_stat/logger/loggers/onBattleResultLogger.py @@ -71,6 +71,7 @@ def process_battle_result(self, results): teamHealth = [results['common']['teamHealth'][1], results['common']['teamHealth'][2]] players = results['players'] + avatars = results['avatars'] vehicles = results['vehicles'] playersResultList = list() @@ -113,14 +114,16 @@ def getVehicleInfo(vehicle): 'tankRole': get_tank_role(veWG.role), 'maxHealth': vehicle['maxHealth'], 'health': max(0, vehicle['health']), - 'isAlive': vehicle['health'] > 0 + 'isAlive': vehicle['health'] > 0, } for vehicleId in vehicles: vehicle = vehicles[vehicleId][0] bdid = vehicle['accountDBID'] if bdid not in players: continue + if bdid not in avatars: continue player = players[bdid] + avatar = avatars[bdid] squadID = player['prebattleID'] res = { 'name': player['realName'], @@ -128,6 +131,7 @@ def getVehicleInfo(vehicle): 'bdid': bdid, 'team': player['team'], 'xp': vehicle['xp'], + 'playerRank': avatar['playerRank'], '__vehicleId': vehicleId } res.update(getVehicleInfo(vehicle)) @@ -153,6 +157,7 @@ def getVehicleInfo(vehicle): 'xp': personalRes['originalXP'], 'killerIndex': indexById[killerId] if killerId in indexById else -1, 'squadID': squadStorage[squadID] if squadID in squadStorage else 0, + 'playerRank': avatar['playerRank'], } personal.update(getVehicleInfo(personalRes)) diff --git a/WOTSTAT/res/scripts/client/gui/mods/wot_stat/thirdParty/dataProviderExtension.py b/WOTSTAT/res/scripts/client/gui/mods/wot_stat/thirdParty/dataProviderExtension.py new file mode 100644 index 0000000..c42cee5 --- /dev/null +++ b/WOTSTAT/res/scripts/client/gui/mods/wot_stat/thirdParty/dataProviderExtension.py @@ -0,0 +1,50 @@ +import BigWorld +from ..utils import print_log +from typing import List + +# typing for intellisense +class ITrigger(object): + def trigger(self, value=None): pass + +class IState(object): + def getValue(self): pass + def setValue(self, value): pass + +class IExtension(object): + def createState(self, path, initialValue = None): + # type: (List[str], any) -> IState + pass + + def createTrigger(self, path): + # type: (List[str]) -> ITrigger + pass + +class IDataProviderSDK(object): + version = None # type: int + def registerExtension(self, name): + # type: (str) -> IExtension + pass + + +onEventTrigger = None # type: ITrigger + +def triggerEvent(event): + if onEventTrigger: + onEventTrigger.trigger(event) + +def setupExtension(): + global onEventTrigger + + if not hasattr(BigWorld, 'wotstat_dataProvider'): + return + + provider = BigWorld.wotstat_dataProvider # type: IDataProviderSDK + + providerVersion = provider.version + extension = provider.registerExtension('wotstat') + onEventTrigger = extension.createTrigger(['onEvent']) + + print_log('Extension setup complete. Data provider version: %s' % str(providerVersion)) + + +BigWorld.callback(0.1, setupExtension) \ No newline at end of file