mirror of
https://github.com/PaiGramTeam/genshin-wiki.git
synced 2024-11-30 02:44:10 +00:00
🔥 remove some useless code
This commit is contained in:
parent
fa5c315d67
commit
c04e90f26f
@ -102,61 +102,25 @@ class FoodQuality(StrEnum):
|
|||||||
"""美味的"""
|
"""美味的"""
|
||||||
|
|
||||||
|
|
||||||
# noinspection SpellCheckingInspection
|
|
||||||
class MaterialType(StrEnum):
|
|
||||||
Adsorbate = "ADSORBATE"
|
|
||||||
FakeAbsorbate = "FAKE_ABSORBATE"
|
|
||||||
Consume = "CONSUME"
|
|
||||||
Talent = "TALENT"
|
|
||||||
Avatar = "AVATAR"
|
|
||||||
Chest = "CHEST"
|
|
||||||
NoticeAddHp = "NOTICE_ADD_HP"
|
|
||||||
Exchange = "EXCHANGE"
|
|
||||||
Wood = "WOOD"
|
|
||||||
Quest = "QUEST"
|
|
||||||
Cricket = "CRICKET"
|
|
||||||
Widget = "WIDGET"
|
|
||||||
ElemCrystal = "ELEM_CRYSTAL"
|
|
||||||
SpiceFood = "SPICE_FOOD"
|
|
||||||
ActivityGear = "ACTIVITY_GEAR"
|
|
||||||
ActivityRobot = "ACTIVITY_ROBOT"
|
|
||||||
ActivityJigsaw = "ACTIVITY_JIGSAW"
|
|
||||||
Food = "FOOD"
|
|
||||||
ExpFruit = "EXP_FRUIT"
|
|
||||||
WeaponExpStone = "WEAPON_EXP_STONE"
|
|
||||||
AvatarMaterial = "AVATAR_MATERIAL"
|
|
||||||
ReliquaryMaterial = "RELIQUARY_MATERIAL"
|
|
||||||
ConsumeBatchUse = "CONSUME_BATCH_USE"
|
|
||||||
FishBait = "FISH_BAIT"
|
|
||||||
ChestBatchUse = "CHEST_BATCH_USE"
|
|
||||||
SelectableChest = "SELECTABLE_CHEST"
|
|
||||||
HomeSeed = "HOME_SEED"
|
|
||||||
Flycloak = "FLYCLOAK"
|
|
||||||
BGM = "BGM"
|
|
||||||
SeaLamp = "SEA_LAMP"
|
|
||||||
ChannellerSlabBuff = "CHANNELLER_SLAB_BUFF"
|
|
||||||
FishRod = "FISH_ROD"
|
|
||||||
Namecard = "NAMECARD"
|
|
||||||
Aranara = "ARANARA"
|
|
||||||
DeshretManual = "DESHRET_MANUAL"
|
|
||||||
Fireworks = "FIREWORKS"
|
|
||||||
Costume = "COSTUME"
|
|
||||||
FurnitureSuiteFormula = "FURNITURE_SUITE_FORMULA"
|
|
||||||
FurnitureFormula = "FURNITURE_FORMULA"
|
|
||||||
|
|
||||||
|
|
||||||
class Association(StrEnum):
|
class Association(StrEnum):
|
||||||
Inazuma = "INAZUMA"
|
Inazuma = "INAZUMA"
|
||||||
"""稻妻"""
|
"""稻妻"""
|
||||||
Mondstadt = "MONDSTADT"
|
Mondstadt = "MONDSTADT"
|
||||||
"""蒙德"""
|
"""蒙德"""
|
||||||
Mainactor = "MAINACTOR"
|
|
||||||
"""主角"""
|
|
||||||
Liyue = "LIYUE"
|
Liyue = "LIYUE"
|
||||||
"""璃月"""
|
"""璃月"""
|
||||||
|
Sumeru = "SUMERU"
|
||||||
|
"""须弥"""
|
||||||
|
Fontaine = "FONTAINE"
|
||||||
|
"""枫丹"""
|
||||||
|
Natlan = "NATLAN"
|
||||||
|
"""纳塔"""
|
||||||
|
Snezhnaya = "SNEZHNAYA"
|
||||||
|
"""至冬"""
|
||||||
|
|
||||||
|
Mainactor = "MAINACTOR"
|
||||||
|
"""主角"""
|
||||||
Fatui = "FATUI"
|
Fatui = "FATUI"
|
||||||
"""愚人众"""
|
"""愚人众"""
|
||||||
Ranger = "RANGER"
|
Ranger = "RANGER"
|
||||||
"""游侠"""
|
"""游侠"""
|
||||||
Sumeru = "SUMERU"
|
|
||||||
"""须弥"""
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from model.enums import FoodQuality, ItemType, MaterialType
|
from model.enums import FoodQuality, ItemType
|
||||||
from utils.model import BaseModel
|
from utils.model import BaseModel
|
||||||
|
|
||||||
|
|
||||||
@ -22,8 +22,10 @@ class Item(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class Material(Item):
|
class Material(Item):
|
||||||
material_type: MaterialType
|
material_type: str
|
||||||
"""材料类型"""
|
"""材料类型"""
|
||||||
|
material_type_description: str
|
||||||
|
"""材料类型描述"""
|
||||||
|
|
||||||
|
|
||||||
class Food(Item):
|
class Food(Item):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from functools import lru_cache
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
@ -46,79 +47,6 @@ TalentType = TypeVar("TalentType", bound=Talent)
|
|||||||
|
|
||||||
OUT_DIR = PROJECT_ROOT.joinpath("out")
|
OUT_DIR = PROJECT_ROOT.joinpath("out")
|
||||||
|
|
||||||
elements_map = {
|
|
||||||
(
|
|
||||||
230082676,
|
|
||||||
313529204,
|
|
||||||
627825788,
|
|
||||||
1247335084,
|
|
||||||
1646245548,
|
|
||||||
1740638908,
|
|
||||||
3105283268,
|
|
||||||
3112476852,
|
|
||||||
3177381772,
|
|
||||||
3847511308,
|
|
||||||
): Element.Pyro,
|
|
||||||
(
|
|
||||||
321258364,
|
|
||||||
483165900,
|
|
||||||
756679372,
|
|
||||||
1688473500,
|
|
||||||
2480954540,
|
|
||||||
3228108484,
|
|
||||||
3400532572,
|
|
||||||
3646588372,
|
|
||||||
4022324356,
|
|
||||||
): Element.Hydro,
|
|
||||||
(
|
|
||||||
126875444,
|
|
||||||
467004516,
|
|
||||||
550531300,
|
|
||||||
898621369,
|
|
||||||
1778251796,
|
|
||||||
2075460644,
|
|
||||||
2477900860,
|
|
||||||
2648184060,
|
|
||||||
): Element.Anemo,
|
|
||||||
(
|
|
||||||
122554396,
|
|
||||||
608089036,
|
|
||||||
689445588,
|
|
||||||
1072755468,
|
|
||||||
1821644548,
|
|
||||||
1843086100,
|
|
||||||
2085306033,
|
|
||||||
2143937940,
|
|
||||||
2480172868,
|
|
||||||
2689029804,
|
|
||||||
3352621156,
|
|
||||||
4219874220,
|
|
||||||
): Element.Electro,
|
|
||||||
(2161032364, 4017448612): Element.Dendro,
|
|
||||||
(
|
|
||||||
98482612,
|
|
||||||
766902996,
|
|
||||||
862088588,
|
|
||||||
1480674860,
|
|
||||||
1695600284,
|
|
||||||
2778487532,
|
|
||||||
2809830820,
|
|
||||||
3057990932,
|
|
||||||
4127670180,
|
|
||||||
4220569804,
|
|
||||||
): Element.Cryo,
|
|
||||||
(
|
|
||||||
825986772,
|
|
||||||
967031460,
|
|
||||||
1016213980,
|
|
||||||
1662907292,
|
|
||||||
2507042785,
|
|
||||||
3219124204,
|
|
||||||
3617274620,
|
|
||||||
3929787020,
|
|
||||||
): Element.Geo,
|
|
||||||
(471154292, 821712868, 1128382182, 3053155130, 4168416172): Element.Null,
|
|
||||||
}
|
|
||||||
prop_type_map = {
|
prop_type_map = {
|
||||||
"Hp": PropType.HP,
|
"Hp": PropType.HP,
|
||||||
"RockAddHurt": PropType.Geo,
|
"RockAddHurt": PropType.Geo,
|
||||||
@ -240,6 +168,42 @@ def parse_passive_talent(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
|
def get_element_data() -> dict[Element, set[int]]:
|
||||||
|
_manager = ResourceManager("chs")
|
||||||
|
_avatar_json_data = _manager.fetch("AvatarExcelConfigData")
|
||||||
|
_fetter_info_json_data = manager.fetch("FetterInfoExcelConfigData")
|
||||||
|
text_map = {
|
||||||
|
"火": Element.Pyro,
|
||||||
|
"水": Element.Hydro,
|
||||||
|
"风": Element.Anemo,
|
||||||
|
"雷": Element.Electro,
|
||||||
|
"草": Element.Dendro,
|
||||||
|
"冰": Element.Cryo,
|
||||||
|
"岩": Element.Geo,
|
||||||
|
"无": Element.Null,
|
||||||
|
}
|
||||||
|
result = {k: set() for k in text_map.values()}
|
||||||
|
for data in _avatar_json_data:
|
||||||
|
_id = data["id"]
|
||||||
|
if (
|
||||||
|
info_data := next(
|
||||||
|
chain(
|
||||||
|
filter(lambda x: x["avatarId"] == _id, _fetter_info_json_data),
|
||||||
|
[None],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) is None:
|
||||||
|
continue
|
||||||
|
if (
|
||||||
|
vision := _manager.get_text(
|
||||||
|
text_id := info_data["avatarVisionBeforTextMapHash"]
|
||||||
|
)
|
||||||
|
) is not None:
|
||||||
|
result[text_map[vision]] = set(list(result[text_map[vision]]) + [text_id])
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyShadowingBuiltins,SpellCheckingInspection,PyGlobalUndefined
|
# noinspection PyShadowingBuiltins,SpellCheckingInspection,PyGlobalUndefined
|
||||||
async def parse_avatar_data(lang: Lang):
|
async def parse_avatar_data(lang: Lang):
|
||||||
global out_path, manager
|
global out_path, manager
|
||||||
@ -259,6 +223,8 @@ async def parse_avatar_data(lang: Lang):
|
|||||||
proud_skill_json_data = manager.fetch("ProudSkillExcelConfigData")
|
proud_skill_json_data = manager.fetch("ProudSkillExcelConfigData")
|
||||||
talent_json_data = manager.fetch("AvatarTalentExcelConfigData")
|
talent_json_data = manager.fetch("AvatarTalentExcelConfigData")
|
||||||
|
|
||||||
|
element_data = get_element_data()
|
||||||
|
|
||||||
avatar_list = []
|
avatar_list = []
|
||||||
for data in avatar_json_data:
|
for data in avatar_json_data:
|
||||||
id = data["id"]
|
id = data["id"]
|
||||||
@ -273,10 +239,10 @@ async def parse_avatar_data(lang: Lang):
|
|||||||
name = manager.get_text(data["nameTextMapHash"])
|
name = manager.get_text(data["nameTextMapHash"])
|
||||||
element = next(
|
element = next(
|
||||||
filter(
|
filter(
|
||||||
lambda x: info_data["avatarVisionBeforTextMapHash"] in x[0],
|
lambda x: info_data["avatarVisionBeforTextMapHash"] in x[1],
|
||||||
elements_map.items(),
|
element_data.items(),
|
||||||
)
|
)
|
||||||
)[1]
|
)[0]
|
||||||
quality = AvatarQuality(
|
quality = AvatarQuality(
|
||||||
data["qualityType"].removeprefix("QUALITY_").replace("ORANGE_SP", "SPECIAL")
|
data["qualityType"].removeprefix("QUALITY_").replace("ORANGE_SP", "SPECIAL")
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,7 @@ from pathlib import Path
|
|||||||
import ujson as json
|
import ujson as json
|
||||||
from aiofiles import open as async_open
|
from aiofiles import open as async_open
|
||||||
|
|
||||||
from model.enums import FoodQuality, ItemType, MaterialType
|
from model.enums import FoodQuality, ItemType
|
||||||
from model.item import Food, Item, Material, Namecard
|
from model.item import Food, Item, Material, Namecard
|
||||||
from utils.const import PROJECT_ROOT
|
from utils.const import PROJECT_ROOT
|
||||||
from utils.manager import ResourceManager
|
from utils.manager import ResourceManager
|
||||||
@ -51,10 +51,19 @@ async def parse_item_data(
|
|||||||
item = Namecard(pictures=pictures, **kwargs)
|
item = Namecard(pictures=pictures, **kwargs)
|
||||||
|
|
||||||
elif "materialType" in data:
|
elif "materialType" in data:
|
||||||
material_type = MaterialType(
|
# material_type = MaterialType(
|
||||||
data["materialType"].removeprefix("MATERIAL_")
|
# data["materialType"].removeprefix("MATERIAL_")
|
||||||
|
# )
|
||||||
|
# item = Material(material_type=material_type, **kwargs)
|
||||||
|
material_type = data["materialType"].removeprefix("MATERIAL_")
|
||||||
|
item = Material(
|
||||||
|
material_type=material_type,
|
||||||
|
material_type_description=manager.get_text(
|
||||||
|
data["typeDescTextMapHash"]
|
||||||
|
)
|
||||||
|
or "",
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
item = Material(material_type=material_type, **kwargs)
|
|
||||||
elif "foodQuality" in data:
|
elif "foodQuality" in data:
|
||||||
quality = FoodQuality(data["foodQuality"])
|
quality = FoodQuality(data["foodQuality"])
|
||||||
effect = manager.get_text(data["effectDescTextMapHash"])
|
effect = manager.get_text(data["effectDescTextMapHash"])
|
||||||
|
@ -24,8 +24,7 @@ class ResourceManager:
|
|||||||
|
|
||||||
def __init__(self, base_url: str | None = None, lang: Lang | None = None):
|
def __init__(self, base_url: str | None = None, lang: Lang | None = None):
|
||||||
self._base_url = URL(
|
self._base_url = URL(
|
||||||
base_url
|
base_url or "https://gitlab.com/Dimbreath/AnimeGameData/-/raw/master/"
|
||||||
or "https://git.neeemooo.com/githubbackup/GenshinData/-/raw/master/"
|
|
||||||
)
|
)
|
||||||
self._lang = lang or "chs"
|
self._lang = lang or "chs"
|
||||||
|
|
||||||
@ -35,8 +34,10 @@ class ResourceManager:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def client(self) -> Client:
|
def client(self) -> Client:
|
||||||
|
from httpx import Timeout
|
||||||
|
|
||||||
if self._client is None or self._client.is_closed:
|
if self._client is None or self._client.is_closed:
|
||||||
self._client = Client(verify=ssl_context)
|
self._client = Client(verify=ssl_context, timeout=Timeout(timeout=30))
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
def refresh(self) -> None:
|
def refresh(self) -> None:
|
||||||
@ -65,8 +66,10 @@ class ResourceManager:
|
|||||||
file_path = DATA_DIR.joinpath(file_dir).joinpath(name).with_suffix(".json")
|
file_path = DATA_DIR.joinpath(file_dir).joinpath(name).with_suffix(".json")
|
||||||
file_path.parent.mkdir(exist_ok=True, parents=True)
|
file_path.parent.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
if not file_path.exists() or os.stat(file_path) == 0:
|
if not (file_path.exists() and os.stat(file_path)):
|
||||||
response = self.client.get(str(self._base_url / file_dir / file_path.name))
|
response = self.client.get(
|
||||||
|
str(self._base_url / file_dir / file_path.name)
|
||||||
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
with open(file_path, encoding="utf-8", mode="w") as file:
|
with open(file_path, encoding="utf-8", mode="w") as file:
|
||||||
file.write(content := response.text)
|
file.write(content := response.text)
|
||||||
|
Loading…
Reference in New Issue
Block a user