更多操作
无编辑摘要 |
无编辑摘要 |
||
第6行: | 第6行: | ||
Arcade = '街机', | Arcade = '街机', | ||
Adventure = '冒险', | Adventure = '冒险', | ||
['Hack and slash/Beat | ['Hack and slash/Beat 'em up'] = '清版动作', | ||
Shooter = '射击', | Shooter = '射击', | ||
Simulator = '模拟', | Simulator = '模拟', |
2025年3月26日 (三) 15:32的版本
此模块的文档可以在模块:GetGenres/doc创建
local getArgs = require('Module:Arguments').getArgs
local p = {}
local types = {
Arcade = '街机',
Adventure = '冒险',
['Hack and slash/Beat 'em up'] = '清版动作',
Shooter = '射击',
Simulator = '模拟',
Strategy = '策略',
Indie = '独立',
Platform = '平台',
Puzzle = '解谜',
Racing = '竞速',
['Real Time Strategy (RTS)'] = '即时战略',
['Role-playing (RPG)'] = '角色扮演',
Sport = '运动',
['Turn-based strategy (TBS)'] = '回合制策略'
}
function p.replace(str, target, result)
local res = str:gsub(target, result)
return res
end
function p.isKeyInTable(keyToCheck)
for key in pairs(types) do
if key == keyToCheck then
mw.log(key)
return true
end
end
return false
end
function p.split(str, separator)
local fields = {}
local temp = str:gsub(", ", ",")
temp:gsub("[^"..separator.."]+", function(c) fields[#fields + 1] = c end)
return fields
end
function p.exec(str)
local arr = p.split(str, ",")
local ret = ""
for key, value in pairs(arr) do
if p.isKeyInTable(value) then
ret = ret.."[[:分类:类型/"..types[value].."|"..types[value].."]][[分类:类型/"..types[value].."]] "
else
ret = ret..value.."[[分类:类型/缺少类型]] "
end
end
mw.logObject(ret)
return ret
end
function p.getGenres(frame)
local args = getArgs(frame)
return p.exec(args[1])
end
return p