diff --git a/data_model/actual_data/character.py b/data_model/actual_data/character.py index fddf241..9a57470 100644 --- a/data_model/actual_data/character.py +++ b/data_model/actual_data/character.py @@ -109,7 +109,7 @@ def to_json(self, no_used_by: bool = True): return d -class CharacterInfoProxyComm: +class CharacterInfoIndirectProxy: """ 这个类干的东西基本上就是:接管原对象的 `used_by.register` 方法,然后把背景数据的filetype改一下实现特殊注册。 """ @@ -135,10 +135,21 @@ def __init__(self, real_obj: "NpcInfo" or "StudentInfo"): def used_by(self): return self._used_by_handler + def register(self, file_loader: FileLoader, count_increase=True): + self.used_by.register(file_loader, count_increase) + def __getattr__(self, item): return getattr(self.real_obj, item) +class CharacterInfoProxyComm(CharacterInfoIndirectProxy): + pass + + +class CharacterInfoProxyNarrative(CharacterInfoIndirectProxy): + pass + + class CharacterInfo(FileLoader, InterpageMixin, UsedByRegisterMixin, RelatedToRegisterMixin): _instance = {} @@ -147,16 +158,21 @@ def get_instance(cls, instance_id): def return_instance(instance): if is_comm: return CharacterInfoProxyComm(instance) + elif is_narrative: + return CharacterInfoProxyNarrative(instance) return instance instance_id = instance_id.upper() - is_comm = False + is_comm, is_narrative = False, False # 考虑是不是comm特殊例 if instance_id.endswith("(COMM)") or instance_id.endswith("_COMM"): # 清除特殊标记 instance_id = instance_id.replace("_COMM", "").replace("(COMM)", "") is_comm = True + elif instance_id.endswith("(NARR)") or instance_id.endswith("_NARR"): + instance_id = instance_id.replace("_NARR", "").replace("(NARR)", "") + is_narrative = True try: # If it's a student @@ -484,8 +500,13 @@ def to_json(self): if isinstance(i, CharacterInfoProxyComm): temp["is_comm"] = True + temp["is_narrative"] = False + elif isinstance(i, CharacterInfoProxyNarrative): + temp["is_comm"] = False + temp["is_narrative"] = True else: temp["is_comm"] = False + temp["is_narrative"] = False t.append(temp)