Spaces:
Runtime error
Runtime error
File size: 3,654 Bytes
b8aecdd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
import json
import os
from functools import cache
import requests
from tqdm import tqdm
from qt.constant import MAX_BASE_ATTR, MAX_MAGIC_ATTR, MAX_EMBED_ATTR, MAX_ENCHANT_ATTR, MAX_STONE_ATTR, \
MAX_STONE_LEVEL, ATTR_TYPE_MAP, ATTR_TYPE_TRANSLATE, STONE_ATTR
from qt.constant import EQUIPMENTS_DIR, ENCHANTS_DIR, STONES_DIR
EQUIP_ATTR_MAP = {
"Overcome": "破防",
"Critical": "会心",
"CriticalDamage": "会效",
"Haste": "加速",
"Surplus": "破招",
"Strain": "无双"
}
POSITION_MAP = {
"hat": 3,
"jacket": 2,
"belt": 6,
"wrist": 10,
"bottoms": 8,
"shoes": 9,
"necklace": 4,
"pendant": 7,
"ring": 5,
"tertiary_weapon": 1,
"primary_weapon": 0
}
SUFFIX_MAP = {
3: 'armor',
2: 'armor',
6: 'armor',
10: 'armor',
8: 'armor',
9: 'armor',
4: 'trinket',
7: 'trinket',
5: 'trinket',
1: 'weapon',
0: 'weapon'
}
SPECIAL_ENCHANT_MAP = {
"3": {
12800: "15436-11",
11500: "15436-10",
10600: "15436-9"
},
"2": {
12800: "22151-11",
11500: "22151-10",
10600: "22151-9"
},
"6": {
0: "22169"
},
"10": {
0: "22166"
},
"9": {
0: "33247"
},
}
equip_min_level = 11000
equip_params = {
"client": "std",
"pv_type": 1,
"pz": 1,
"page": 1,
"per": 300,
"min_level": 9000,
"max_level": 15000
}
enchant_params = {
"client": "std",
"subtype": 1,
"latest_enhance": 1
}
# @cache
def get_equips_list(position):
position_id = POSITION_MAP[position]
url = f"https://node.jx3box.com/equip/{SUFFIX_MAP[position_id]}"
params = equip_params.copy()
params['position'] = position_id
equips = []
res = requests.get(url, params=params).json()
equips.extend(res['list'])
while res['pages'] > params['page']:
params['page'] += 1
res = requests.get(url, params=params).json()
equips.extend(res['list'])
return equips
@cache
def get_enchants_list(position):
position_id = POSITION_MAP[position]
url = f"https://node.jx3box.com/enchant/primary"
params = enchant_params.copy()
params['position'] = position_id
res = requests.get(url, params=params)
enchants = [e for e in sorted(res.json(), key=lambda x: x['Score'], reverse=True) if
e['Attribute1ID'] in ATTR_TYPE_MAP]
return enchants
def get_stones_list():
url = "https://node.jx3box.com/enchant/stone"
result = {}
for level in tqdm(range(MAX_STONE_LEVEL)):
level = level + 1
stones = []
params = {
"client": "std",
"level": level,
"page": 1,
"per": 100
}
res = requests.get(url, params=params).json()
stones.extend(res['list'])
while res['pages'] > params['page']:
params['page'] += 1
res = requests.get(url, params=params).json()
stones.extend(res['list'])
return result
if __name__ == '__main__':
if not os.path.exists(EQUIPMENTS_DIR):
os.makedirs(EQUIPMENTS_DIR)
if not os.path.exists(ENCHANTS_DIR):
os.makedirs(ENCHANTS_DIR)
for pos in tqdm(POSITION_MAP):
json.dump(
get_equips_list(pos),
open(os.path.join(EQUIPMENTS_DIR, pos), "w", encoding="utf-8"), ensure_ascii=False
)
json.dump(
get_enchants_list(pos),
open(os.path.join(ENCHANTS_DIR, pos), "w", encoding="utf-8"), ensure_ascii=False
)
json.dump(get_stones_list(), open(STONES_DIR, "w", encoding="utf-8"), ensure_ascii=False)
|