This commit is contained in:
Jylpah committed 2020-11-27 18:13:50 +02:00
commit be4f870a18
4 files changed
+113 -17

No files matched your search

+22 -10
View File
@@ -127,9 +127,12 @@ class BattleCategorizationList():
'total' : [ 'TOTAL', 'total' ],
'battle_result' : [ 'Result', 'category', [ 'Loss', 'Win', 'Draw']],
'battle_type' : [ 'Battle Type', 'category', [ 'Encounter', 'Supremacy']],
'tank_tier' : [ 'Tank Tier', 'number' ],
'top_tier' : [ 'Tier', 'category', [ 'Bottom tier', 'Top tier']],
'room_type' : [ 'Battle Mode', 'category', _BATTLE_MODES ],
'top_tier' : [ 'Tier', 'category', [ 'Bottom tier', 'Top tier']],
'tank_tier' : [ 'Tank Tier', 'number' ],
'is_premium' : [ 'Tank Type', 'category', [ 'Tech tree', 'Premium']],
'tank_type' : [ 'Tank Class', 'category', WG.TANK_TYPE_STR],
'tank_nation' : [ 'Nation', 'category', WG.NATION_STR],
'mastery_badge' : [ 'Battle Medal', 'category', ['-', '3rd Class', '2nd Class', '1st Class', 'Mastery' ]],
'team_result' : [ 'Team Result', 'string' ],
'player_wins' : [ 'Player WR', 'bucket', [ 0, .35, .45, .50, .55, .65], '%' ],
@@ -140,11 +143,11 @@ class BattleCategorizationList():
'enemies_spotted' : [ 'Player Spots', 'number'],
'hit_rate' : [ 'Player Hit Rate', 'bucket', [ 0, .25, .5, .6, .7, .8, .9, .95 ], '%' ],
'pen_rate' : [ 'Player Pen Rate', 'bucket', [ 0, .25, .5, .6, .7, .8, .9, .95 ], '%' ],
'map_name' : [ 'Map', 'string' ],
'tank_name' : [ 'Tank', 'string' ],
'player_name' : [ 'Player', 'string' ],
'protagonist' : [ 'account_id', 'number' ],
'battle_i' : [ 'Battle #', 'number' ]
'player_name' : [ 'Player', 'string' ],
'protagonist' : [ 'account_id', 'number' ],
'tank_name' : [ 'Tank', 'string' ],
'map_name' : [ 'Map', 'string' ],
'battle_i' : [ 'Battle #', 'number' ]
}
_categorizations_default = [
@@ -1960,7 +1963,7 @@ async def mk_replayQ(queue : asyncio.Queue, args : argparse.Namespace, db : moto
if not line: break
if (p_replayfile.match(line) != None):
replay_json = await bu.open_JSON(line, wi.chk_JSON_replay)
replay_json = await bu.open_JSON(line, wi.chk_JSON_replay)
await queue.put(await mk_readerQ_item(replay_json, line))
except Exception as err:
bu.error(exception=err)
@@ -1993,7 +1996,13 @@ async def mk_replayQ(queue : asyncio.Queue, args : argparse.Namespace, db : moto
async def mk_readerQ_item(replay_json, filename : str = None) -> list:
"""Make an item to replay queue"""
global REPLAY_N
REPLAY_N +=1
REPLAY_N +=1
try:
if not '_id' in replay_json:
id = wi.read_replay_id(replay_json)
replay_json['_id'] = id
except Exception as err:
bu.error(exception=err)
if filename == None:
return [replay_json, REPLAY_N, '' ]
elif RE_SRC_IS_DB.match(filename) != None:
@@ -2117,7 +2126,10 @@ async def read_replay_JSON(replay_json: dict, args : argparse.Namespace) -> dict
tmp['account_id'] = account_id
tmp['tank_id'] = player['vehicle_descr']
tmp['tank_tier'] = player_tank_tier
tmp['tank_name'] = wg.get_tank_data(tmp['tank_id'], 'name')
tmp['tank_name'] = wg.get_tank_name(tmp['tank_id'])
tmp['tank_type'] = wg.get_tank_type_id(tmp['tank_id'])
tmp['tank_nation'] = wg.get_tank_nation_id(tmp['tank_id'])
tmp['is_premium'] = int(wg.is_premium(tmp['tank_id']))
tmp['squad_index'] = player['squad_index']
for key in replay_details_flds:
tmp[key] = player[key]
+89 -5
View File
@@ -756,7 +756,8 @@ class WG:
tanks = None
tanks_by_tier = None
NATIONS = [ 'ussr', 'germany', 'usa', 'china', 'france', 'uk', 'japan', 'other', 'european']
NATION = [ 'ussr', 'germany', 'usa', 'china', 'france', 'uk', 'japan', 'other', 'european']
NATION_STR = [ 'Soviet', 'Germany', 'USA', 'China', 'France', 'UK', 'Japan', 'Other', 'European']
NATION_ID = {
'ussr' : 0,
'germany' : 1,
@@ -769,7 +770,9 @@ class WG:
'european' : 8
}
TANK_TYPE = [ 'lightTank', 'mediumTank', 'heavyTank', 'AT-SPG' ]
TANK_TYPE = [ 'lightTank', 'mediumTank', 'heavyTank', 'AT-SPG' ]
TANK_TYPE_STR = [ 'Light Tank', 'Medium Tank', 'Heavy Tank', 'Tank Destroyer' ]
TANK_TYPE_ID = {
'lightTank' : 0,
'mediumTank' : 1,
@@ -906,7 +909,7 @@ class WG:
@classmethod
def get_tank_name(cls, tank_str: str) -> str:
def tank_str2name(cls, tank_str: str) -> str:
"""Return tank name from short tank string in replays"""
try:
return cls.tanks["userStr"][tank_str]
@@ -1348,8 +1351,79 @@ class WG:
return None
def get_tank_tier(self, tank_id: int):
return self.get_tank_data(tank_id, 'tier')
def get_tank_tier(self, tank_id: int) -> str:
try:
return self.get_tank_data(tank_id, 'tier')
except Exception as err:
error(exception=err)
return None
def get_tank_name(self, tank_id: int) -> str:
try:
return self.get_tank_data(tank_id, 'name')
except Exception as err:
error(exception=err)
return None
def get_tank_type(self, tank_id: int) -> str:
try:
return self.get_tank_data(tank_id, 'type')
except Exception as err:
error(exception=err)
return None
def get_tank_nation(self, tank_id: int) -> str:
try:
return self.get_tank_data(tank_id, 'nation')
except Exception as err:
error(exception=err)
return None
def get_tank_type_str(self, tank_id: int) -> str:
try:
tank_type = self.get_tank_data(tank_id, 'type')
return self.TANK_TYPE_STR[self.TANK_TYPE_ID[tank_type]]
except Exception as err:
error(exception=err)
return None
def get_tank_nation_str(self, tank_id: int) -> str:
try:
nation = self.get_tank_data(tank_id, 'nation')
return self.NATION_STR[self.NATION_ID[nation]]
except Exception as err:
error(exception=err)
return None
def get_tank_type_id(self, tank_id: int) -> str:
try:
tank_type = self.get_tank_data(tank_id, 'type')
return self.TANK_TYPE_ID[tank_type]
except Exception as err:
error(exception=err)
return None
def get_tank_nation_id(self, tank_id: int) -> str:
try:
nation = self.get_tank_data(tank_id, 'nation')
return self.NATION_ID[nation]
except Exception as err:
error(exception=err)
return None
def is_premium(self, tank_id: int) -> bool:
try:
return self.get_tank_data(tank_id, 'is_premium')
except Exception as err:
error(exception=err)
return None
async def put_2_statsQ(self, statsType: str, key: list, stats: list):
@@ -1747,6 +1821,16 @@ class WoTinspector:
return url.rsplit('/', 1)[-1]
@classmethod
def read_replay_id(cls, json_replay):
"""Read replay_id from replay JSON file"""
try:
url = json_replay['data']['view_url']
return cls.get_replay_id(url)
except Exception as err:
error(exception=err)
return None
@classmethod
def chk_JSON_replay(cls, json_resp):
""""Check String for being a valid JSON file"""
+1 -1
View File
@@ -49,7 +49,7 @@ async def main(argv):
wg = WG()
tasks = []
for nation in wg.NATIONS:
for nation in wg.NATION:
tasks.append(asyncio.create_task(extract_tanks(args.blitz_app_base, nation)))
tanklist = []
+1 -1
View File
@@ -286,7 +286,7 @@ def getTitle(replayfile: str, title: str = None, i : int = 0) -> str:
try:
metadata_json = json.load(meta)
#player = metadata_json['playerName']
tank = wg.get_tank_name(metadata_json['playerVehicleName'])
tank = wg.tank_str2name(metadata_json['playerVehicleName'])
map_name = wg.get_map(metadata_json['mapName'])
bu.debug('Tank: ' + tank + ' Map: ' + map_name)
except Exception as err: