置顶公告:【置顶】关于临时开启评论区所有功能的公告(2022.10.22) | 【置顶】关于本站Widget恢复使用的公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:FGOClass

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [查看] [编辑] [历史] [刷新]

本模块仅用于{{FGO_职阶信息}},可用来生成Fate/Grand_Order从者的职阶数据表。

-- Originally designed and coded by Maya (U:MJH)

local getArgs = require("Module:Arguments").getArgs
local FGOData = require("Module:FGOData")

local generateTabs = function (args)
    local retstr = '<div class="Tabs" data-label-side="top" style="width:220px;margin:auto" data-label-padding="2px" data-text-padding="0px 0px">'
    for i = 1, #(args['卡背args'].labels) do
        retstr = retstr .. '<div class="Tab"><div class="TabLabelText">' .. args['卡背args'].labels[i] ..
        [=[</div><div class="TabContentText">[[File:]=] .. args['卡背args'].filenames[i] .. [=[.png|185px]]</div></div>]=]
    end    
    retstr = retstr .. '</div>'
    return retstr
end

local fillDefaultAndConstructArgs = function (args)
    local i = 1
    args['卡背args'] = { labels = {} , filenames = {} }
    while i <= 3 or args['卡背名称' .. i] do
        args['卡背args'].labels[i] = args['卡背名称' .. i] or FGOData.classCardTabTitles[-1][i]
        args['卡背args'].filenames[i] = args['卡背文件名' .. i] or 
        ((args['卡背立绘' .. i] or args['卡背'] or 'Shielder') ..
        (args['卡背名称' .. i] or FGOData.classCardTabTitles[-1][i]))
        i = i + 1
    end
    args['伤害系数'] = args['伤害系数'] or FGOData.classAtkCoeff[-1]
    args['暴击星掉落率'] = args['暴击星掉落率'] or FGOData.baseStarDropRate[-1]
    args['暴击星集中度'] = args['暴击星集中度'] or FGOData.baseStarWeight[-1]
    args['被即死率'] = args['被即死率'] or FGOData.baseInstakillRate[-1]
    args['充能格数'] = args['充能格数'] or FGOData.baseChargeLength[-1]
    args['行动次数'] = args['行动次数'] or FGOData.baseActionCount[-1]
    args['行动优先度'] = args['行动优先度'] or FGOData.baseActionPriority[-1]
    args['攻args'] = {}
    args['防args'] = {}
    for i = 1, #FGOData.classKeys do
        args['攻args'][i] = args[FGOData.classNames[FGOData.classKeys[i]] .. '攻'] or 
        FGOData.getFromDefaultedTable2d(FGOData.classMultFromTo, nil, FGOData.classKeys[i])
        args['防args'][i] = args[FGOData.classNames[FGOData.classKeys[i]] .. '防'] or 
        FGOData.getFromDefaultedTable2d(FGOData.classMultFromTo, FGOData.classKeys[i], nil)
    end
end

local classDataTableCore = function (args)
    local tabTemp = ''
    if next(args['卡背args'].labels) then tabTemp = generateTabs(args) else tabTemp = '卡背暂缺' end
    local mults = ''
    local titletemp = ''
    local atktemp = ''
    local deftemp = ''
    for i = 1, #FGOData.classKeys do
        if i % 7 == 1 then
            mults = mults .. titletemp .. atktemp .. deftemp
            titletemp = [[
                
            |-
            ! style="width:7%" | 职阶相性]]
            atktemp = [[

            |-
            ! 造成伤害]]
            deftemp = [[

            |-
            ! 受到伤害]]
        end
        titletemp = titletemp .. [=[!![[]=] .. FGOData.classLinks[FGOData.classKeys[i]] .. '|' 
        	.. (FGOData.classNamesDisplay[FGOData.classKeys[i]] or FGOData.classNames[FGOData.classKeys[i]]) 
        	.. FGOData.getFromDefaultedTable(FGOData.classNamesInfo, FGOData.classKeys[i]) .. [=[]]]=]
        atktemp = atktemp .. [[

        |]] .. FGOData.getClassMultStyle(args['攻args'][i]) .. string.format('%.1f', args['攻args'][i])
        deftemp = deftemp .. [[

        |]] .. FGOData.getClassMultStyle(args['防args'][i]) .. string.format('%.1f', args['防args'][i])
    end

    local multsSpanTaken = #FGOData.classKeys % 7
    if multsSpanTaken ~= 0 then
        multsRestSpan = 7 - multsSpanTaken
        titletemp = titletemp .. [[
            
        | rowspan=3 colspan=]] .. multsRestSpan .. ' style="background:#CCC" |'
    end
    mults = mults .. titletemp .. atktemp .. deftemp

    return [[<div style="max-width:100%;overflow:auto">
    {| class="wikitable" style="text-align:center;background:#FFF"
    |-
    ! rowspan=3 |]] .. (args['图标整体'] or FGOData.getClassIconCore(args['图标'], args['图标链接'], 40)) ..
    '!! colspan=8 |' .. args['职阶'] .. [[

    |-
    | colspan=8 lang="ja" | -{]] .. args['日文名称'] .. [[}-

    |-
    | colspan=8 |]] .. args['中文名称'] .. [[

    |-
    | rowspan=15 style="min-width:230px;margin:auto;" |]] .. tabTemp ..
    [[
        
    ! rowspan=3 style="min-width:70px;" | 常规数值 !! colspan=4 | 己方 !! colspan=3 | 敌方
    |-
    ! style="min-width:100px" | 伤害系数
    ! style="min-width:100px" | 暴击星掉落率
    ! style="min-width:100px" | 暴击星集中度
    ! style="min-width:100px" | 被即死率
    ! style="min-width:100px" | 充能格数
    ! style="min-width:100px" | 行动次数
    ! style="min-width:100px" | 行动优先度
    |-
    | ]] .. FGOData.getClassAtkCoeffStyle(args['伤害系数']) .. string.format('%.2f', args['伤害系数']) ..
    '||' .. FGOData.getBaseStarDropRateStyle(args['暴击星掉落率'] or args['掉星率']) .. (args['暴击星掉落率'] or args['掉星率']) ..
    '%||' .. FGOData.getBaseStarWeightStyle(args['暴击星集中度'] or args['集星权重']) .. (args['暴击星集中度'] or args['集星权重']) ..
    '||' .. FGOData.getBaseInstakillRateStyle(args['被即死率']) .. (args['被即死率']) ..
    '%||' .. FGOData.getBaseChargeLengthStyle(args['充能格数']) .. (args['充能格数']) ..
    '||' .. FGOData.getBaseActionCountStyle(args['行动次数']) .. (args['行动次数']) ..
    '||' .. FGOData.getBaseActionPriorityStyle(args['行动优先度']) .. (args['行动优先度']) .. mults .. [[

    |}
    </div>]]
end

local FGOClass = {
    main = function (frame)
        local args = getArgs(frame)
        local classIndex = FGOData.classNamesInverse[args['职阶'] or args[1]]
        local argsToCore = {}
        if classIndex then
            argsToCore['职阶'] = FGOData.classNames[classIndex]
            argsToCore['中文名称'] = FGOData.classNamesChinese[classIndex]
            argsToCore['日文名称'] = FGOData.classNamesJapanese[classIndex]
            argsToCore['图标整体'] = FGOData.getClassIcon(classIndex, 40)
            local classCardFilenames = {}
            local classCardFilenameSuffix = FGOData.getFromDefaultedTable(FGOData.classCardFilenameSuffixes, classIndex)
            for i = 1, #classCardFilenameSuffix do
                classCardFilenames[i] = FGOData.classNames[classIndex] .. classCardFilenameSuffix[i]
            end
            argsToCore['卡背args'] = {
                labels = FGOData.getFromDefaultedTable(FGOData.classCardTabTitles, classIndex),
                filenames = classCardFilenames
            }
            argsToCore['伤害系数'] = FGOData.getFromDefaultedTable(FGOData.classAtkCoeff, classIndex)
            argsToCore['暴击星掉落率'] = FGOData.getFromDefaultedTable(FGOData.baseStarDropRate, classIndex)
            argsToCore['暴击星集中度'] = FGOData.getFromDefaultedTable(FGOData.baseStarWeight, classIndex)
            argsToCore['被即死率'] = FGOData.getFromDefaultedTable(FGOData.baseInstakillRate, classIndex)
            argsToCore['充能格数'] = FGOData.getFromDefaultedTable(FGOData.baseChargeLength, classIndex)
            argsToCore['行动次数'] = FGOData.getFromDefaultedTable(FGOData.baseActionCount, classIndex)
            argsToCore['行动优先度'] = FGOData.getFromDefaultedTable(FGOData.baseActionPriority, classIndex)
            argsToCore['攻args'] = {}
            argsToCore['防args'] = {}
            for i = 1, #FGOData.classKeys do
                argsToCore['攻args'][i] = FGOData.getFromDefaultedTable2d(FGOData.classMultFromTo, classIndex, FGOData.classKeys[i])
                argsToCore['防args'][i] = FGOData.getFromDefaultedTable2d(FGOData.classMultFromTo, FGOData.classKeys[i], classIndex)
            end
        else
            argsToCore = args
            fillDefaultAndConstructArgs(argsToCore)
        end
        return classDataTableCore(argsToCore)
    end,
    classTitle = function (frame)
        local args = getArgs(frame)
        local classIndexer = args[1]
        local size = args[2]
        local link = args[3]
        if not tonumber(classIndexer) then
            classIndexer = FGOData.classNamesInverse[classIndexer]
        end
        return FGOData.getClassTitle(classIndexer, size, link)
    end
}

return FGOClass