“模块:Jobs”的版本间的差异
来自小鱼君和他的朋友们
([InPageEdit] 没有编辑摘要) |
([InPageEdit] 没有编辑摘要) |
||
第2行: | 第2行: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
− | local | + | local alias = { |
['弓箭手'] = 'archer', | ['弓箭手'] = 'archer', | ||
['archer'] = 'archer', | ['archer'] = 'archer', | ||
第23行: | 第23行: | ||
} | } | ||
− | function | + | function jobCode(frame) |
local args = getArgs(frame) | local args = getArgs(frame) | ||
− | local | + | local job = args['job'] or args[1] or 'unknown' |
− | + | job = mw.ustring.lower(job) | |
− | return | + | return alias[job] or 'unknown' |
+ | end | ||
+ | |||
+ | function p.jobColor(frame) | ||
+ | local job = jobCode(frame) | ||
+ | return jobDetail[job]['color'] | ||
end | end | ||
function p.main(frame) | function p.main(frame) | ||
− | local job = | + | local job = jobCode(frame) |
return jobDetail[job]['name'] .. p.jobColor(frame) | return jobDetail[job]['name'] .. p.jobColor(frame) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
return p | return p |
2020年4月2日 (四) 11:30的版本
弓箭手red 弓箭手red
未知职业unknown 未知职业unknown
未知职业unknown 未知职业unknown
未知职业unknown
Module:Jobs/alias (编辑) • Module:Jobs/colorInfo (编辑) • Module:Jobs/details (编辑) • Module:Jobs/levels (编辑)
local p = {} local getArgs = require('Module:Arguments').getArgs local alias = { ['弓箭手'] = 'archer', ['archer'] = 'archer', ['arc'] = 'archer' } local jobDetail = { ['unknown'] = { ['name'] = '未知职业', ['color'] = 'unknown', ['prop'] = '', ['level'] = 'n' }, ['archer'] = { ['name'] = '弓箭手', ['color'] = 'red', ['prop'] = '远程物理', ['level'] = 'n' } } 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 function p.jobColor(frame) local job = jobCode(frame) return jobDetail[job]['color'] end function p.main(frame) local job = jobCode(frame) return jobDetail[job]['name'] .. p.jobColor(frame) end return p