-
Notifications
You must be signed in to change notification settings - Fork 0
/
Resplendent.py
118 lines (99 loc) · 5.68 KB
/
Resplendent.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#! /usr/bin/env python3
import re
import util
import wikiUtil
import globals
from util import DATA as ENDATA
from MiniUnit import createMiniUnit, uploadMiniUnit, useMiniUnit
def addResplendentHeroQuotes(unit: dict):
name = util.getName(unit['hero_id'])
page = wikiUtil.getPageContent(name + '/Quotes')[name + '/Quotes']
if page.find("Resplendent Hero") != -1:
return {}
romanized = util.fetchFehData("Common/SRPG/Person")[unit['hero_id']]['roman']
EN = util.readFehData("USEN/Message/Character/"+romanized+"_EX01.json")
JP = util.readFehData("JPJA/Message/Character/"+romanized+"_EX01.json")
reg = re.compile(r'[a-zA-Z]')
s = ["==Resplendent Hero=="]
for (title, tag, init, count, template, extra) in [("Attack", "ATTACK", 1, 2, "Audio", None),
("Damage", "DAMAGE", 3, 2, "Audio", None),
("Special trigger", "SKILL", 5, 4, "Audio", None),
("Defeat", "DEAD", 9, 1, "Audio", None),
("Status page", "STATUS", 10, 8, "Status", lambda d: 1 if d < 4 else 4 if d < 6 else 5),
("Turn action", "MAP", 18, 3, "Audio", None)]:
s += ["==="+title+"===\n{{"+template+"TableHeader}}"]
for i in range(count):
v = f"|{extra(i)}" if extra else ""
text = [obj['value'] for obj in EN if obj['key'] == f'MID_{romanized}_EX01_VOICE{init+i:02}' and reg.search(obj['value'])]
s += ["{{"+template+"TableRow|VOICE_{{MF|1={{BASEPAGENAME}}}}_Resplendent_"+f"{tag}_{i+1}.wav|"+(text[0] if len(text) else "")+v+"}}"]
s += ["|}\n{{"+template+"TableHeader|ja}}"]
for i in range(count):
v = f"|{extra(i)}" if extra else ""
text = [obj['value'] for obj in JP if obj['key'] == f'MID_{romanized}_EX01_VOICE{init+i:02}']
s += ["{{"+template+"TableRow|VOICE_{{MF|1={{BASEPAGENAME}}}}_Resplendent_"+f"{tag}_{i+1}_jp.wav|"+text[0]+v+"|ja}}"]
s += ["|}\n{{Clear}}"]
page = re.sub(r'(\{\{StoryAppearances\}\})', "\n".join(s) + "\n\\1", page)
return {name+"/Quotes": page}
def updateResplendentHeroMisc(unit: dict):
name = util.getName(unit['hero_id'])
face = globals.UNITS[unit['hero_id']]['face_name2'] + 'EX01'
createMiniUnit(unit['hero_id'], only=[face])
uploadMiniUnit()
page = useMiniUnit([unit['hero_id']])[name + '/Misc']
if not page:
page = wikiUtil.getPageContent(name + '/Misc')[name + '/Misc']
if not re.search('Resplendent BtlFace BU\\.', page):
page = re.sub('(BtlFace BU D.*)', f"\\1\nFile:{util.cleanStr(name)} Resplendent BtlFace BU.webp", page, 1)
if not re.search('Resplendent BtlFace BU D\\.', page):
page = re.sub('(Resplendent BtlFace BU.*)', f"\\1\nFile:{util.cleanStr(name)} Resplendent BtlFace BU D.webp", page, 1)
return {name+'/Misc': page}
def updateResplendentHeroPage(unit: dict):
name = util.getName(unit['hero_id'])
page = wikiUtil.getPageContent([name])[name]
JPDATA = {data['key']: data['value'] for data in util.fetchFehData("JPJA/Message/Data", None)}
if not re.search(r'Properties\s*=[^\n|]*resplendent', page):
add = 'resplendent,' + (util.askFor(intro='Where does Resplendent '+name+' come from') or '')
if re.search(r'Properties\s*=\s*\w', page):
add = ',' + add
if page.find('Properties') != -1:
page = re.sub(r'(Properties\s*=[^\n|]*)', '\\1'+add, page)
else:
page = re.sub(r'(?s)(\{\{\s*Hero Infobox.*?)\}\}', '\\1|Properties='+add+'\n}}', page)
if page.find('resplendentStartTime') == -1:
page = re.sub(r'(?s)(\{\{\s*Hero Infobox.*?)\}\}', '\\1|resplendentStartTime='+unit['avail_start']+'\n|resplendentEndTime='+util.timeDiff(unit['avail_finish'])+'\n}}', page)
if page.find('resplendentArtist') == -1:
page = re.sub(r'(artist\s*=[^\n|]*)', '\\1\n|resplendentArtist='+JPDATA['MPID_ILLUST_'+unit['hero_id'][4:]+'EX01'], page)
if page.find('resplendentActorEN') == -1 and ENDATA['MPID_VOICE_'+unit['hero_id'][4:]+'EX01'] != ENDATA['MPID_VOICE_'+unit['hero_id'][4:]]:
page = re.sub(r'(actorEN\s*=[^\n|]*)', '\\1\n|resplendentActorEN='+ENDATA['MPID_VOICE_'+unit['hero_id'][4:]+'EX01'], page)
if page.find('resplendentActorJP') == -1 and JPDATA['MPID_VOICE_'+unit['hero_id'][4:]+'EX01'] != JPDATA['MPID_VOICE_'+unit['hero_id'][4:]]:
page = re.sub(r'(actorJP\s*=[^\n|]*)', '\\1\n|resplendentActorJP='+JPDATA['MPID_VOICE_'+unit['hero_id'][4:]+'EX01'], page)
return {name: page}
def ResplendentHero(unitId: str):
data = globals.RESPLENDENTS[unitId] or None
res = updateResplendentHeroPage(data)
res.update(addResplendentHeroQuotes(data))
res.update(updateResplendentHeroMisc(data))
return res
def ResplendentHeroesFrom(tagId: str):
datas = util.readFehData('Common/SubscriptionCostume/' + tagId + '.json')
res = {}
for data in datas:
try:
res.update(updateResplendentHeroPage(data))
res.update(addResplendentHeroQuotes(data))
res.update(updateResplendentHeroMisc(data))
except:
print(util.TODO + 'Error with Resplendent hero ' + util.getName(data['hero_id']))
return res
from sys import argv
if __name__ == '__main__':
for arg in argv[1:]:
pages = {}
if re.match(r'\d+_\w+|v\d{4}[a-e]_\w+', arg):
pages = ResplendentHeroesFrom(arg)
elif arg.find(':') != -1:
pass
elif arg.find('PID_') == 0:
pages = ResplendentHero(arg)
for page in pages:
print(page, pages[page])