Skip to content

Commit

Permalink
feat: categorize stories into colabs and events
Browse files Browse the repository at this point in the history
  • Loading branch information
gudzpoz committed Oct 14, 2023
1 parent 585b96a commit 05a3f59
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 20 deletions.
6 changes: 4 additions & 2 deletions src/StorySimulator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ function generateChapterOption(label: ChapterType, name: string): MenuOption & T
};
}
const data: (MenuOption & TreeSelectOption)[] = [
generateChapterOption('main', '主线支线活动故事'),
generateChapterOption('upgrading', '心智升级故事'),
generateChapterOption('main', '主线剧情'),
generateChapterOption('event', '小型活动'),
generateChapterOption('colab', '联动'),
generateChapterOption('upgrading', '心智升级'),
generateChapterOption('bonding', '格里芬往事'),
generateChapterOption('anniversary', '周年庆'),
generateChapterOption('skin', '皮肤故事'),
Expand Down
8 changes: 6 additions & 2 deletions src/components/StoryTeller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ function updateAudio(audio: string) {
if (audio !== '') {
backgroundMusic = new Audio(audio);
backgroundMusic.loop = true;
backgroundMusic.play();
try {
backgroundMusic.play();
} catch (_) { /* empty */ }
}
}
function playAudio(audio: string) {
const sePlayer = new Audio(audio);
sePlayer.loop = false;
sePlayer.play();
try {
sePlayer.play();
} catch (_) { /* empty */ }
}
function updateLine(line: string, tags: Record<string, string>) {
Expand Down
2 changes: 1 addition & 1 deletion src/types/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function getUrlType(s: string): typeof MEDIA_TYPES[number] {
return 'sprite';
}

export type ChapterType = 'main' | 'bonding' | 'upgrading' | 'anniversary' | 'skin';
export type ChapterType = 'main' | 'event' | 'colab' | 'bonding' | 'upgrading' | 'anniversary' | 'skin';
export type Story = {
name: string;
description: string;
Expand Down
22 changes: 19 additions & 3 deletions unpack/src/gfunpack/chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import hjson

from gfunpack.stories import Stories
from gfunpack.manual_chapters import Chapter, Story, get_block_list, get_recorded_chapters, post_insert
from gfunpack.manual_chapters import Chapter, Story, add_extra_chapter_mappings, get_block_list, get_recorded_chapters, post_insert

_logger = logging.getLogger('gfunpack.prefabs')
_warning = _logger.warning
Expand Down Expand Up @@ -245,6 +245,8 @@ def _categorize_main_stories(self):
)
for campaign_id in chapter.story_campaign_id.split(','):
id_mapping[campaign_id] = chapter.id

add_extra_chapter_mappings(id_mapping)

# 已经进入剧情回放的剧情录入对应章节
for story in sorted(self.main_events, key=lambda e: (abs(e.campaign), e.id)):
Expand Down Expand Up @@ -330,7 +332,21 @@ def _categorize_upgrading_stories(self):

def categorize_stories(self):
all_chapters: dict[str, list[Chapter]] = {}
all_chapters['main'] = self._categorize_main_stories()
stories = self._categorize_main_stories()
main, events, colab = [], [], []
for s in stories:
if s.description.isdigit() and 2000 < int(s.description) < 2100:
events.append(s)
elif '联动内容' in s.description:
colab.append(s)
else:
main.append(s)
events.sort(key=lambda e: int(e.description))
events.extend(filter(lambda e: e.name.startswith('未知: '), main))
main = list(filter(lambda e: not e.name.startswith('未知: '), main))
all_chapters['main'] = main
all_chapters['event'] = events
all_chapters['colab'] = colab
all_chapters['bonding'] = self._categorize_bonding_stories()
all_chapters['upgrading'] = self._categorize_upgrading_stories()
all_chapters['anniversary'] = self._categorize_anniversary()
Expand All @@ -347,7 +363,7 @@ def save(self):
all_file_list.extend((f if isinstance(f, str) else f[0]) for f in story.files)
all_files = set(all_file_list)
others = set(self.stories.extracted.keys()) - all_files - get_block_list()
self.all_chapters['main'].append(Chapter(
self.all_chapters['event'].append(Chapter(
name='未能归类',
description='程序未能自动归类的故事',
stories=[
Expand Down
52 changes: 40 additions & 12 deletions unpack/src/gfunpack/manual_chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ class Chapter:

_extra_chapters: list[tuple[str, str, str, list]] = [
('-42', '茧中蝶影', '2020', _extra_stories_cocoon()),
('-50', '焙炒爱意', '2022', []),
('-52', '里坎禁猎区', '2022', []),
('-59', '迷笼猜想', '2023', []),
('-61', '思域迷航', '2023', []),
('-62', '许可!二次加载', '2023', []),

('-8', '猎兔行动', '《苍翼默示录》x《罪恶装备》联动内容', []),
('-14,-15', '独法师', '《崩坏学园2》联动内容', []),
Expand All @@ -161,17 +166,6 @@ def _get_extra_chapter_mapping():
return mapping


def get_block_list():
return set(
[
'0-0-0.txt', # 空白,“替代剧情”
'0-0-1.txt', # 空白,“替代教程”
'profiles.txt',
'avgplaybackprofiles.txt',
]
)


def get_recorded_chapters():
chapters: dict[int, Chapter] = {
0: _chapter_starting(),
Expand Down Expand Up @@ -223,16 +217,50 @@ def get_recorded_chapters():
]


_extra_chapter_mapping = {
'-27': '-24', # 有序紊流:飓风营救
'-45': '-24', # 飓风营救复刻
'-99': '-58', # 慢休克 END
}
def add_extra_chapter_mappings(id_mapping: dict[str, int]):
for extra, mapping in _extra_chapter_mapping.items():
id_mapping[extra] = id_mapping[mapping]


def post_insert(chapters: dict[int, Chapter], mapped_files: set[str]):
stories: dict[str, Story] = {}
for chapter in chapters.values():
for story in chapter.stories:
for file in story.files:
stories[file if isinstance(file, str) else file[0]] = story
for file, attached in _attached_stories:
assert attached not in mapped_files
assert attached not in mapped_files, attached
story = stories[file]
assert isinstance(story.files[0], str)
stories[attached] = story
story.files.append(attached)
mapped_files.add(attached)


def get_block_list():
return set(
[
'0-0-0.txt', # 空白,“替代剧情”
'0-0-1.txt', # 空白,“替代教程”
'profiles.txt',
'avgplaybackprofiles.txt',

# 魔方行动,例如 -6-1-1 和 -1-1-1 的内容是一模一样的……
'-6-1-1.txt',
'-6-1-2first.txt',
'-6-2-1.txt',
'-6-2-2end.txt',
'-6-2-2first.txt',
'-6-3-1.txt',
'-6-3-2end.txt',
'-6-3-2first.txt',
'-6-4-1.txt',
'-6-4-2end.txt',
'-6-4-2first.txt',
]
)

0 comments on commit 05a3f59

Please sign in to comment.