-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_story.py
79 lines (57 loc) · 3.13 KB
/
gen_story.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from src.output import OutputFiles
from src.baidu.ab import AppBuilderKnowledgeBase
from src.utils import *
knowledge_base = AppBuilderKnowledgeBase('story')
book_store = OutputFiles('stories', single_file=argv('single_file', bool))
def roguelike():
roguelike_topic_table = JsonData.get_json_data('roguelike_topic_table')
story_review_meta_table = JsonData.get_json_data('story_review_meta_table')
for rid, detail in roguelike_topic_table['details'].items():
book_name = roguelike_topic_table['topics'][rid]['name']
book_store.create(book_name, book_name, [roguelike_topic_table['topics'][rid]['lineText']])
if book_name == '傀影与猩红孤钻':
avgs = story_review_meta_table['actArchiveResData']['avgs']
indexes = [
(1, avgs['avg_rogue_1_2']),
(2, avgs['avg_rogue_1_3']),
(3, avgs['avg_rogue_1_4']),
(4, avgs['avg_rogue_1_5']),
]
for idx, endbook in progress(indexes, book_name):
section_name = '%s-结局%d:%s' % (book_name, idx, endbook['desc'].strip())
content = (
endbook['rawBrief']
+ '\n\n'
+ read_content(f'{gamedata}/story/%s.txt' % endbook['contentPath'].lower())
)
book_store.create(section_name, book_name, [content])
else:
for endbook in progress(detail['archiveComp']['endbook']['endbook'].values(), book_name):
ending = detail['endings'][endbook['endingId']]
section_name = '%s-结局%d:%s' % (book_name, ending['priority'] + 1, ending['name'].strip())
content = ending['desc'] + '\n\n' + read_content(f'{gamedata}/story/%s.txt' % endbook['avgId'].lower())
book_store.create(section_name, book_name, [content])
for month in detail['monthSquad'].values():
chat = detail['archiveComp']['chat']['chat'][month['chatId']]
book_content = [month['teamDes']]
for item in chat['clientChatItemData']:
book_content.append(read_content(f'{gamedata}/story/%s.txt' % item['chatStoryId'].lower()))
book_store.create('%s-%s' % (book_name, month['teamName'].strip()), book_name, book_content)
def main():
story_review_table = JsonData.get_json_data('story_review_table')
for item in story_review_table.values():
if item['id'].startswith('main') or ('act' in item['id']):
book_name = item['name']
else:
continue
for sec in progress(sorted(item['infoUnlockDatas'], key=lambda n: n['storySort']), book_name):
file = gamedata + '/story/{storyTxt}.txt'.format_map(sec)
section_name: str = book_name + '-{storyName} {avgTag}'.format_map(sec)
section_name = section_name.replace(':', ':')
section_name = section_name.replace('?', '?')
book_store.create(section_name, book_name, [read_content(file)])
roguelike()
book_store.done()
knowledge_base.compare_files_and_update(book_store.result)
if __name__ == '__main__':
main()