Files

736 lines
30 KiB
Python

import requests
from PIL import Image
from PIL import ImageFilter
from PIL import ImageEnhance
from PIL import ImageDraw, ImageFont
from datetime import datetime, timedelta
import os
import json
from Player_Query import Character_Query
class Vechile_Character_Query():
#def Character_date(self, name):
async def Character_date(self, name):
url = "https://api.sunderer.games/census/character/search"
querystring = {"name": ""}
querystring["name"] = name
response = requests.request("GET", url, params=querystring)
response = response.json()
# print(response)
return response
#def Date_Rinse_common(self, date, num=13):
async def Date_Rinse_common(self, date, num=13):
# 加载图片
file_path = os.path.dirname(os.path.abspath(__file__))
icon_dir = os.path.join(file_path, "Vechile_query/download")
Source_dir = os.path.join(file_path, "Vechile_query/Source")
Player_query_Source_dir = os.path.join(file_path, "Charter_Sundy_Query")
screen1_dir = (
os.path.join(file_path, "Vechile_query/screen1")
)
screen2_dir = (
os.path.join(file_path, "Vechile_query/screen2")
)
bruh = "wrel.png"
by_path = "love.png"
ad_path = "ad_test.png"
botton_path = "上面的丁真.png"
Logo_path = "顶部LOGO.png"
lable_path = "ID框.png"
tr_path = "地球共和国.png"
vs_path = "瓦努主权国.png"
nc_path = "新联邦.png"
nso_path = "纳能特工.png"
level_path = "战斗等级底图.png"
asp1_path = "asp1.png"
asp2_path = "asp2.png"
asp3_path = "asp3.png"
online_path = "在线状态.png"
offline_path = "离线状态.png"
online_none_path = "无历史数据在线状态.png"
offline_none_path = "无历史数据离线状态.png"
money_path = "证书数量.png"
sol_path = "索泰克.png"
eme_path = "艾莫若德.png"
con_path = "康纳利.png"
cob_path = "柯伯特.png"
mil_path = "米勒.png"
other_path = "其他数据底图.png"
tr_botton_path = "地球共和国背景.png"
vs_botton_path = "瓦努主权国背景.png"
nc_botton_path = "新联邦背景.png"
nso_botton_path = "纳能特工背景.png"
message_path = '缩写含义.png'
screen_demo = "demo.png"
afd_path = 'afd.png'
box_path = "框框.png"
article_path = "条条.png"
up_path = "从低到高.png"
down_path = "从高到低.png"
judou_heavy = "judou-ui-cn-heavy.ttf"
judou_heavyit = "judou-ui-cn-heavyitalic.ttf"
judou_blod = "judou-bold.ttc"
judou_media = "judou-medium.ttc"
##
message = Image.open(os.path.join(
Source_dir, message_path)).convert("RGBA")
ad = Image.open(os.path.join(Source_dir, ad_path)).convert("RGBA")
by = Image.open(os.path.join(Source_dir, by_path)).convert("RGBA")
botton = Image.open(os.path.join(
Source_dir, botton_path)).convert("RGBA")
Logo = Image.open(os.path.join(Source_dir, Logo_path)).convert("RGBA")
lable = Image.open(os.path.join(
Source_dir, lable_path)).convert("RGBA")
tr_icon = Image.open(os.path.join(Source_dir, tr_path)).convert("RGBA")
vs_icon = Image.open(os.path.join(Source_dir, vs_path)).convert("RGBA")
nc_icon = Image.open(os.path.join(Source_dir, nc_path)).convert("RGBA")
nso_icon = Image.open(os.path.join(
Source_dir, nso_path)).convert("RGBA")
tr_botton = Image.open(os.path.join(
Source_dir, tr_botton_path)).convert("RGBA")
vs_botton = Image.open(os.path.join(
Source_dir, vs_botton_path)).convert("RGBA")
nc_botton = Image.open(os.path.join(
Source_dir, nc_botton_path)).convert("RGBA")
nso_botton = Image.open(os.path.join(
Source_dir, nso_botton_path)).convert("RGBA")
Soltech = Image.open(os.path.join(
Source_dir, sol_path)).convert("RGBA")
Miller = Image.open(os.path.join(Source_dir, mil_path)).convert("RGBA")
Cobalt = Image.open(os.path.join(Source_dir, cob_path)).convert("RGBA")
Connery = Image.open(os.path.join(
Source_dir, con_path)).convert("RGBA")
Emerald = Image.open(os.path.join(
Source_dir, eme_path)).convert("RGBA")
level_icon = Image.open(os.path.join(
Source_dir, level_path)).convert("RGBA")
asp1_icon = Image.open(os.path.join(
Source_dir, asp1_path)).convert("RGBA")
asp2_icon = Image.open(os.path.join(
Source_dir, asp2_path)).convert("RGBA")
asp3_icon = Image.open(os.path.join(
Source_dir, asp3_path)).convert("RGBA")
online = Image.open(os.path.join(
Source_dir, online_path)).convert("RGBA")
offline = Image.open(os.path.join(
Source_dir, offline_path)).convert("RGBA")
money_icon = Image.open(os.path.join(
Source_dir, money_path)).convert("RGBA")
other_icon = Image.open(os.path.join(
Source_dir, other_path)).convert("RGBA")
box = Image.open(os.path.join(Source_dir, box_path)).convert("RGBA")
article = Image.open(os.path.join(
Source_dir, article_path)).convert("RGBA")
up = Image.open(os.path.join(Source_dir, up_path)).convert("RGBA")
down = Image.open(os.path.join(Source_dir, down_path)).convert("RGBA")
afd = Image.open(os.path.join(Source_dir, afd_path)).convert("RGBA")
Title = ImageFont.truetype(
(os.path.join(Source_dir, judou_blod)),
88,
)
Numttf = ImageFont.truetype(
(os.path.join(Source_dir, judou_heavy)),
240,
)
No_ver_Name_ttf = ImageFont.truetype(
(os.path.join(Source_dir, judou_heavy)),
308,
)
Ver_NickName_ttf = ImageFont.truetype(
(os.path.join(Source_dir, judou_heavy)),
264,
)
Ver_ChartName_ttf = ImageFont.truetype(
(os.path.join(Source_dir, judou_heavy)),
88,
)
content = ImageFont.truetype(
(os.path.join(Source_dir, judou_blod)),
52,
)
status_time = ImageFont.truetype(
((os.path.join(Source_dir,judou_heavy))),
88,
)
text_lable = ImageFont.truetype(
(os.path.join(Source_dir, judou_heavy)),
24,
)
heavyit = ImageFont.truetype(
(os.path.join(Source_dir, judou_heavyit)),
88,
)
width, height = botton.size
logo_w, logo_h = Logo.size
logo_r, logo_g, logo_b, logo_a = Logo.split()
lable_r, lable_g, lable_b, lable_a = lable.split()
level_r, level_g, level_b, level_a = level_icon.split()
asp1_r, asp1_g, asp1_b, asp1_a = asp1_icon.split()
asp2_r, asp2_g, asp2_b, asp2_a = asp2_icon.split()
asp3_r, asp3_g, asp3_b, asp3_a = asp3_icon.split()
online_r, online_g, online_b, online_a = online.split()
offline_r, offline_g, offline_b, offline_a = offline.split()
tr_botton_r, tr_botton_g, tr_botton_b, tr_botton_a = tr_botton.split()
vs_botton_r, vs_botton_g, vs_botton_b, vs_botton_a = vs_botton.split()
nc_botton_r, nc_botton_g, nc_botton_b, nc_botton_a = nc_botton.split()
nso_botton_r, nso_botton_g, nso_botton_b, nso_botton_a = nso_botton.split()
Soltech_r, Soltech_g, Soltech_b, Soltech_a = Soltech.split()
Miller_r, Miller_g, Miller_b, Miller_a = Miller.split()
Cobalt_r, Cobalt_g, Cobalt_b, Cobalt_a = Cobalt.split()
Connery_r, Connery_g, Connery_b, Connery_a = Connery.split()
Emerald_r, Emerald_g, Emerald_b, Emerald_a = Emerald.split()
money_r, money_g, money_b, money_a = money_icon.split()
other_r, other_g, other_b, other_a = other_icon.split()
tr_r, tr_g, tr_b, tr_a = tr_icon.split()
vs_r, vs_g, vs_b, vs_a = vs_icon.split()
nc_r, nc_g, nc_b, nc_a = nc_icon.split()
nso_r, nso_g, nso_b, nso_a = nso_icon.split()
box_r, box_g, box_b, box_a = box.split()
article_r, article_g, article_b, article_a = article.split()
up_r, up_g, up_b, up_a = up.split()
down_r, down_g, down_b, down_a = down.split()
message_r, message_g, message_b, message_a = message.split()
ad_r, ad_g, ad_b, ad_a = ad.split()
by_r, by_g, by_b, by_a = by.split()
afd_r, afd_g, afd_b, afd_a = afd.split()
All_kill = "总击杀"
All_death = "总死亡"
All_KDR = "总KDR"
# 基础信息
Character_BasicDate = date["basicInfo"]
charactername = Character_BasicDate["characterFullName"]
outfitAlias = Character_BasicDate["outfitAlias"]
outfitName = Character_BasicDate["outfitName"]
factionId = Character_BasicDate["factionId"]
serverName = Character_BasicDate["worldName"]
money = str(Character_BasicDate["availableCertCount"])
battleRank = Character_BasicDate["battleRank"]
aspRank = Character_BasicDate["aspRank"]
FullName = Character_BasicDate["characterFullName"]
# Character_Server = Character_BasicDate['Server']
# Character_ = Character_BasicDate['']
asplevel = Character_BasicDate["aspRank"]
online = Character_BasicDate["online"]
All_kill_date = Character_BasicDate["kill"]
All_death_date = Character_BasicDate["death"]
All_KDR_date = "%.2f" % Character_BasicDate["kdr"]
All_kill = "总击杀"
All_death = "总死亡"
All_KDR = "总KDR"
if outfitName == None:
outfitName = ''
try:
title = str("[" + outfitAlias + "]" + " " + FullName)
except:
title = FullName
lv = str("Lv." + str(battleRank))
off = "已离线"
off_time = ""
on_time = ""
on = "已在线"
w_on_time, h_on_time = Title.getsize(on_time)
w_off_time, h_off_time = Title.getsize(off_time)
w_All_kill_date, h_All_kill_date = Title.getsize(str(All_kill_date))
w_All_death_date, h_All_death_date = Title.getsize(str(All_death_date))
w_All_KDR_date, h_All_KDR_date = Title.getsize(str(All_KDR_date))
w_outfitName, h_outfitName = content.getsize(str(outfitName))
date_common = Image.new("RGBA", (width, height), (0,124,212,100))
date_common.paste(botton, (0, 0))
#date_common.show()#上部数据
#判断是否认证
Sundy_auth = False
user_message = None
chart_msg = date['basicInfo']['characterFullName']
file_path_csv = os.path.join(os.path.dirname(__file__), r"csv/character.csv")
auth_dict = await Character_Query().csv_Verified_User(file_path_csv)#异步
if chart_msg in auth_dict.values():
Sundy_auth = True
matching_keys = [key for key, value in auth_dict.items() if value == chart_msg]
ver_chart_id = int(matching_keys[0])
csv_file_nickname = os.path.join(os.path.dirname(__file__), r"csv/nickname.csv")
nickname_csv = await Character_Query().read_csv_to_list(csv_file_nickname)
chart_list = await Character_Query().find_id(ver_chart_id,nickname_csv)
ver_charactername = chart_list[1]
if Sundy_auth == False:
Sundy_auth = False
chart_msg = chart_msg[0:3] + "**" + chart_msg[-2:]
Online_flag = date['basicInfo']['online']
lastLoginfo = date['latestSessionInfo']['latestLoginDate']
lastLogout = date['latestSessionInfo']['latestLogoutDate']
try:
if Online_flag == True :
logintimeline = (lastLoginfo)/1000
logintime = datetime.fromtimestamp(logintimeline)
formatted_time = logintime.strftime("%Y-%m-%d %H:%M:%S")
elif Online_flag == False :
Logouttimeline = (lastLogout)/1000
Logouttime = datetime.fromtimestamp(Logouttimeline)
formatted_time = Logouttime.strftime("%Y-%m-%d %H:%M:%S")
except:
formatted_time = '数据库无记录'
if Sundy_auth == False :#QQbot\Charter_Sundy_Query\步兵武器列表\状态\在线文字背景.png
Status_light = os.path.join(Player_query_Source_dir,'步兵武器列表/状态/在线圆点.png')
status_text = 'ONLINE NOW ' + formatted_time
BackGround_path = os.path.join(Player_query_Source_dir,'步兵武器列表/状态/在线文字背景.png')
color = (0,252,155)
else:
Status_light = os.path.join(Player_query_Source_dir,'步兵武器列表/状态/离线圆点.png')
status_text = 'OFFLINE At ' + formatted_time
BackGround_path = os.path.join(Player_query_Source_dir,'步兵武器列表/状态/离线文字背景.png')
color = (255,255,255)
light = Image.open(Status_light).convert("RGBA")
light_shadow = Image.open(BackGround_path).convert("RGBA")
w,h = status_time.getsize(status_text)
r,g,b,a = light.split()
date_common.paste(light,(2000-w-220,700+20),mask=a)
r,g,b,a = light_shadow.split()
date_common.paste(light_shadow,(2000-w-820,700-20),mask=a)
date_common_pic = ImageDraw.Draw(date_common)
date_common_pic.text(((2000-w-120),700),str(status_text),fill=(255,255,255),font=status_time)
if Sundy_auth == False :
w_tit,h_tit = No_ver_Name_ttf.getsize(chart_msg)
x_No_ver_Name = 2000 - w_tit -100
date_common_pic.text(
(x_No_ver_Name, 250),
chart_msg,
fill=(255,255,255),
font=No_ver_Name_ttf
)
else:
w_tit,h_tit = Ver_NickName_ttf.getsize(ver_charactername)
x_ver_nickName = 2000 - w_tit -100
date_common_pic.text(
(x_ver_nickName, 120),
ver_charactername,
fill=(255,255,255),
font=Ver_NickName_ttf
)
w_tit,h_tit = Ver_ChartName_ttf.getsize(chart_msg)
x_ver_nickName = 2000 - w_tit -100
date_common_pic.text(
(x_ver_nickName, 410),
chart_msg,
fill=(255,255,255),
font=Ver_ChartName_ttf
)
# 提取载具数据
Character_BattleData = date["battleData"]
# Character_Battle_weaponStatList
landVehicleData = Character_BattleData["vehicleData"]["landVehicleData"]["vehicleData"]
waterVehicleData = Character_BattleData["vehicleData"]["waterVehicleData"]["vehicleData"]
otherVehicleData = Character_BattleData["vehicleData"]["otherVehicleData"]["vehicleData"]
airVehicleData = Character_BattleData["vehicleData"]["airVehicleData"]["vehicleData"]
# 打开特定底图
screen1 = Image.open(os.path.join(
screen1_dir, screen_demo)).convert("RGBA")
screen2 = Image.open(os.path.join(
screen2_dir, screen_demo)).convert("RGBA")
w_screen1, h_screen1 = screen1.size
w_screen1r, w_screen1g, w_screen1b, w_screen1a = screen1.split()
# 筛选标题和横幅
text = "载具总览"
w_text, h_text = Title.getsize(text)
w_tiaotiao, h_tiaotiao = article.size
# 坐标数据
h_act = 40
hlist = []
for i in range(0, num):
hf = h_tiaotiao + h_screen1 * i - h_act * (i + 1)
hlist.append(hf)
# 计算总高度并生成新画布
h_scr = h_screen1 * num + h_tiaotiao - h_act * (num)
date_screen = Image.new("RGBA", (w_screen1, h_scr), (0, 124,212,100))
date_screen.paste(article, (0, 0), article_a)
date_screen.paste(down, (0, 0), down_a)
# 区别排列数据展示框
for i in range(0, num):
if i % 2 == 0:
if i == 0:
date_screen.paste(message, (0, hlist[i]), message_a)
else:
date_screen.paste(screen1, (0, hlist[i]), w_screen1a)
else:
date_screen.paste(screen2, (0, hlist[i]), w_screen1a)
# date_screen.paste(by, (0, hlist[-1]+h_screen1-h_act), by_a)
# 添加数据
date_screen_pic = ImageDraw.Draw(date_screen)
date_screen_pic.text(
(((w_screen1 - w_text) / 2), 50),
text,
fill=(0, 0, 0),
font=Title,
)
# date_screen.paste(by, (0, hlist[-1]+h_screen1-h_act), by_a)
# 敌前三的武器数据
# sorted_list = (sorted(Character_Battle_weaponStatList, key=lambda x: x['kill']))[-3:]
# sorted_list = Character_Battle_weaponStatList[:(num-1)]
sorted_list = await filtrate_common().vehicle_filtrate_common(Character_BattleData, factionId)
#await
# sorted_list = (sorted(sorted_list1, key=lambda x: x['kill']))
#sorted_list.insert(3, AD) 插入广告用
for i in range(0, len(sorted_list)):
kill = sorted_list[i]["kill"]
kps = sorted_list[i]["spk"]
hit = sorted_list[i]["hit"]
fire = sorted_list[i]["fire"]
accuracy = sorted_list[i]["accuracy"]
rdkill = sorted_list[i]["roadKill"]
hpk = "%.2f" % sorted_list[i]["hpk"] # 命中数量/击杀数量
playTime = int(((sorted_list[i]["playTime"])))
minutes, seconds = divmod(playTime, 60)
hours, minutes = divmod(minutes, 60)
days, hours = divmod(hours, 24)
dtime = f"{days}{hours}{minutes}{seconds}秒"
imageID = sorted_list[i]["imageId"]
name = sorted_list[i]["name"]
damage = (sorted_list[i]["damage"])/10000
dmg = (("%.2f" % damage) + 'W')
try:
icon = str(imageID + ".png")
except:
if i == 3:
icon = str('none.png')
else:
icon = str('wrel.png')
weapon_icondir = str(os.path.join(icon_dir, icon))
# 拆分名字
string_B = ""
try:
splitted = name.split(" ")
string_A = splitted[0] # 获取第一个部分
string_B = ''.join(str(x)
for x in splitted[1:]) # 获取第二个部分
except:
string_A = name
w_string_A, h_string_A = Title.getsize(str(string_A))
w_string_B, h_string_B = Title.getsize(str(string_B))
if w_string_A + w_string_B < 465:
string_A = name
string_B = ''
w_string_A, h_string_A = Title.getsize(str(string_A))
w_string_B, h_string_B = Title.getsize(str(string_B))
# 计算参数
try:
weapon = Image.open(weapon_icondir).convert("RGBA")
except:
weapon = Image.open(
str(os.path.join(Source_dir, bruh))).convert("RGBA")
weapon_r, weapon_g, weapon_b, weapon_a = weapon.split()
w_kill, h_kill = heavyit.getsize(str(kill))
w_death, h_death = Title.getsize(str(fire))
w_hsr, h_hsr = Title.getsize(str(hit))
w_accuracy, h_accuracy = Title.getsize(str(accuracy))
w_kdr, h_kdr = Title.getsize(str(kps))
w_kpm, h_kpm = Title.getsize(str(dmg))
w_hpk, h_hpk = Title.getsize(str(hpk))
w_ivi, h_ivi = Title.getsize(str(rdkill))
w_playTime, h_playTime = Title.getsize(str(dtime))
interval = 860
(x, y) = weapon.size
x_s = 400 # 定义缩小后的标准宽度
y_s = int(y * x_s / x) # 基于标准宽度计算缩小后的高度
weapon1 = weapon.resize((x_s, y_s), Image.ANTIALIAS)
r, g, b, a = weapon1.split()
if weapon.size == (128, 128):
date_screen.paste(
weapon1, (110, (360 + interval + interval * i)), a)
elif weapon.size == (400, 400):
date_screen.paste(
weapon1, (110, (360 + interval + interval * i)), a)
else:
date_screen.paste(
weapon1, (110, (460 + interval + interval * i)), a)
date_screen_pic.text(
(20, 150 + interval + interval * i),
str(i+1),
fill=(255, 255, 255), # 255, 87, 23
font=Numttf, # heavyit
)
date_screen_pic.text(
((850 + (370 - w_kill) / 2), 333 + interval + interval * i),
str(kill),
fill=(0, 0, 0), # 255, 87, 23
font=Title, # heavyit
)
date_screen_pic.text(
((850 + (370 - w_death) / 2), 475 + interval + interval * i),
str(fire),
fill=(0, 0, 0),
font=Title,
)
date_screen_pic.text(
((850 + (370 - w_hsr) / 2), 617 + interval + interval * i),
str(hit),
fill=(0, 0, 0),
font=Title,
)
date_screen_pic.text(
((850 + (370 - w_accuracy) / 2),
753 + interval + interval * i),
str(accuracy),
fill=(0, 0, 0),
font=Title,
)
date_screen_pic.text(
((1540 + (370 - w_kdr) / 2), 333 + interval + interval * i),
str(kps),
fill=(0, 0, 0),
font=Title,
)
date_screen_pic.text(
((1540 + (370 - w_kpm) / 2), 475 + interval + interval * i),
str(dmg),
fill=(0, 0, 0),
font=Title,
)
date_screen_pic.text(
((1540 + (370 - w_hpk) / 2), 617 + interval + interval * i),
str(hpk),
fill=(0, 0, 0),
font=Title,
)
date_screen_pic.text(
((1540 + (370 - w_ivi) / 2), 753 + interval + interval * i),
str(rdkill),
fill=(0, 0, 0),
font=Title,
)
if w_string_A > 465:
Title_s = ImageFont.truetype(
(os.path.join(Source_dir, judou_blod)),
64,
)
w_string_A, h_string_A = Title_s.getsize(str(string_A))
date_screen_pic.text(
((65 + (465 - w_string_A) / 2),
830 + interval + interval * i),
str(string_A),
fill=(0, 67, 48),
font=Title_s,
)
else:
date_screen_pic.text(
((65 + (465 - w_string_A) / 2),
830 + interval + interval * i),
str(string_A),
fill=(0, 67, 48),
font=Title,
)
if w_string_B > 465:
Title_s = ImageFont.truetype(
(os.path.join(Source_dir, judou_blod)),
64,
)
w_string_B, h_string_B = Title_s.getsize(str(string_B))
if w_string_B > 465:
None
else:
date_screen_pic.text(
((65 + (465 - w_string_B) / 2),
920 + interval + interval * i),
str(string_B),
fill=(0, 67, 48),
font=Title_s,
)
else:
date_screen_pic.text(
((65 + (465 - w_string_B) / 2),
920 + interval + interval * i),
str(string_B),
fill=(0, 67, 48),
font=Title,
)
date_screen_pic.text(
((1030 + (870 - w_playTime) / 2),
912 + interval + interval * i+3),
str(dtime),
fill=(0, 0, 0),
font=Title,
)
w_screen, h_screen = date_screen.size
h = height + h_screen
date1 = Image.new("RGBA", (w_screen1, h), (0,124,212,0))
sr, sg, sb, sa = date_screen.split()
te = h_screen + 1900
# 生成最终图
date1.paste(date_common, (0, 0))
date1.paste(date_screen, (0, 900), sa)
date1.paste(by, (0, te), by_a)
"""# 添加广告信息
w_afd, h_afd = afd.size
w_date1, h_date1 = date1.size
h_adlast = h_afd + h_date1
date2 = Image.new("RGBA", (w_date1, h_adlast), (4, 212, 155, 0))
dr, dg, db, da = date1.split()
date2.paste(date1, (0, 0), da)
date2.paste(afd, (0, h_date1))"""
# 保存
# date1.save('test.png')
w_date1, h_date1 = date1.size
date2 = date1.convert("RGB")
date2 = date2.resize((w_date1, h_date1), Image.ANTIALIAS)
filename = str(charactername) + '.jpg'
Output_dir = os.path.join(file_path, "Charter_Sundy_Query/Output")
output = os.path.join(Output_dir, filename)
date2.save(output, "JPEG", quality=70, subsampling=0)
return filename
# return date1
class filtrate_common():
#def txt_reader(self):
async def txt_reader(self):
with open("GGou7.txt", "r", encoding='gbk') as file:
lines = file.read().strip("'").strip('"')
lines = lines.replace("\n", "")
lines = lines.replace("\t", "")
lines = lines.strip("'")
lines = json.loads(lines)
# lines = lines.strip()
return lines
#def vehicle_filtrate_common(self, Character_BattleData, factionId):
async def vehicle_filtrate_common(self, Character_BattleData, factionId):
landVehicleData = Character_BattleData["vehicleData"]["landVehicleData"]["vehicleData"]
waterVehicleData = Character_BattleData["vehicleData"]["waterVehicleData"]["vehicleData"]
otherVehicleData = Character_BattleData["vehicleData"]["otherVehicleData"]["vehicleData"]
airVehicleData = Character_BattleData["vehicleData"]["airVehicleData"]["vehicleData"]
date_list = [landVehicleData, waterVehicleData,
otherVehicleData, airVehicleData]
nc_list = ["Reaver", "Vanguard", "Flash", "Harasser", "Sunderer", "Lightning",
"Corsair", "Valkyrie", "Liberator", "Galaxy", "Colossus", "Bastion Fleet Carrier", "Flash XS-1", "Drop Pod",]
vs_list = ["Scythe", "Magrider", "Flash", "Harasser", "Sunderer", "Lightning",
"Corsair", "Valkyrie", "Liberator", "Galaxy", "Colossus", "Bastion Fleet Carrier", "Flash XS-1", "Drop Pod",]
tr_list = ["Mosquito", "Prowler", "Flash", "Harasser", "Sunderer", "Lightning",
"Corsair", "Valkyrie", "Liberator", "Galaxy", "Colossus", "Bastion Fleet Carrier", "Flash XS-1", "Drop Pod",]
nso_list = ["Dervish", "Chimera", "Flash", "Harasser", "Sunderer", "Lightning",
"Corsair", "Valkyrie", "Liberator", "Galaxy", "Colossus", "Bastion Fleet Carrier", "Flash XS-1", "Drop Pod",]
text = []
output = []
if factionId == "1":
for b in range(0, len(date_list)):
for i in range(0, len(date_list[b])):
mid = date_list[b][i]
partial_dict = {k: mid[k] for k in list(mid.keys())[:-1]}
text.append(partial_dict)
test = [item for item in text if item["engName"] in vs_list]
def custom_order_index(item):
return vs_list.index(item["engName"])
sorted_list = sorted(test, key=custom_order_index)
# output.append(test)
elif factionId == "2":
for b in range(0, len(date_list)):
for i in range(0, len(date_list[b])):
mid = date_list[b][i]
partial_dict = {k: mid[k] for k in list(mid.keys())[:-1]}
text.append(partial_dict)
test = [item for item in text if item["engName"] in nc_list]
def custom_order_index(item):
return nc_list.index(item["engName"])
sorted_list = sorted(test, key=custom_order_index)
elif factionId == "2":
for b in range(0, len(date_list)):
for i in range(0, len(date_list[b])):
mid = date_list[b][i]
partial_dict = {k: mid[k] for k in list(mid.keys())[:-1]}
text.append(partial_dict)
test = [item for item in text if item["engName"] in tr_list]
def custom_order_index(item):
return tr_list.index(item["engName"])
sorted_list = sorted(test, key=custom_order_index)
# output.append(test)
else:
for b in range(0, len(date_list)):
for i in range(0, len(date_list[b])):
mid = date_list[b][i]
partial_dict = {k: mid[k] for k in list(mid.keys())[:-1]}
text.append(partial_dict)
test = [item for item in text if item["engName"] in nso_list]
# output.append(test)
def custom_order_index(item):
return nso_list.index(item["engName"])
sorted_list = sorted(test, key=custom_order_index)
# return sorted_list
return sorted_list
"""name = "GGou7"
date = Vechile_await Character_Query().Character_date(name)
# date = Vechile_await Character_Query().txt_reader()
start = Vechile_await Character_Query().Date_Rinse_common(date)
print(start)"""