Skip to content

Commit

Permalink
player rank + trigger event
Browse files Browse the repository at this point in the history
  • Loading branch information
SoprachevAK committed Aug 25, 2024
1 parent d5b83d1 commit 351ff26
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -113,21 +114,24 @@ 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'],
'squadID': squadStorage[squadID] if squadID in squadStorage else 0,
'bdid': bdid,
'team': player['team'],
'xp': vehicle['xp'],
'playerRank': avatar['playerRank'],
'__vehicleId': vehicleId
}
res.update(getVehicleInfo(vehicle))
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 351ff26

Please sign in to comment.