“模块:Jobs”的版本间的差异
来自小鱼君和他的朋友们
([InPageEdit] 没有编辑摘要) |
|||
第57行: | 第57行: | ||
local code = jobCode(frame) | local code = jobCode(frame) | ||
local icon = p.jobColor(frame) | local icon = p.jobColor(frame) | ||
− | local level = jobDetail[ | + | local level = jobDetail[code]['level'] or '' |
− | local name = jobDetail[ | + | local name = jobDetail[code]['name'] |
− | local en = jobDetail[ | + | local en = jobDetail[code]['en'] or '' |
− | local prop = jobDetail[ | + | local prop = jobDetail[code]['prop'] or '' |
return icon .. level .. name .. en .. ' (' .. prop .. ')' | return icon .. level .. name .. en .. ' (' .. prop .. ')' | ||
end | end | ||
return p | return p |
2020年4月2日 (四) 18:41的版本
rednor弓箭手Archer (远程物理) rednor弓箭手Archer (远程物理)
redadv游吟诗人Bard (远程物理) redadv游吟诗人Bard (远程物理)
unknownnor未知职业Unknown () unknownnor未知职业Unknown ()
unknownnor未知职业Unknown ()
Module:Jobs/alias (编辑) • Module:Jobs/colorInfo (编辑) • Module:Jobs/details (编辑) • Module:Jobs/levels (编辑)
local p = {} local getArgs = require('Module:Arguments').getArgs -- 职业名称标准化 local alias = {} function setAlias(array,code) for i,name in ipairs(array) do alias[array[i]] = code end end function jobCode(frame) local args = getArgs(frame) local job = args['job'] or args[1] or 'unknown' job = mw.ustring.lower(job) return alias[job] or 'unknown' end -- 职业别名 setAlias({'弓箭手', 'archer', 'arc'}, 'archer') setAlias({'吟游诗人', '诗人', 'bard', 'brd'}, 'bard') -- 职业具体参数 local jobDetail = { ['unknown'] = { ['name'] = '未知职业', --中文名 ['en'] = 'Unknown', --英文名 ['short'] = 'null', --简称 ['color'] = 'unknown', --red/green/blue/yellow/purple ['prop'] = '', --战斗职业的类型 ['level'] = 'nor' --nor/adv/spe }, ['archer'] = { ['name'] = '弓箭手', ['en'] = 'Archer', ['short'] = 'arc', ['color'] = 'red', ['prop'] = '远程物理', ['level'] = 'nor' }, ['bard'] = { ['name'] = '游吟诗人', ['en'] = 'Bard', ['short'] = 'brd', ['color'] = 'red', ['prop'] = '远程物理', ['level'] = 'adv' } } -- 职业色谱 function p.jobColor(frame) local job = jobCode(frame) return jobDetail[job]['color'] end -- 返回最完整的格式 function p.main(frame) local code = jobCode(frame) local icon = p.jobColor(frame) local level = jobDetail[code]['level'] or '' local name = jobDetail[code]['name'] local en = jobDetail[code]['en'] or '' local prop = jobDetail[code]['prop'] or '' return icon .. level .. name .. en .. ' (' .. prop .. ')' end return p