打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模块:CardData:修订间差异

来自夜幕之下
Rin留言 | 贡献
无编辑摘要
标签已被回退
Rin留言 | 贡献
无编辑摘要
标签已被回退
第24行: 第24行:
         :addClass("card_content-item-title")
         :addClass("card_content-item-title")
         :addClass("card_content-item-title--mt")
         :addClass("card_content-item-title--mt")
     if extraClass then div:addClass(extraClass) end
     if extraClass then div:addClass(extraClass) end
     div:wikitext(titleText)
     div:wikitext(titleText)
     div:tag("span"):addClass("card_content-item-subtitle"):wikitext(subtitleText)
     div:tag("span")
        :addClass("card_content-item-subtitle")
        :wikitext(subtitleText)
 
     return div
     return div
end
end


local function makeHr(extraClass)
local function makeHr(extraClass)
     local div = mw.html.create("div"):addClass("card_content-item-hr")
     local div = mw.html.create("div")
        :addClass("card_content-item-hr")
 
     if extraClass then div:addClass(extraClass) end
     if extraClass then div:addClass(extraClass) end
     return div
     return div
end
end


local function makeTriggerLabel(triggerType, triggerValue)
local function makeStoryTimeline(stories, cardTitle)
     local span = mw.html.create("span"):addClass("card_content_skill-meta-val")
 
    if triggerType == "normal_attack" then
     local timeline = mw.html.create("div")
        span:wikitext("每进行")
         :addClass("card_timeline card_content_story-timeline")
         span:tag("span"):addClass("card_accent"):wikitext(tostring(triggerValue or "?"))
        span:wikitext("次普攻")
    else
        span:wikitext(val(triggerType))
    end
    return span
end


local function makeTagsRow(tagsJson)
     timeline:tag("div")
     local div = mw.html.create("div"):addClass("card_content_skill-tags")
         :addClass("card_timeline-line")
    local tags = parseJson(tagsJson)
    if tags and type(tags) == "table" then
         for _, tag in ipairs(tags) do
            div:tag("div"):addClass("card_content_skill-tag"):wikitext(tag)
        end
    end
    return div
end


local function makeUpgradeTable(levelsJson)
     -- 更安全获取 entry
     local wrap = mw.html.create("div"):addClass("card_content_skill-upgrade")
     local entry
    local rows = parseJson(levelsJson)
     if type(stories) == "table" then
    if not rows or type(rows) ~= "table" or #rows == 0 then return wrap end
        for _,v in pairs(stories) do
    local colCount = 0
            entry = v
    if rows[1] and rows[1].levels then colCount = #rows[1].levels end
             break
    local gridClass = "card_content_skill-upgrade-grid"
    if colCount >= 10 then gridClass = gridClass .. " card_content_skill-upgrade-grid--10" end
     local grid = wrap:tag("div"):addClass(gridClass)
     grid:tag("div")
    for i = 2, colCount do
        grid:tag("div"):addClass("card_content_skill-upgrade-lv"):wikitext(tostring(i))
    end
    for idx, row in ipairs(rows) do
        local labelCell = grid:tag("div"):addClass("card_content_skill-upgrade-row-label")
        labelCell:tag("span"):addClass("card_content_skill-upgrade-badge"):wikitext(tostring(idx))
        labelCell:tag("span"):addClass("card_content_skill-upgrade-badge-text"):wikitext(val(row.name, ""))
        labelCell:tag("span"):addClass("card_content_skill-upgrade-arrow"):wikitext("→")
        if row.levels and type(row.levels) == "table" then
            for _, v in ipairs(row.levels) do
                local cell = grid:tag("div"):addClass("card_content_skill-upgrade-val")
                if v == nil or v == "" or v == "—" then
                    cell:addClass("card_content_skill-upgrade-val--null"):wikitext("—")
                else
                    cell:addClass("card_accent"):wikitext(tostring(v))
                end
             end
         end
         end
     end
     end
    return wrap
end


local function makeSkillCard(skillData, skillType)
     local chapters = entry and entry.story or {}
    local card = mw.html.create("div"):addClass("card_content_skill-card")
    local left = card:tag("div"):addClass("card_content_skill-left")
    local titleRow = left:tag("div"):addClass("card_content_skill-title")
    titleRow:tag("div"):addClass("card_content_skill-icon")
    local titleText = titleRow:tag("div"):addClass("card_content_skill-title-text")
    local nameRow = titleText:tag("div")
    nameRow:tag("span"):addClass("card_content_skill-name"):wikitext(val(skillData.name))
    nameRow:tag("span"):addClass("card_content_skill-type card_accent--type")
        :wikitext("「" .. val(skillData.type) .. "」")
     local metaRow = titleText:tag("div"):addClass("card_content_skill-meta")
    if skillType == "normal_attack" then
        metaRow:wikitext("使用武器 ")
        metaRow:tag("span"):addClass("card_content_skill-meta-val card_accent"):wikitext(val(skillData.weapon))
    elseif skillType == "passive" then
        metaRow:wikitext("触发条件 ")
        metaRow:node(makeTriggerLabel(skillData.trigger_type, skillData.trigger_value))
    elseif skillType == "ultimate" then
        metaRow:wikitext("欲火消耗 ")
        metaRow:tag("span"):addClass("card_content_skill-meta-val")
            :tag("span"):addClass("card_accent"):wikitext(val(skillData.desire_cost))
    end
    if skillType == "passive" or skillType == "ultimate" then
        left:node(makeTagsRow(skillData.tags))
    end
    left:tag("div"):addClass("card_content_skill_effect"):wikitext(val(skillData.description))
    card:node(makeUpgradeTable(skillData.levels))
    return card
end


local function makeFeatList(stagesJson)
     if not chapters or type(chapters) ~= "table" then
    local ul = mw.html.create("ul"):addClass("card_content_feat-ul")
         chapters = {}
    local stages = parseJson(stagesJson)
     if not stages or type(stages) ~= "table" then
         ul:tag("li"):wikitext("—")
        return ul
     end
     end
    for _, stage in ipairs(stages) do
        local li  = ul:tag("li"):addClass("card_content_feat-list")
        local row = li:tag("div"):addClass("card_content_feat-row")
        local sw  = row:tag("div"):addClass("card_content_feat-stage-wrap")
        sw:tag("p"):tag("span"):addClass("card_content_feat-stage"):wikitext("STAGE")
        sw:tag("div"):addClass("card_content_feat-number")
            :wikitext(string.format("%02d", stage.stage or 0))
        local rd = row:tag("div")
        if stage.value and type(stage.value) == "table" then
            for _, v in ipairs(stage.value) do
                if v.description then
                    rd:tag("span"):addClass("card_accent"):wikitext(v.description)
                    rd:tag("br")
                end
            end
        end
        if stage.stat_boosts and type(stage.stat_boosts) == "table" then
            for _, boost in ipairs(stage.stat_boosts) do
                rd:wikitext((boost.type or "") .. "提升" .. (boost.value or ""))
            end
        end
        if stage.extra_name then
            rd:tag("span"):addClass("card_content_feat-stage-cn")
                :wikitext("「" .. stage.extra_name .. "」")
        end
    end
    return ul
end


local function makeStoryTimeline(stories, cardTitle)
     if next(chapters) == nil then
     local timeline = mw.html.create("div")
         timeline:tag("div")
        :addClass("card_timeline card_content_story-timeline")
            :addClass("card_timeline-item")
    timeline:tag("div"):addClass("card_timeline-line")
            :wikitext("(小传数据待补充)")
    local entry    = stories and type(stories) == "table" and stories[1]
    local chapters = entry and type(entry.story) == "table" and entry.story or {}
    if #chapters == 0 then
         timeline:tag("div"):addClass("card_timeline-item"):wikitext("(小传数据待补充)")
         return timeline
         return timeline
     end
     end
     local romans       = { "Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ" }
 
     local unlockLevels = { "Lv.20 解锁", "Lv.40 解锁", "Lv.60 解锁", "Lv.80 解锁", "Lv.100 解锁" }
     local romans = { "Ⅰ","Ⅱ","Ⅲ","Ⅳ","Ⅴ","Ⅵ","Ⅶ","Ⅷ" }
     for idx, chapter in ipairs(chapters) do
     local unlockLevels = {
         local item = timeline:tag("div"):addClass("card_timeline-item")
        "Lv.20 解锁",
        if idx == #chapters then item:addClass("card_timeline-item--last") end
        "Lv.40 解锁",
         item:tag("div"):addClass("card_timeline-dot")
        "Lv.60 解锁",
         item:tag("div"):addClass("card_timeline-unlock")
        "Lv.80 解锁",
             :wikitext(unlockLevels[idx] or ("Lv." .. (idx * 20) .. " 解锁"))
        "Lv.100 解锁"
         local titleDiv = item:tag("div"):addClass("card_timeline-title")
    }
         titleDiv:tag("span"):addClass("card_timeline-numeral"):wikitext(romans[idx] or tostring(idx))
 
         titleDiv:tag("span"):addClass("card_timeline-chapter"):wikitext(cardTitle or "")
    local idx = 1
         titleDiv:tag("span"):addClass("card_timeline-label"):wikitext("/ Story")
 
         local bodyDiv = item:tag("div"):addClass("card_timeline-body")
     for _, chapter in pairs(chapters) do
 
         local item = timeline:tag("div")
            :addClass("card_timeline-item")
 
         item:tag("div")
            :addClass("card_timeline-dot")
 
         item:tag("div")
            :addClass("card_timeline-unlock")
             :wikitext(unlockLevels[idx] or ("Lv."..(idx*20).." 解锁"))
 
         local titleDiv = item:tag("div")
            :addClass("card_timeline-title")
 
         titleDiv:tag("span")
            :addClass("card_timeline-numeral")
            :wikitext(romans[idx] or idx)
 
         titleDiv:tag("span")
            :addClass("card_timeline-chapter")
            :wikitext(cardTitle or "")
 
         titleDiv:tag("span")
            :addClass("card_timeline-label")
            :wikitext("/ Story")
 
         local bodyDiv = item:tag("div")
            :addClass("card_timeline-body")
 
         local text = chapter.text or ""
         local text = chapter.text or ""
         if text ~= "" then
         if text ~= "" then
             local lines = mw.text.split(text, "\n")
 
             for i, line in ipairs(lines) do
             local lines = mw.text.split(text,"\n")
                 if line ~= "" then bodyDiv:wikitext(line) end
 
                 if i < #lines then bodyDiv:tag("br") end
             for i,line in ipairs(lines) do
 
                 if line ~= "" then
                    bodyDiv:wikitext(line)
                end
 
                 if i < #lines then
                    bodyDiv:tag("br")
                end
 
             end
             end
         end
         end
        idx = idx + 1
     end
     end
     return timeline
     return timeline
end
end


function p.render(frame)
function p.render(frame)
     local name = mw.text.trim(frame.args[1] or frame.args.name or "")
     local name = mw.text.trim(frame.args[1] or frame.args.name or "")
     if name == "" then
     if name == "" then
         return '<span class="error">错误:请提供卡片名称</span>'
         return '<span class="error">错误:请提供卡片名称</span>'
     end
     end


    -- 关键:stories.story.*
     local fields = table.concat({
     local fields = table.concat({
         "stylename", "rarity",
 
         "character.name", "profession.name", "desire.name",
         "stylename",
         "skill_normal_attack.name", "skill_normal_attack.type",
        "rarity",
         "skill_normal_attack.weapon", "skill_normal_attack.description",
 
         "character.name",
        "profession.name",
        "desire.name",
 
         "skill_normal_attack.name",
        "skill_normal_attack.type",
         "skill_normal_attack.weapon",
        "skill_normal_attack.description",
         "skill_normal_attack.levels.*",
         "skill_normal_attack.levels.*",
         "skill_passive.name", "skill_passive.type",
 
         "skill_passive.trigger_type", "skill_passive.trigger_value",
         "skill_passive.name",
         "skill_passive.tags", "skill_passive.description",
        "skill_passive.type",
         "skill_passive.trigger_type",
        "skill_passive.trigger_value",
         "skill_passive.tags",
        "skill_passive.description",
         "skill_passive.levels.*",
         "skill_passive.levels.*",
         "skill_ultimate.name", "skill_ultimate.type",
 
         "skill_ultimate.desire_cost", "skill_ultimate.tags",
         "skill_ultimate.name",
         "skill_ultimate.description", "skill_ultimate.levels.*",
        "skill_ultimate.type",
         "skill_ultimate.desire_cost",
        "skill_ultimate.tags",
         "skill_ultimate.description",
        "skill_ultimate.levels.*",
 
         "feats.stages",
         "feats.stages",
        "stories.sort",
        "stories.story.text"
    }, ",")


     local encodedName = mw.uri.encode(name, "QUERY")
        -- 修复 stories
     local apiUrl = "https://data.saltedkiss.org/items/cards"
        "stories.*",
         .. "?fields=" .. mw.uri.encode(fields, "QUERY")
        "stories.story.*"
 
    },",")
 
 
     local encodedName = mw.uri.encode(name,"QUERY")
 
     local apiUrl =
        "https://data.saltedkiss.org/items/cards"
         .. "?fields=" .. mw.uri.encode(fields,"QUERY")
         .. "&filter[stylename][_eq]=" .. encodedName
         .. "&filter[stylename][_eq]=" .. encodedName
        .. "&_v=3"  -- 缓存破坏版本号,如遇缓存问题递增此数字
 


     local rawResponse = frame:preprocess(
     local rawResponse = frame:preprocess(
         '{{#get_web_data:url=' .. apiUrl
         '{{#get_web_data:url='..apiUrl
         .. '|format=text|data=responseText=__text}}'
         ..'|format=text|data=responseText=__text}}'
         .. '{{#external_value:responseText}}'
         ..'{{#external_value:responseText}}'
     )
     )
     rawResponse = mw.text.trim(rawResponse or "")
     rawResponse = mw.text.trim(rawResponse or "")


     local parsed = parseJson(rawResponse)
     local parsed = parseJson(rawResponse)
     local card   = parsed and type(parsed.data) == "table" and parsed.data[1] or nil
 
     local card =
        parsed
        and type(parsed.data) == "table"
        and parsed.data[1]
        or nil


     if not card then
     if not card then
         return '<span class="error">⚠ 无法加载卡片数据:' .. mw.text.nowiki(name)
         return '<span class="error">⚠ 无法加载卡片数据</span>'
            .. '(response=' .. mw.text.nowiki(rawResponse) .. ')</span>'
    end
 
    local charData  = card.character or {}
    local profData  = card.profession or {}
    local desireData = card.desire or {}
    local skillNA    = card.skill_normal_attack or {}
    local skillPA    = card.skill_passive or {}
    local skillUL    = card.skill_ultimate or {}
    local stories    = card.stories or {}
 
    local featsStagesJson = "[]"
    if card.feats and type(card.feats) == "table" and card.feats[1] then
        local sr = card.feats[1].stages
        featsStagesJson = type(sr) == "table" and mw.text.jsonEncode(sr)
                      or type(sr) == "string" and sr or "[]"
    end
 
    local function levelsToJson(skill)
        if not skill.levels then return "[]" end
        if type(skill.levels) == "string" then return skill.levels end
        if type(skill.levels) == "table"  then return mw.text.jsonEncode(skill.levels) end
        return "[]"
     end
     end
    skillNA.levels = levelsToJson(skillNA)
    skillPA.levels = levelsToJson(skillPA)
    skillUL.levels = levelsToJson(skillUL)


    local function tagsToJson(skill)
        if not skill.tags then return "[]" end
        if type(skill.tags) == "string" then return skill.tags end
        if type(skill.tags) == "table"  then return mw.text.jsonEncode(skill.tags) end
        return "[]"
    end
    skillPA.tags = tagsToJson(skillPA)
    skillUL.tags = tagsToJson(skillUL)


     local rarity    = tonumber(card.rarity) or 0
     local stories = card.stories or {}
    local stylename = val(card.stylename)
    local charName  = val(charData.name)
    local profName  = val(profData.name)
    local desName  = val(desireData.name)


     local root = mw.html.create("div")
     local root = mw.html.create("div")
         :addClass("ron-card ron-card--rarity-" .. rarity)
         :addClass("ron-card")
        :attr("data-rarity", rarity)


     root:tag("div"):addClass("card_fullscreen-img")
     local rightCol = root:tag("div")
    root:tag("div"):addClass("card_hero"):css("height", "100vh")
        :addClass("card_content_right")


    local layout = root:tag("div"):addClass("card_content-container")
        :tag("div"):addClass("card_content-background")
        :tag("div"):addClass("card_content-inner")
        :tag("div"):addClass("card_content card_content--layout")


     local leftCol = layout:tag("div"):addClass("card_content_left")
     local storySection = rightCol:tag("div")
    local nc = leftCol:tag("div"):addClass("card_content_name-container")
        :addClass("card_content_story")
    local nr = nc:tag("div"):addClass("card_content_name-row")
    nr:tag("div"):addClass("card_content_name-icon")
    nr:tag("div"):addClass("card_content_name-classtext"):wikitext(profName)
    nr:tag("div"):addClass("card_content_name-icon card_content_name-icon--ml")
    nr:tag("div"):addClass("card_content_name-classtext"):wikitext(desName)
    local nt = nc:tag("div"):addClass("card_content_name-text")
    nt:wikitext(stylename .. " ")
    nt:tag("span"):addClass("card_accent"):wikitext("·")
    nt:wikitext(" " .. charName)


     leftCol:node(makeTitle("信息", "Info"))
     local storyHeader = storySection:tag("div")
    leftCol:node(makeHr())
         :addClass("card_content_story-header")
    leftCol:tag("div"):addClass("card_content_info")
        :tag("div"):addClass("card_content_info-item")
        :tag("div"):wikitext("稀有度"):done()
         :tag("div"):wikitext(rarityStars(rarity))
    leftCol:node(makeTitle("等级 100", "Lv. Max"))
    leftCol:node(makeHr())
    leftCol:tag("div"):addClass("card_content_attribute-item"):wikitext("(数据待补充)")
    leftCol:node(makeTitle("映像", "Reflection"))
    leftCol:node(makeHr())
    leftCol:tag("div"):addClass("card_content_attribute-item"):wikitext("(数据待补充)")
    leftCol:node(makeTitle("认知", "Cognition"))
    leftCol:node(makeHr())
    leftCol:tag("div"):addClass("card_content_attribute-item"):wikitext("(数据待补充)")


     local rightCol = layout:tag("div"):addClass("card_content_right")
     local storyLeft = storyHeader:tag("div")
    rightCol:node(makeTitle("战斗技能", "Tactical"))
        :addClass("card_content_story-header-left")
    rightCol:node(makeHr("card_content-item-hr--mb12"))
    rightCol:node(makeSkillCard(skillNA, "normal_attack"))
    rightCol:tag("div"):addClass("card_content_skill-gap")
    rightCol:node(makeSkillCard(skillPA, "passive"))
    rightCol:tag("div"):addClass("card_content_skill-gap")
    rightCol:node(makeSkillCard(skillUL, "ultimate"))


     rightCol:node(makeTitle("觉醒", "Feat"))
     storyLeft:node(makeTitle("小传","Story"))
    rightCol:node(makeHr("card_content-item-hr--mb12"))
    rightCol:node(makeFeatList(featsStagesJson))


    local storySection = rightCol:tag("div"):addClass("card_content_story")
    local storyHeader  = storySection:tag("div"):addClass("card_content_story-header")
    local storyLeft    = storyHeader:tag("div"):addClass("card_content_story-header-left")
    storyLeft:node(makeTitle("小传", "Story"))
     storyLeft:node(makeHr("card_content-item-hr--mb12"))
     storyLeft:node(makeHr("card_content-item-hr--mb12"))
    storyLeft:tag("div"):addClass("card_content_story-toggle")
        :attr("data-collapsed", "false")
        :tag("span"):addClass("story-toggle-text"):wikitext("收起"):done()
        :tag("span"):addClass("story-toggle-icon"):wikitext("-")
    storyHeader:tag("div"):addClass("card_content_story-header-spacer")
    storyHeader:node(makeStoryTimeline(stories, stylename))


     rightCol:tag("div"):css("height", "12px"):css("width", "100%")
     storyHeader:node(
    rightCol:node(makeTitle("邀约", "Date"))
        makeStoryTimeline(stories,card.stylename)
     rightCol:node(makeHr("card_content-item-hr--mb12"))
     )
    rightCol:tag("div"):addClass("card_content_date")
 
        :tag("div"):addClass("card_content_date-track")
        :tag("ul"):addClass("card_content_date-list")
        :tag("li"):addClass("card_content_date-item"):wikitext("(邀约数据待补充)")


     return tostring(root)
     return tostring(root)
end
end


return p
return p

2026年3月11日 (三) 21:13的版本

此模块的文档可以在模块:CardData/doc创建

-- Module:CardData
-- 用法:{{#invoke:CardData|render|复仇童谣}}

local p = {}

local function val(v, fallback)
    if v == nil or v == "" then return fallback or "—" end
    return v
end

local function rarityStars(n)
    n = tonumber(n) or 0
    return string.rep("★", n)
end

local function parseJson(str)
    if not str or str == "" then return nil end
    local ok, result = pcall(mw.text.jsonDecode, str)
    if ok then return result else return nil end
end

local function makeTitle(titleText, subtitleText, extraClass)
    local div = mw.html.create("div")
        :addClass("card_content-item-title")
        :addClass("card_content-item-title--mt")

    if extraClass then div:addClass(extraClass) end

    div:wikitext(titleText)
    div:tag("span")
        :addClass("card_content-item-subtitle")
        :wikitext(subtitleText)

    return div
end

local function makeHr(extraClass)
    local div = mw.html.create("div")
        :addClass("card_content-item-hr")

    if extraClass then div:addClass(extraClass) end

    return div
end

local function makeStoryTimeline(stories, cardTitle)

    local timeline = mw.html.create("div")
        :addClass("card_timeline card_content_story-timeline")

    timeline:tag("div")
        :addClass("card_timeline-line")

    -- 更安全获取 entry
    local entry
    if type(stories) == "table" then
        for _,v in pairs(stories) do
            entry = v
            break
        end
    end

    local chapters = entry and entry.story or {}

    if not chapters or type(chapters) ~= "table" then
        chapters = {}
    end

    if next(chapters) == nil then
        timeline:tag("div")
            :addClass("card_timeline-item")
            :wikitext("(小传数据待补充)")
        return timeline
    end

    local romans = { "Ⅰ","Ⅱ","Ⅲ","Ⅳ","Ⅴ","Ⅵ","Ⅶ","Ⅷ" }
    local unlockLevels = {
        "Lv.20 解锁",
        "Lv.40 解锁",
        "Lv.60 解锁",
        "Lv.80 解锁",
        "Lv.100 解锁"
    }

    local idx = 1

    for _, chapter in pairs(chapters) do

        local item = timeline:tag("div")
            :addClass("card_timeline-item")

        item:tag("div")
            :addClass("card_timeline-dot")

        item:tag("div")
            :addClass("card_timeline-unlock")
            :wikitext(unlockLevels[idx] or ("Lv."..(idx*20).." 解锁"))

        local titleDiv = item:tag("div")
            :addClass("card_timeline-title")

        titleDiv:tag("span")
            :addClass("card_timeline-numeral")
            :wikitext(romans[idx] or idx)

        titleDiv:tag("span")
            :addClass("card_timeline-chapter")
            :wikitext(cardTitle or "")

        titleDiv:tag("span")
            :addClass("card_timeline-label")
            :wikitext("/ Story")

        local bodyDiv = item:tag("div")
            :addClass("card_timeline-body")

        local text = chapter.text or ""

        if text ~= "" then

            local lines = mw.text.split(text,"\n")

            for i,line in ipairs(lines) do

                if line ~= "" then
                    bodyDiv:wikitext(line)
                end

                if i < #lines then
                    bodyDiv:tag("br")
                end

            end

        end

        idx = idx + 1

    end

    return timeline
end


function p.render(frame)

    local name = mw.text.trim(frame.args[1] or frame.args.name or "")

    if name == "" then
        return '<span class="error">错误:请提供卡片名称</span>'
    end


    -- 关键:stories.story.*
    local fields = table.concat({

        "stylename",
        "rarity",

        "character.name",
        "profession.name",
        "desire.name",

        "skill_normal_attack.name",
        "skill_normal_attack.type",
        "skill_normal_attack.weapon",
        "skill_normal_attack.description",
        "skill_normal_attack.levels.*",

        "skill_passive.name",
        "skill_passive.type",
        "skill_passive.trigger_type",
        "skill_passive.trigger_value",
        "skill_passive.tags",
        "skill_passive.description",
        "skill_passive.levels.*",

        "skill_ultimate.name",
        "skill_ultimate.type",
        "skill_ultimate.desire_cost",
        "skill_ultimate.tags",
        "skill_ultimate.description",
        "skill_ultimate.levels.*",

        "feats.stages",

        -- 修复 stories
        "stories.*",
        "stories.story.*"

    },",")


    local encodedName = mw.uri.encode(name,"QUERY")

    local apiUrl =
        "https://data.saltedkiss.org/items/cards"
        .. "?fields=" .. mw.uri.encode(fields,"QUERY")
        .. "&filter[stylename][_eq]=" .. encodedName


    local rawResponse = frame:preprocess(
        '{{#get_web_data:url='..apiUrl
        ..'|format=text|data=responseText=__text}}'
        ..'{{#external_value:responseText}}'
    )

    rawResponse = mw.text.trim(rawResponse or "")

    local parsed = parseJson(rawResponse)

    local card =
        parsed
        and type(parsed.data) == "table"
        and parsed.data[1]
        or nil

    if not card then
        return '<span class="error">⚠ 无法加载卡片数据</span>'
    end


    local stories = card.stories or {}

    local root = mw.html.create("div")
        :addClass("ron-card")

    local rightCol = root:tag("div")
        :addClass("card_content_right")


    local storySection = rightCol:tag("div")
        :addClass("card_content_story")

    local storyHeader = storySection:tag("div")
        :addClass("card_content_story-header")

    local storyLeft = storyHeader:tag("div")
        :addClass("card_content_story-header-left")

    storyLeft:node(makeTitle("小传","Story"))

    storyLeft:node(makeHr("card_content-item-hr--mb12"))

    storyHeader:node(
        makeStoryTimeline(stories,card.stylename)
    )


    return tostring(root)

end

return p