mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 15:36:44 +00:00
031198b08d
Signed-off-by: Lei Shi <me@leishi.io> Co-authored-by: 洛水居室 <luoshuijs@outlook.com> Co-authored-by: CHxCOOH <chxcooh@googlemail.com> Co-authored-by: xtaodada <xtao@xtaolink.cn> Co-authored-by: Nahida <53059854+NahidaBuer@users.noreply.github.com> Co-authored-by: omg-xtao <100690902+omg-xtao@users.noreply.github.com>
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from typing import Dict, Any
|
|
|
|
from utils.const import PROJECT_ROOT
|
|
|
|
try:
|
|
import ujson as jsonlib
|
|
except ImportError:
|
|
import json as jsonlib
|
|
|
|
METADATA_PATH = PROJECT_ROOT.joinpath("metadata").joinpath("data")
|
|
|
|
|
|
class Metadata:
|
|
_instance: "Metadata" = None
|
|
weapon_metadata: Dict[str, Any] = {}
|
|
artifacts_metadata: Dict[str, Any] = {}
|
|
characters_metadata: Dict[str, Any] = {}
|
|
|
|
def __new__(cls):
|
|
if cls._instance is None:
|
|
cls._instance = super().__new__(cls)
|
|
cls._instance.reload_assets()
|
|
return cls._instance
|
|
|
|
def reload_assets(self) -> None:
|
|
self.__load_assets_data()
|
|
|
|
def __load_assets_data(self) -> None:
|
|
self.weapon_metadata = jsonlib.loads(METADATA_PATH.joinpath("weapon.json").read_text(encoding="utf-8"))
|
|
self.artifacts_metadata = jsonlib.loads(METADATA_PATH.joinpath("reliquary.json").read_text(encoding="utf-8"))
|
|
self.characters_metadata = jsonlib.loads(METADATA_PATH.joinpath("avatar.json").read_text(encoding="utf-8"))
|