模块:Db:修订间差异
MJ Hamster(留言 | 贡献) 小无编辑摘要 |
MJ Hamster(留言 | 贡献) 小无编辑摘要 |
||
| 第100行: | 第100行: | ||
end | end | ||
-- | -- 获取难度模式 (使用哈希表检查,使用 sub 提取模式) | ||
local function getDifficultyMode(field) | local function getDifficultyMode(field) | ||
local checkField = field and string.lower(mw.text.trim(field)) or '' | local checkField = field and string.lower(mw.text.trim(field)) or '' | ||
-- | |||
local | -- 哈希表包含所有需要套用 {{df|}} 模板的精准字段 | ||
local difficultyFields = { | |||
['4b_nm'] = true, ['4b_hd'] = true, ['4b_mx'] = true, ['4b_sc'] = true, | |||
['5b_nm'] = true, ['5b_hd'] = true, ['5b_mx'] = true, ['5b_sc'] = true, | |||
['6b_nm'] = true, ['6b_hd'] = true, ['6b_mx'] = true, ['6b_sc'] = true, | |||
['8b_nm'] = true, ['8b_hd'] = true, ['8b_mx'] = true, ['8b_sc'] = true, | |||
} | |||
if difficultyFields[checkField] == true then | |||
-- 匹配成功,安全提取模式 (最后两个字符: 'nm', 'hd', 'mx', or 'sc') | |||
return checkField:sub(-2) | |||
end | |||
return nil | |||
end | end | ||
| 第161行: | 第173行: | ||
local formattedValue = formatSingleValue(value, argType) | local formattedValue = formatSingleValue(value, argType) | ||
-- | -- 应用 {{df|}} 模板和 SC 前缀逻辑 | ||
local mode = getDifficultyMode(argType) | local mode = getDifficultyMode(argType) | ||
if mode then | if mode then | ||
| 第281行: | 第293行: | ||
local formattedValue = formatSingleValue(rawValue, field) | local formattedValue = formatSingleValue(rawValue, field) | ||
-- | -- 应用 {{df|}} 模板和 SC 前缀逻辑 | ||
local mode = getDifficultyMode(field) | local mode = getDifficultyMode(field) | ||
if mode then | if mode then | ||
| 第291行: | 第303行: | ||
end | end | ||
-- FIX: | -- FIX: 移除表格单元格分隔符后的空格以避免解析错误 | ||
table.insert(output, '|' .. formattedValue) | table.insert(output, '|' .. formattedValue) | ||
end | end | ||