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

Module:FGOTables

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

本模块仅用于{{FGO_数据总表}},可用来生成适用于Fate/Grand Order整个游戏的游戏数据表格。

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

local FGOData = require('Module:FGOData')

local generateClassTitles = function (title)
    local retstr = '! style="min-width:100px" |' .. title
    for i = 1, #(FGOData.classKeys) do
        retstr = retstr .. '!! style="' ..
        FGOData.getFromDefaultedTable(FGOData.classTextStyle, FGOData.classKeys[i]) .. 
        'min-width:100px;" |' ..
        FGOData.getClassTitle(FGOData.classKeys[i])
    end
    return retstr
end

local generateClassTable = function (tbl, stylelookup, name, formatter)
    local retstr = [[<div style="max-width:100%;overflow:auto">
    {| class="wikitable" style="text-align:center;font-weight:bold;background:#FFF"
    |-
    ]] .. generateClassTitles('职阶')
    retstr = retstr .. [[

    |-
    ! style="height:2em" |]] .. name
    for i = 1, #(FGOData.classKeys) do
        classVal = FGOData.getFromDefaultedTable(tbl, FGOData.classKeys[i])
        if i == 1 then
            retstr = retstr .. [[

            |]]
        else
            retstr = retstr .. '||'
        end
        retstr = retstr .. stylelookup(classVal) .. formatter(classVal)
    end

    retstr = retstr .. [[

    |}
    </div>]]
    return retstr
end

local FGOTables = {
    classMultTable = function ()
        local retstr = [[<div style="max-width:100%;overflow:auto">
        {| class="wikitable" style="text-align:center;font-weight:bold;background:#FFF"
        |-
        ! colspan="]] .. (#(FGOData.classKeys) + 1) .. [[" | 职阶克制关系
        |-
        ]] .. generateClassTitles([[攻击\防御]])
        for i = 1, #(FGOData.classKeys) do
            retstr = retstr .. [[

            |-
            ! style="]] ..
            FGOData.getFromDefaultedTable(FGOData.classTextStyle, FGOData.classKeys[i]) .. '" |' ..
            FGOData.getClassTitle(FGOData.classKeys[i])
            for j = 1, #(FGOData.classKeys) do
                local classMult = FGOData.getFromDefaultedTable2d(FGOData.classMultFromTo, FGOData.classKeys[i], FGOData.classKeys[j])
                if j == 1 then
                    retstr = retstr .. [[

                    |]]
                else
                    retstr = retstr .. '||'
                end
                retstr = retstr .. FGOData.getClassMultStyle(classMult) .. string.format('%.1f', classMult)
            end
        end

        retstr = retstr .. [[

        |}
        </div>]]
        return retstr
    end,

    hiddenAlignMultTable = function ()
        local retstr = [[<div style="max-width:100%;overflow:auto">
        {| class="wikitable" style="text-align:center;font-weight:bold;background:#FFF;line-height:2em"
        |-
        ! colspan="]] .. (#(FGOData.hiddenAlignNamesChinese) + 1) .. [[" | 隐藏属性克制关系
        |-
        ! style="min-width:80px" | 攻击\防御]]
        for i = 1, #(FGOData.hiddenAlignNamesChinese) do
            retstr = retstr .. '!! style="min-width:50px" |' .. FGOData.hiddenAlignNamesChinese[i]
        end 
        for i = 1, #(FGOData.hiddenAlignNamesChinese) do
            retstr = retstr .. [[

            |-
            ! ]] .. FGOData.hiddenAlignNamesChinese[i]
            for j = 1, #(FGOData.hiddenAlignNamesChinese) do
                local alignMult = FGOData.getFromDefaultedTable2d(FGOData.hiddenAlignMultFromTo, i, j)
                if j == 1 then
                    retstr = retstr .. [[

                    |]]
                else
                    retstr = retstr .. '||'
                end
                retstr = retstr .. FGOData.getHiddenAlignMultStyle(alignMult) .. string.format('%.1f', alignMult)
            end
        end

        retstr = retstr .. [[

        |}
        </div>]]
        return retstr
    end,

    classAtkCoeffTable = function ()
        return generateClassTable(
            FGOData.classAtkCoeff,
            FGOData.getClassAtkCoeffStyle,
            '伤害系数',
            function(s) return string.format('%.2f', s) end)
    end,

    baseStarDropRateTable = function ()
        return generateClassTable(
            FGOData.baseStarDropRate,
            FGOData.getBaseStarDropRateStyle,
            '暴击星掉落率',
            function(s) return s .. '%' end)
    end,

    baseStarWeightTable = function ()
        return generateClassTable(
            FGOData.baseStarWeight,
            FGOData.getBaseStarWeightStyle,
            '暴击星集中度',
            function(s) return s end)
    end,

    baseInstakillRateTable = function ()
        return generateClassTable(
            FGOData.baseInstakillRate,
            FGOData.getBaseInstakillRateStyle,
            '被即死率',
            function(s) return s .. '%' end)
    end
}

return FGOTables