来自魔法纪录中文Wiki
跳转至: 导航 搜索
# coding=utf-8
# get json from: https://gitlab.com/EnkanRec/magireco-data-json/-/tree/master/
# version beta-2
import json

MEMORIA_JSON = "memoria.json"
OUTPUT = "wikitext.txt"
WD = ""

def read_json(fname):
    f = open(WD + fname, 'r', encoding='utf-8')
    data = f.read()
    f.close()
    return json.loads(data)

def write_wiki(fname, text):
    f = open(WD + fname, 'w', encoding='utf-8')
    f.write(text)
    f.close()

def table_header(columns, column_certain=False, percentage=True, icon_width='30px', table_style=None):
    text = '{| class="wikitable"'
    if table_style: text += ' style="%s"' % table_style
    text += '\n'
    text += table_caption(columns, column_certain=column_certain, percentage=percentage, firstRow=True, icon_width=icon_width)
    return text

def table_caption(columns, column_certain=False, percentage=True, firstRow=False, icon_width='30px'):
    text = '' if firstRow else '|-\n'
    text += '! style="width: %s" | !! 技能' % icon_width
    if column_certain:
        text += ' !! 必定'
    for i in columns:
        if percentage:
            text += ' !! %g%%' % (i/10)
        else:
            text += ' !! %g' % (i/10)
    text += ' !! 其他\n'
    return text

def memoriaSort(m):
    if type(m) == type(()): m = m[1]
    art = m['art']
    a = ['ABILITY', 'SKILL'].index(m['pieceType'])
    b = ['ALL', 'TARGET', 'SELF', 'CONNECT', 'ONE', 'DYING'].index(art['targetId'])
    c = 0 if 'enableTurn' not in art.keys() else -art['enableTurn']
    d = ['RANK_4', 'RANK_3', 'RANK_2', 'RANK_1'].index(m['rank'])
    return d + 4*(c + 10*(b + 6*a))

def table_row(icon, name, data, column_certain=False, bad_target=None, mark_chara=False):
    text = '|-\n| '
    if len(icon) > 0:
        if type(icon) != type([]):
            text += '[[文件:%s|30px]]' % icon
        else:
            for i in icon:
                text += '[[文件:%s|30px]]' % i
    text += ' || '
    if len(name) > 0: text += name
    for cell in data:
        text += ' || '
        # if len(cell) > 0:
            # text += 'style="padding: 0;" | '
        cell.sort(key=memoriaSort)
        for memo in cell:
            rubyValue = None
            if type(memo) == type(()):
                rubyValue = memo[0]
                memo = memo[1]
            # uText = '{{记忆数据表/%s|icon-small}}' % get_name(memo)
            uText = '[[File:%s_s.png|35px|link=记忆结晶/%s]]' % (get_name(memo, True), get_name(memo))
            style = ''
            boxShadow = []
            if 'enableTurn' in memo['art'].keys() and memo['art']['enableTurn'] > 1:
                boxShadow.append('2px 2px 6px #00f')
            if memo['art']['targetId'] == bad_target:
                boxShadow.append('2px 0 15px #000, 0 2px 15px #000')
            if memo['art']['targetId'] == 'ALL':
                # boxShadow.append('0 0 25px #da0')
                boxShadow.append('0 2px 15px #f80, 0 -2px 15px #f80, -2px 0 15px #f80, 2px 0 15px #f80')
            if len(boxShadow) > 0:
                style += 'margin: 2px; box-shadow: %s; ' % (', '.join(boxShadow))
            if 'charaList' in memo.keys():
                style += 'border: 2px solid #0f0;'
            if style != '':
                uText = '<div style="display: inline-block; width: 35px; height: 35px; %s">%s</div>' % (style, uText)
            if not rubyValue and mark_chara and 'charaList' in memo.keys():
                rubyValue = '、'.join([c['name'] for c in memo['charaList']])
            if rubyValue:
                text += '{{Ruby|1=%s|2=%s}}' % (uText, rubyValue)
            else:
                text += uText
    text += '\n'
    return text

def get_name(memo, is_pic=False):
    memo_name = memo['pieceName']
    if is_pic:
        memo_name = memo_name.replace(":", "-")
    if memo['pieceId'] == 1001:
        return memo_name + ' (1)'
    elif memo['pieceId'] == 1002:
        return memo_name + ' (2)'
    elif memo['pieceId'] == 1753:
        return memo_name + ' (2)'
    else:
        return memo_name

def table_footer():
    return '|}\n'

def check(memo, condition):
    if 'pieceSkill2' not in memo.keys(): return False
    for key, art in memo['pieceSkill2'].items():
        if key[:3] == 'art' and key[:5] != 'artId':
            checked = True
            for cKey, cValue in condition.items():
                if cKey != 'EXCEPT':
                    if cKey not in art.keys() or art[cKey] != cValue:
                        checked = False
                else:
                    for cKey2, cValue2 in cValue.items():
                        if cKey2 in art.keys() and art[cKey2] == cValue2:
                            checked = False
            if checked:
                memo['art'] = art
                return True
    return False

def select(baseMemoria, pieceType, mFilters):
    if pieceType:
        memoria = [v for k, v in baseMemoria.items() if 'pieceType' in v.keys() and v['pieceType']==pieceType and check(v, mFilters)]
    else:
        memoria = [v for k, v in baseMemoria.items() if check(v, mFilters)]
    return memoria

def separate(baseMemoria, columnKey, columnValues, percentage=True):
    data = []
    if columnKey == 'probability':
        cell = [memo for memo in baseMemoria if memo['art']['probability'] == 1000]
        baseMemoria[:] = [memo for memo in baseMemoria if memo not in cell]
        data.append(cell)
    for v in columnValues:
        cell = [memo for memo in baseMemoria if memo['art'][columnKey] == v]
        baseMemoria[:] = [memo for memo in baseMemoria if memo not in cell]
        data.append(cell)
    if percentage:
        cell = [('%g%%' % (memo['art'][columnKey]/10), memo) for memo in baseMemoria]
    else:
        cell = [('%g' % (memo['art'][columnKey]/10), memo) for memo in baseMemoria]
    data.append(cell)
    return data

def png(num):
    return "Icon skill %g.png" % num

def active_ailments(memoria, effectCode, name, icon, columns):
    data = separate(select(memoria, 'SKILL', {"verbCode": "CONDITION_BAD", "effectCode": effectCode}), 'probability', columns)
    return table_row(icon, name, data, column_certain=True, bad_target='SELF')

def passive_ailments(memoria, effectCode, name, icon, columns):
    data = separate(select(memoria, 'ABILITY', {"verbCode": "ENCHANT", "effectCode": effectCode}), 'probability', columns)
    return table_row(icon, name, data, column_certain=True)

def ignore(memoria, effectCode, name, icon, columns):
    data = separate(select(memoria, '', {"verbCode": "IGNORE", "effectCode": effectCode}), 'probability', columns)
    return table_row(icon, name, data, column_certain=True, bad_target='TARGET')

def condition_good_p(memoria, effectCode, name, icon, columns, percentage=True, pieceType=''):
    data = separate(select(memoria, pieceType, {"verbCode": "CONDITION_GOOD", "effectCode": effectCode}), 'probability', columns, percentage=percentage)
    return table_row(icon, name, data, column_certain=True, bad_target='TARGET')

def condition_good_v(memoria, effectCode, name, icon, columns, percentage=True, pieceType=''):
    data = separate(select(memoria, pieceType, {"verbCode": "CONDITION_GOOD", "effectCode": effectCode}), 'effectValue', columns, percentage=percentage)
    return table_row(icon, name, data, bad_target='TARGET')

def buff(memoria, effectCode, name, icon, columns, pieceType=''):
    data = separate(select(memoria, pieceType, {"verbCode": "BUFF", "effectCode": effectCode}), 'effectValue', columns)
    return table_row(icon, name, data, bad_target='TARGET')

def debuff(memoria, effectCode, name, icon, columns, pieceType=''):
    data = separate(select(memoria, pieceType, {"verbCode": "DEBUFF", "effectCode": effectCode}), 'effectValue', columns)
    return table_row(icon, name, data, bad_target='SELF')

def draw(memoria, effectCode, name, icon):
    data = separate(select(memoria, 'SKILL', {"verbCode": "DRAW", "effectCode": effectCode}), 'probability', [])
    return table_row(icon, name, data, column_certain=True, mark_chara=True)

def sanityCheck(memo):
    try:
        if 'pieceId' not in memo.keys():
            raise Exception('Unexpected: pieceId key not found in:', memo)
        if 'pieceName' not in memo.keys():
            raise Exception('Unexpected: pieceName key not found in:', memo)
        pieceId = memo['pieceId']
        pieceName = memo['pieceName']
        if 'pieceType' not in memo.keys():
            raise Exception('Unexpected: pieceType key not found in %g %s' % (pieceId, pieceName))
        pieceType = memo['pieceType']
        if pieceType != 'SKILL' and pieceType != 'ABILITY':
            raise Exception('Unexpected: pieceType value %s in %g %s' % (pieceType, pieceId, pieceName))
        if 'pieceSkill2' not in memo.keys():
            raise Exception('Unexpected: pieceSkill2 key not found in %g %s' % (pieceId, pieceName))
        hasArt = False
        for key, art in memo['pieceSkill2'].items():
            if key[:3] == 'art' and key[:5] != 'artId':
                hasArt = True
                if 'verbCode' not in art.keys():
                    raise Exception('Unexpected: missing verbCode for %s in %g %s' % (key, pieceId, pieceName))
                if 'effectCode' not in art.keys():
                    raise Exception('Unexpected: missing effectCode for %s in %g %s' % (key, pieceId, pieceName))
                verbCode = art['verbCode']
                effectCode = art['effectCode']
                if verbCode == 'BUFF' or verbCode == 'DEBUFF' or verbCode == 'BUFF_HPMAX' or verbCode == 'BUFF_DYING' or verbCode == 'BUFF_DIE':
                    if effectCode not in ['ATTACK', 'DEFENSE', 'DAMAGE', 'ACCEL', 'BLAST', 'CHARGE', 'MAGIA', 'MP_GAIN', 'RESIST', 'ATTACK_FIRE']:
                        raise Exception('Unexpected: %s %s for %s in %g %s' % (verbCode, effectCode, key, pieceId, pieceName))
                    if verbCode == 'DEBUFF' and effectCode == 'CHARGE':
                        raise Exception('Report: %s %s realized for %s in %g %s' % (verbCode, effectCode, key, pieceId, pieceName))
                    if verbCode in ['BUFF_HPMAX', 'BUFF_DYING', 'BUFF_DIE'] and effectCode not in ['ATTACK', 'DEFENSE']:
                        raise Exception('Report: %s %s realized for %s in %g %s' % (verbCode, effectCode, key, pieceId, pieceName))
                elif verbCode == 'CONDITION_BAD' or verbCode == 'ENCHANT':
                    if effectCode not in ["CHARM", "STUN", "RESTRAINT", "POISON", "BURN", "CURSE", "FOG", "DARKNESS", "BLINDNESS", "BAN_SKILL", "BAN_MAGIA"]:
                        raise Exception('Unexpected: %s %s for %s in %g %s' % (verbCode, effectCode, key, pieceId, pieceName))
                    if verbCode == 'CONDITION_BAD' and pieceType == 'ABILITY':
                        raise Exception('Unexpected: ABILITY (passive) CONDITION_BAD %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                    if verbCode == 'ENCHANT' and pieceType == 'SKILL':
                        raise Exception('Unexpected: SKILL (active) ENCHANT %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                elif verbCode == 'CONDITION_GOOD':
                    if effectCode not in ["DAMAGE_UP", "DAMAGE_UP_BAD", "DAMAGE_DOWN", "DAMAGE_DOWN_BLAST", "DAMAGE_DOWN_NODISK", "CRITICAL", "DEFENSE_IGNORED", "AVOID", "COUNTER", "PROVOKE",  "PROTECT", "PURSUE", "GUTS", "SKILL_QUICK", "C_COMBO_PLUS", "AUTO_HEAL", "MP_PLUS_WEAKED", "MP_PLUS_BLAST"]:
                        raise Exception('Unexpected: CONDITION_GOOD %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                elif verbCode == 'IGNORE':
                    if effectCode not in ["DAMAGE_DOWN", "AVOID", "COUNTER", "PROVOKE", "CHARM", "STUN", "RESTRAINT", "POISON", "BURN", "CURSE", "FOG", "DARKNESS", "BLINDNESS", "BAN_SKILL", "BAN_MAGIA", "DEBUFF"]:
                        raise Exception('Unexpected: IGNORE %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                elif verbCode == 'HEAL':
                    if effectCode not in ['HP', 'MP', 'MP_DAMAGE']:
                        raise Exception('Unexpected: HEAL %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                    if effectCode == 'HP' and art['targetId'] not in ["SELF", "ONE"]:
                        raise Exception('Unexpected: HEAL HP %s for %s in %g %s' % (art['targetId'], key, pieceId, pieceName))
                    if pieceType == 'ABILITY':
                        raise Exception('Unexpected: ABILITY (passive) HEAL %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                elif verbCode == 'DRAW':
                    if effectCode not in ["AGAIN", "CHARACTER", "ACCEL", "BLAST", "CHARGE", "ALIGNMENT"]:
                        raise Exception('Unexpected: DRAW %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                    if pieceType == 'ABILITY':
                        raise Exception('Unexpected: ABILITY (passive) DRAW %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                elif verbCode == 'REVOKE':
                    if effectCode not in ["BAD", "DEBUFF", "BUFF", "CONDITION_GOOD"]:
                        raise Exception('Unexpected: REVOKE %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                    if pieceType == 'ABILITY':
                        raise Exception('Unexpected: ABILITY (passive) REVOKE %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                elif verbCode == 'INITIAL':
                    if effectCode != "MP":
                        raise Exception('Unexpected: INITIAL %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                elif verbCode == 'OTHER':
                    if effectCode not in ['EPISODE_UP', 'GOLD_UP']:
                        raise Exception('Unexpected: OTHER %s for %s in %g %s' % (effectCode, key, pieceId, pieceName))
                else:
                    raise Exception('Unexpected: %s %s for %s in %g %s' % (verbCode, effectCode, key, pieceId, pieceName))
    except Exception as e:
        if len(e.args) == 2:
            print(e.args[0])
            print(e.args[1])
        else:
            print(e)

def main():
    memoria = read_json(MEMORIA_JSON)
    wikitext = ""
    
    wikitext += "\n===攻击系===\n"
    columns = range(500, 150-50, -50)
    wikitext += table_header(columns, column_certain=True)
    wikitext += condition_good_p(memoria, "CRITICAL", "暴击", png(1121), columns)
    wikitext += condition_good_p(memoria, "DEFENSE_IGNORED", "无视防御", png(1123), columns)
    columns = range(800, 450-50, -50)
    wikitext += table_caption(columns, column_certain=True)
    wikitext += ignore(memoria, "DAMAGE_DOWN", "无视伤害削减", png(1177), columns)
    wikitext += table_footer()
    
    columns = range(350, 50-50, -50)
    # columns = range(400, 100-50, -50)
    wikitext += table_header(columns)
    wikitext += buff(memoria, "ATTACK", "攻击力UP(被动)", png(1085), columns, pieceType='ABILITY')
    columns = range(500, 200-50, -50)
    wikitext += table_caption(columns)
    wikitext += buff(memoria, "ATTACK", "攻击力UP(主动)", png(1085), columns, pieceType='SKILL')
    columns = range(400, 100-50, -50)
    # columns = range(450, 150-50, -50)
    wikitext += table_caption(columns)
    # data = separate(select(memoria, 'ABILITY', {"verbCode": "CONDITION_GOOD", "effectCode": "DAMAGE_UP"}) + select(memoria, 'ABILITY', {"verbCode": "BUFF", "effectCode": "DAMAGE"}), 'effectValue', columns)
    # wikitext += table_row([png(1087), png(1119)], "造成伤害UP&伤害上升状态(被动)", data, bad_target='TARGET')
    # data = separate(select(memoria, 'SKILL', {"verbCode": "CONDITION_GOOD", "effectCode": "DAMAGE_UP"}) + select(memoria, 'SKILL', {"verbCode": "BUFF", "effectCode": "DAMAGE"}), 'effectValue', columns)
    # wikitext += table_row([png(1087), png(1119)], "造成伤害UP&伤害上升状态(主动)", data, bad_target='TARGET')
    # wikitext += buff(memoria, "DAMAGE", "造成伤害UP", png(1087), columns)
    # wikitext += condition_good_v(memoria, "DAMAGE_UP", "伤害上升状态", png(1119), columns)
    wikitext += buff(memoria, "DAMAGE", "造成伤害UP(被动)", png(1087), columns, pieceType='ABILITY')
    wikitext += condition_good_v(memoria, "DAMAGE_UP", "伤害上升状态(被动)", png(1119), columns, pieceType='ABILITY')
    wikitext += buff(memoria, "DAMAGE", "造成伤害UP(主动)", png(1087), columns, pieceType='SKILL')
    wikitext += condition_good_v(memoria, "DAMAGE_UP", "伤害上升状态(主动)", png(1119), columns, pieceType='SKILL')
    wikitext += condition_good_v(memoria, "DAMAGE_UP_BAD", "敌方状态异常时伤害上升", png(1172), columns)
    columns = range(500, 200-50, -50)
    wikitext += table_caption(columns)
    wikitext += debuff(memoria, "DEFENSE", "防御力DOWN", png(1095), columns)
    wikitext += table_footer()
    
    columns = range(600, 200-50, -50)
    wikitext += table_header(columns)
    wikitext += buff(memoria, "BLAST", "Blast伤害UP", png(1092), columns)
    columns = range(250, 50-25, -25)
    wikitext += table_caption(columns)
    wikitext += buff(memoria, "CHARGE", "Charge后伤害UP", png(1091), columns)
    columns = range(250, 50-25, -25)
    wikitext += table_caption(columns)
    wikitext += buff(memoria, "CHARGING", "Charge盘伤害UP", png(1214), columns)
    columns = range(275, 75-25, -25)
    wikitext += table_caption(columns)
    wikitext += buff(memoria, "MAGIA", "Magia伤害UP", png(1088), columns)
    wikitext += buff(memoria, "DOPPEL", "Doppel伤害UP", png(1220), columns)
    columns = range(450, 50-50, -50)
    wikitext += table_caption(columns)
    wikitext += table_row(png(1085), "HP最大时攻击力UP", separate(select(memoria, '', {"verbCode": "BUFF_HPMAX", "effectCode": "ATTACK"}), 'effectValue', columns), bad_target='TARGET')
    wikitext += table_row(png(1241), "濒死时攻击力UP", separate(select(memoria, '', {"verbCode": "BUFF_DYING", "effectCode": "ATTACK"}), 'effectValue', columns), bad_target='TARGET')
    wikitext += table_row(png(1085), "战斗不能时获得攻击力UP(己全)", separate(select(memoria, '', {"verbCode": "BUFF_DIE", "effectCode": "ATTACK"}), 'effectValue', columns))
    wikitext += table_row(png(1213), "对魔女伤害UP", separate(select(memoria, '', {"verbCode": "LIMITED_ENEMY_TYPE", "effectCode": "DAMAGE_UP", "genericValue": "WITCH"}), 'effectValue', columns))
    wikitext += table_footer()

    columns = range(450, 50-50, -50)
    wikitext += table_caption(columns)
    wikitext += table_row(png(1233), "火属性攻击力UP", separate(select(memoria, '', {"verbCode": "BUFF", "effectCode": "ATTACK_FIRE"}), 'effectValue', columns))
    wikitext += table_row(png(1236), "水属性攻击力UP", separate(select(memoria, '', {"verbCode": "BUFF", "effectCode": "ATTACK_WATER"}), 'effectValue', columns))
    wikitext += table_row(png(1237), "木属性攻击力UP", separate(select(memoria, '', {"verbCode": "BUFF", "effectCode": "ATTACK_TIMBER"}), 'effectValue', columns))
    wikitext += table_row(png(1235), "光属性攻击力UP", separate(select(memoria, '', {"verbCode": "BUFF", "effectCode": "ATTACK_LIGHT"}), 'effectValue', columns))
    wikitext += table_row(png(1234), "暗属性攻击力UP", separate(select(memoria, '', {"verbCode": "BUFF", "effectCode": "ATTACK_DARK"}), 'effectValue', columns))
    wikitext += table_footer()
    
    wikitext += "\n===防守系===\n"
    columns = range(600, 150-75, -75)
    wikitext += table_header(columns)
    wikitext += buff(memoria, "DEFENSE", "防御力UP(被动)", png(1086), columns, pieceType='ABILITY')
    columns = range(675, 225-75, -75)
    wikitext += table_caption(columns)
    wikitext += buff(memoria, "DEFENSE", "防御力UP(主动)", png(1086), columns, pieceType='SKILL')
    columns = range(350, 50-50, -50)
    wikitext += table_caption(columns)
    wikitext += condition_good_v(memoria, "DAMAGE_DOWN", "伤害削减(被动)", png(1120), columns, pieceType='ABILITY')
    columns = range(500, 200-50, -50)
    wikitext += table_caption(columns)
    wikitext += condition_good_v(memoria, "DAMAGE_DOWN", "伤害削减(主动)", png(1120), columns, pieceType='SKILL')
    wikitext += debuff(memoria, "ATTACK", "攻击力DOWN", png(1094), columns)
    wikitext += debuff(memoria, "DAMAGE", "造成伤害DOWN", png(1096), columns)
    wikitext += condition_good_v(memoria, "DAMAGE_DOWN_BLAST", "Blast伤害削减", png(1202), columns)
    wikitext += condition_good_v(memoria, "DAMAGE_DOWN_NODISK", "Magia伤害削减状态", png(1205), columns)
    wikitext += debuff(memoria, "MAGIA", "Magia伤害DOWN", png(1097), columns)
    columns = range(375, 225-25, -25)
    wikitext += table_caption(columns)
    wikitext += debuff(memoria, "BLAST", "Blast伤害DOWN", png(1101), columns)
    columns = range(900, 300-100, -100)
    wikitext += table_caption(columns)
    wikitext += table_row(png(1086), "HP最大时防御力UP", separate(select(memoria, '', {"verbCode": "BUFF_HPMAX", "effectCode": "DEFENSE"}), 'effectValue', columns), bad_target='TARGET')
    wikitext += table_row(png(1242), "濒死时防御力UP", separate(select(memoria, '', {"verbCode": "BUFF_DYING", "effectCode": "DEFENSE"}), 'effectValue', columns), bad_target='TARGET')
    wikitext += table_row(png(1086), "战斗不能时获得防御力UP(己全)", separate(select(memoria, '', {"verbCode": "BUFF_DIE", "effectCode": "DEFENSE"}), 'effectValue', columns))
    wikitext += table_footer()
    
    wikitext += "\n===MP获取与阻碍===\n"
    columns = range(250, 100-25, -25)
    wikitext += table_header(columns)
    wikitext += buff(memoria, "ACCEL", "Accele MPUP(被动)", png(1090), columns, pieceType='ABILITY')
    columns = range(300, 150-25, -25)
    wikitext += table_caption(columns)
    wikitext += buff(memoria, "ACCEL", "Accele MPUP(主动)", png(1090), columns, pieceType='SKILL')
    columns = range(200, 50-25, -25)
    wikitext += table_caption(columns)
    wikitext += buff(memoria, "MP_GAIN", "MP获得量UP", png(1093), columns)
    wikitext += table_footer()
    
    columns = [150, 100]
    wikitext += table_header(columns)
    wikitext += table_row(png(1130), "战斗开始时拥有一定MP", separate(select(memoria, '', {"verbCode": "INITIAL", "effectCode": "MP"}), 'effectValue', columns))
    columns = [180, 100]
    wikitext += table_caption(columns, percentage=False)
    wikitext += table_row(png(1079), "回复MP", separate(select(memoria, '', {"verbCode": "HEAL", "effectCode": "MP"}), 'effectValue', columns, percentage=False))
    columns = [30]
    wikitext += table_caption(columns, percentage=False)
    wikitext += table_row(png(1180), "自动回复MP", separate(select(memoria, '', {"verbCode": "CONDITION_GOOD", "effectCode": "AUTO_HEAL", "genericValue": "MP"}), 'effectValue', columns, percentage=False))
    columns = range(70, 20-10, -10)
    wikitext += table_caption(columns, percentage=False)
    wikitext += condition_good_v(memoria, "MP_PLUS_WEAKED", "被弱点属性攻击时MPUP", png(1132), columns, percentage=False)
    columns = [40, 30]
    wikitext += table_caption(columns, percentage=False)
    wikitext += condition_good_v(memoria, "MP_PLUS_BLAST", "Blast攻击时MP获得", png(1225), columns, percentage=False)
    columns = range(500, 250-50, -50)
    wikitext += table_caption(columns)
    wikitext += debuff(memoria, "MP_GAIN", "MP获得量DOWN", png(1102), columns)
    columns = [275]
    wikitext += table_caption(columns)
    wikitext += debuff(memoria, "ACCEL", "Accele MP DOWN", png(1099), columns)
    columns = [300]
    wikitext += table_caption(columns, percentage=False)
    wikitext += table_row(png(1176), "MP伤害", separate(select(memoria, '', {"verbCode": "HEAL", "effectCode": "MP_DAMAGE"}), 'effectValue', columns, percentage=False), bad_target='SELF')
    wikitext += table_footer()
    
    wikitext += "\n===特殊行动、特殊对策===\n"
    columns = range(550, 150-50, -50)
    wikitext += table_header(columns, column_certain=True)
    wikitext += condition_good_p(memoria, "AVOID", "回避", png(1124), columns)
    wikitext += condition_good_p(memoria, "COUNTER", "反击", png(1125), columns)
    wikitext += condition_good_p(memoria, "PROVOKE", "挑衅", png(1128), columns)
    wikitext += condition_good_p(memoria, "PROTECT", "保护", png(1170), columns)
    data = separate(select(memoria, 'SKILL', {"verbCode": "CONDITION_GOOD", "effectCode": "PURSUE"}), 'probability', columns)
    wikitext += table_row(png(1126), "追击(主动)", data, column_certain=True)
    columns = range(120, 40-10, -10)
    wikitext += table_caption(columns, column_certain=True)
    data = separate(select(memoria, 'ABILITY', {"verbCode": "CONDITION_GOOD", "effectCode": "PURSUE"}), 'probability', columns)
    wikitext += table_row(png(1126), "追击(被动)", data, column_certain=True)
    wikitext += table_footer()
    
    columns = range(850, 500-50, -50)
    wikitext += table_header(columns, column_certain=True)
    wikitext += ignore(memoria, "AVOID", "回避无效", png(1134), columns)
    wikitext += ignore(memoria, "COUNTER", "反击无效", png(1135), columns)
    wikitext += ignore(memoria, "PROVOKE", "无视挑衅", png(1219), columns)
    wikitext += table_footer()
    
    wikitext += "\n===异常、抗异常===\n"
    ailmentEffectCodes = ["CHARM", "STUN", "RESTRAINT", "POISON", "BURN", "CURSE", "FOG", "DARKNESS", "BLINDNESS", "BAN_SKILL", "BAN_MAGIA"]
    ailmentNames = ["魅惑", "眩晕", "拘束", "毒", "烧伤", "诅咒", "雾", "黑暗", "幻惑", "技能封印", "Magia封印"]
    icons = [png(i) for i in range(1103, 1114)]
    columns = range(525, 300-25, -25)
    wikitext += table_header(columns, column_certain=True)
    wikitext += ''.join([active_ailments(memoria, *i, columns) for i in zip(ailmentEffectCodes, ["主动"+x for x in ailmentNames], icons)])
    wikitext += table_caption(columns, column_certain=True)
    wikitext += table_footer()
    
    icons = [png(i) for i in range(1145, 1155)] + [""]
    columns = range(450, 100-50, -50)
    wikitext += table_header(columns, column_certain=True)
    wikitext += ''.join([passive_ailments(memoria, *i, columns) for i in zip(ailmentEffectCodes, ["攻击时概率给予"+x for x in ailmentNames], icons)])
    wikitext += table_caption(columns, column_certain=True)
    wikitext += table_footer()
    
    icons = [png(i) for i in list(range(1136, 1145))+[1183, 1155]]
    columns = range(700, 600-50, -50)
    wikitext += table_header(columns, column_certain=True)
    wikitext += ''.join([ignore(memoria, *i, columns) for i in zip(ailmentEffectCodes, ["概率"+x+"无效" for x in ailmentNames], icons)])
    wikitext += table_caption(columns, column_certain=True)
    wikitext += table_footer()
    
    columns = range(600, 250-50, -50)
    wikitext += table_header(columns)
    wikitext += buff(memoria, "RESIST", "状态异常耐性UP", png(1089), columns)
    columns = range(250, 75-25, -25)
    wikitext += table_caption(columns)
    wikitext += debuff(memoria, "RESIST", "状态异常耐性DOWN", png(1098), columns)
    wikitext += table_footer()
    
    wikitext += "\n===重抽盘===\n"
    wikitext += table_header([], column_certain=True, icon_width='150px')
    wikitext += draw(memoria, "AGAIN", "重抽盘", png(1169))
    wikitext += draw(memoria, "CHARACTER", "重抽自己盘", [png(1161), png(1162), png(1163), png(1164), png(1165)])
    wikitext += draw(memoria, "ACCEL", "重抽Accele盘", png(1166))
    wikitext += draw(memoria, "BLAST", "重抽Blast盘", png(1168))
    wikitext += draw(memoria, "CHARGE", "重抽Charge盘", png(1167))
    wikitext += draw(memoria, "ALIGNMENT", "重抽同属性盘", [png(1156), png(1157), png(1158), png(1159), png(1160)])
    wikitext += table_footer()
    
    wikitext += "\n===回复、状态恢复===\n"
    columns = range(375, 275-25, -25)
    wikitext += table_header(columns, percentage=False)
    wikitext += table_row(png(1078), "回复HP(自己)", separate(select(memoria, '', {"verbCode": "HEAL", "effectCode": "HP", "targetId": "SELF"}), 'effectValue', columns, percentage=False), bad_target='TARGET')
    wikitext += table_row(png(1078), "回复HP(队友)", separate(select(memoria, '', {"verbCode": "HEAL", "effectCode": "HP", "targetId": "ONE"}), 'effectValue', columns, percentage=False), bad_target='TARGET')
    columns = range(60, 20-10, -10)
    wikitext += table_caption(columns)
    wikitext += table_row(png(1129), "自动回复HP", separate(select(memoria, '', {"verbCode": "CONDITION_GOOD", "effectCode": "AUTO_HEAL", "EXCEPT": {"genericValue": "MP"}}), 'effectValue', columns), bad_target='TARGET')
    wikitext += table_footer()
    
    wikitext += table_header([])
    wikitext += table_row(png(1084), "状态异常解除", [select(memoria, 'SKILL', {"verbCode": "REVOKE", "effectCode": "BAD"})], bad_target='TARGET')
    wikitext += table_row(png(1082), "Debuff解除", [select(memoria, 'SKILL', {"verbCode": "REVOKE", "effectCode": "DEBUFF"})], bad_target='TARGET')
    wikitext += table_row(png(1081), "Buff解除", [select(memoria, 'SKILL', {"verbCode": "REVOKE", "effectCode": "BUFF"})], bad_target='SELF')
    wikitext += table_row(png(1083), "状态强化解除", [select(memoria, 'SKILL', {"verbCode": "REVOKE", "effectCode": "GOOD"})], bad_target='SELF')
    wikitext += table_footer()
    
    wikitext += "\n===其他===\n"
    wikitext += table_header([], column_certain=True)
    wikitext += condition_good_p(memoria, "GUTS", "忍耐", png(1127), [])
    wikitext += condition_good_p(memoria, "SKILL_QUICK", "技能冷却加速", png(1131), [])
    wikitext += ignore(memoria, "DEBUFF", "Debuff无效", png(1218), [])
    wikitext += table_footer()
    
    wikitext += table_header([20], percentage=False)  # 记忆的效果数值是2000,既不代表200%也不代表200ptHP或MP,而是代表2层charge combo,为了让header显示出2需要输入20
    wikitext += condition_good_v(memoria, "C_COMBO_PLUS", "Charge combo时Charge数增加", png(1217), [2000])
    wikitext += table_footer()
    
    columns = range(200, 50-50, -50)
    wikitext += table_header(columns)
    wikitext += table_row(png(1173), "获得篇章点UP", separate(select(memoria, '', {"verbCode": "OTHER", "effectCode": "EPISODE_UP"}), 'effectValue', columns))
    wikitext += table_row(png(1175), "CC获得量UP", separate(select(memoria, '', {"verbCode": "OTHER", "effectCode": "GOLD_UP"}), 'effectValue', columns))
    wikitext += table_footer()
    
    
    write_wiki(OUTPUT, wikitext)
    print("wikitext written")
    
    print("proceed to sanity check")
    for k, v in memoria.items():
        sanityCheck(v)


if __name__ == '__main__':
    main()