Skip to content

Commit

Permalink
interpage update (see generator)
Browse files Browse the repository at this point in the history
  • Loading branch information
sctop committed Jan 27, 2024
1 parent 21d71f9 commit 999ee67
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data_export
22 changes: 22 additions & 0 deletions data_model/actual_data/battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,28 @@ def _get_instance_offset(self, offset: int):
except IndexError:
return None

def get_mixed_interpage_data(self, prev, next):
def get_chapter(obj):
try:
return obj.chapter
except AttributeError:
return "[NO_PREV]"

return {
"prev": {
"name": prev.name.to_json_basic() if prev else "[NO_PREV]",
"namespace": prev.namespace if prev else "[NO_PREV]",
"chapter": get_chapter(prev),
"no": prev.no if prev else "[NO_PREV]"
},
"next": {
"name": next.name.to_json_basic() if next else "[NO_NEXT]",
"namespace": next.namespace if next else "[NO_NEXT]",
"chapter": get_chapter(next),
"no": next.no if next else "[NO_NEXT]"
}
}


class SchoolExchangeInfo(BaseBattleInfo):
_instance = {}
Expand Down
33 changes: 32 additions & 1 deletion data_model/actual_data/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,22 @@ def interpage_next(self):
ref_data = self.data["interpage"]["next"]
return ReferenceData(*self.process_reference_data(ref_data)).ref_instance

def get_mixed_interpage_data(self, prev, next):
return {
"prev": {
"name": prev.name.to_json_basic() if prev else "[NO_PREV]",
"namespace": prev.namespace if prev else "[NO_PREV]",
"is_battle": prev.is_battle if prev else "[NO_PREV]",
"pos": prev.pos.to_json_basic() if prev else "[NO_PREV]"
},
"next": {
"name": next.name.to_json_basic() if next else "[NO_NEXT]",
"namespace": next.namespace if next else "[NO_NEXT]",
"is_battle": next.is_battle if next else "[NO_NEXT]",
"pos": next.pos.to_json_basic() if next else "[NO_NEXT]"
}
}


class StoryInfoBond(FileLoader, IParentData, InterpageMixin):
"""Basically a modified class from StoryInfo"""
Expand Down Expand Up @@ -308,7 +324,6 @@ def _get_instance_id(data: dict):
return "_".join(["BOND", *story_pos])

def _get_instance_offset(self, offset: int):
# TODO
return StoryInfo._get_instance_offset(self, offset)

def parent_data_to_json(self):
Expand Down Expand Up @@ -352,3 +367,19 @@ def to_json_basic(self):
@classmethod
def get_instance(cls, instance_id):
return super().get_instance(instance_id)

def get_mixed_interpage_data(self, prev, next):
return {
"prev": {
"name": prev.name.to_json_basic() if prev else "[NO_PREV]",
"namespace": prev.namespace if prev else "[NO_PREV]",
"is_memory": prev.is_memory if prev else "[NO_PREV]",
"pos": prev.pos.to_json_basic() if prev else "[NO_PREV]"
},
"next": {
"name": next.name.to_json_basic() if next else "[NO_NEXT]",
"namespace": next.namespace if next else "[NO_NEXT]",
"is_memory": next.is_memory if next else "[NO_NEXT]",
"pos": next.pos.to_json_basic() if next else "[NO_NEXT]"
}
}

0 comments on commit 999ee67

Please sign in to comment.