欢迎来到东方归言录wiki!这里是为东方归言录玩家们提供帮助的wiki。

现在新的攻略组正在慢慢建设wiki,如果有心帮忙的话也可以为东方归言录wiki添砖加瓦提供支持,感谢你的帮助和支持。

特别注意:本站为东方归言录(国服)的wiki站,信息和讨论仅限于国服范畴。对日服与国际服仅有参考作用,具体详情还请参阅各自对应的wiki站点。

全站通知:

模板:属性弹种查询

来自东方归言录WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索
Template-info.png 模板文档  [查看] [编辑] [历史] [刷新]

-- Module:角色定位筛选


local p = {}


-- 工具函数:安全获取参数(去除空白)


local function getArg(frame, key)

   local val = frame.args[key]
   if val then
       val = mw.text.trim(val)
       return (val ~= ) and val or nil
   end
   return nil

end


-- 主查询函数


function p.查询角色数据(frame)

   local args = frame.args
   local selected_rarity = getArg(frame, '检索用稀有度')
   local selected_style = getArg(frame, '式')
   local selected_attr = getArg(frame, '检索用弹幕属性')
   local selected_link = getArg(frame, '连携名称')
   local selected_final_attr = getArg(frame, '终符1属性')
   local selected_danzhong = getArg(frame, '终符1弹种')  -- 关键:终符主弹种

-- 获取所有角色页面(假设分类为"人物")


   local pages = mw.site.getCategoryMembers('人物', { limit = 5000 })
   local results = {}
   for _, page in ipairs(pages) do
       if page.exists then
           local title = page.title
           local content = page:getContent()
           if not content then goto continue end
           

-- 解析SMW属性(简易方式:用mw.text.split或正则)


           local props = {}
           for prop, val in content:gmatch('%[%[([^%[%]:]+)::([^%[%]]+)%]%]') do
               props[prop] = val
           end
           -- 条件1:稀有度
           if selected_rarity and props['检索用稀有度'] ~= selected_rarity then goto continue end
           -- 条件2:式
           if selected_style and props['式'] ~= selected_style then goto continue end
           -- 条件3:属性
           if selected_attr and props['检索用弹幕属性'] ~= selected_attr then goto continue end
           -- 条件4:连携
           if selected_link and props['连携名称'] ~= selected_link then goto continue end
           -- 条件5:终符主属性
           if selected_final_attr and props['终符1属性'] ~= selected_final_attr then goto continue end
           -- 条件6:终符弹种(1~6任意匹配)
           if selected_danzhong then
               local match = false
               for i = 1, 6 do
                   local key = '终符' .. i .. '弹种'
                   if props[key] == selected_danzhong then
                       match = true
                       break
                   end
               end
               if not match then goto continue end
           end
           -- 所有条件通过,加入结果
           table.insert(results, {
               name = title,
               danzhong_attr = props['弹幕属性'] or '?',
               hp = props['生命'] or '?',
               speed = props['速度'] or '?',
               yang_atk = props['阳攻'] or '?',
               yin_atk = props['阴攻'] or '?',
               yang_def = props['阳防'] or '?',
               yin_def = props['阴防'] or '?',
               id = props['人物编号'] or '?'
           })
       end
       ::continue::
   end
   -- 排序:按稀有度 desc, 人物编号 desc
   table.sort(results, function(a, b)
       -- 假设稀有度已存于props,此处简化:用人物编号代替排序
       return a.id > b.id
   end)
   -- 生成表格行
   local output = {}
   for _, ship in ipairs(results) do
       table.insert(output, string.format([=[

|- |%s |%s |%s |%s |%s |%s |%s |%s |%s ]=],

           ship.id,
           ship.danzhong_attr,
           ship.hp,
           ship.speed,
           ship.yang_atk,
           ship.yin_atk,
           ship.yang_def,
           ship.yin_def
       ))
   end
   return table.concat(output)

end

return p