local getArgs = require('Module:Arguments').getArgs
local p = {}
local rangeMap = {--------新项目和别名在这里添加--------
["3x3"] = "3,3", ["九宫"] = "3,3", ["九宫格"] = "3,3", ["around_1"] = "3,3",
["5x5"] = "5,5", ["around_2"] = "5,5",
["+"] = "1,3", ["十字"] = "1,3", ["十字格"] = "1,3", ["cross_1"] = "1,3",
["++"] = "4,4", ["大十字"] = "4,4", ["大十字格"] = "4,4", ["cross_2"] = "4,4",
["0"] = "5,4", ["菱形"] = "5,4", ["菱形格"] = "5,4", ["diamond_2"] = "5,4",
["0+"] = "6,5", ["大菱形格"] = "6,5", ["diamond_3"] = "6,5",
["X"] = "2,2", ["斜十字格"] = "2,2", ["inclinedcross"] = "2,2",
["inverseTriangle_2"] = "4,5",
["前方两列"] = "3,2", ["2l"] = "3,2", ["multirowadvance_1_1"] = "3,2",
["前方三列"] = "2,3", ["3l"] = "2,3", ["multirowadvance_2_1"] = "2,3",
["前方四列"] = "4,3", ["4l"] = "4,3", ["异能"] = "4,3", ["multirowadvance_3_1"] = "4,3",
["前方五列"] = "5,3", ["5l"] = "5,3", ["multirowadvance_4_1"] = "5,3",
["前方六列"] = "6,3", ["6l"] = "6,3", ["精准"] = "6,3", ["multirowadvance_5_1"] = "6,3",
["原地"] = "1,1", ["自身格"] = "1,1", ["单格"] = "1,1", ["+0"] = "1,1", ["1"] = "1,1", ["1x1"] = "1,1", ["original"] = "1,1",
["*12"] = "9,5", ["random_12"] = "9,5",
["*2"] = "10,2", ["random_2"] = "10,2",
["*3"] = "10,3", ["random_3"] = "10,3",
["*4"] = "10,4", ["random_4"] = "10,4",
["*5"] = "10,5", ["random_5"] = "10,5",
["*6"] = "9,1", ["random_6"] = "9,1",
["*7"] = "9,2", ["random_7"] = "9,2",
["*8"] = "9,3", ["random_8"] = "9,3",
["长方形"] = "3,4", ["rect_0_0_0_1"] = "3,4",
["单列三格"] = "1,2", ["上下三格"] = "1,2", ["l"] = "1,2", ["singlecol_1"] = "1,2",
["单列五格"] = "4,2", ["上下五格"] = "4,2", ["l+"] = "4,2", ["singlecol_2"] = "4,2",
["身前一格"] = "2,1", ["前方两格"] = "2,1", ["+1"] = "2,1", ["2"] = "2,1", ["singlerowadvance_1"] = "2,1",
["身前两格"] = "3,1", ["前方三格"] = "3,1", ["+2"] = "3,1", ["3"] = "3,1", ["singlerowadvance_2"] = "3,1",
["前方四格"] = "4,1", ["身前三格"] = "4,1", ["+3"] = "4,1", ["4"] = "4,1", ["singlerowadvance_3"] = "4,1",
["身前四格"] = "5,1", ["前方五格"] = "5,1", ["+4"] = "5,1", ["5"] = "5,1", ["singlerowadvance_4"] = "5,1",
["身前五格"] = "6,1", ["前方六格"] = "6,1", ["+5"] = "6,1", ["6"] = "6,1", ["singlerowadvance_5"] = "6,1",
["单行三格"] = "1,4", ["前后三格"] = "1,4", ["-"] = "1,4", ["singlerow_1"] = "1,4",
["单行五格"] = "1,5", ["前后五格"] = "1,5", ["-+"] = "1,5", ["singlerow_2"] = "1,5",
["特殊1"] = "2,5", ["special_1"] = "2,5",
["目标九宫格"] = "8,2", ["*3x3"] = "8,2", ["target_around_1"] = "8,2",
["目标十字格"] = "8,3", ["*+"] = "8,3", ["target_cross_1"] = "8,3",
["*++"] = "7,3", ["target_cross_2"] = "7,3",
["*0"] = "7,4", ["目标菱形格"] = "7,4", ["target_diamond_1"] = "7,4",
["*2l"] = "8,4", ["target_multirowadvance_1_1"] = "8,4",
["*"] = "10,1", ["*1"] = "10,1", ["目标单格"] = "10,1", ["target_original"] = "10,1",
["*l"] = "7,1", ["*1l"] = "7,1", ["target_singlecol_1"] = "7,1",
["*l+"] = "7,2", ["target_singlecol_2"] = "7,2",
["*-+"] = "8,1", ["目标一字格"] = "8,1", ["target_singlerow_1"] = "8,1",
["triangle_1"] = "2,4",
["triangle_2"] = "3,5",
}
local function getXY(str)
local x, y = str:match("^(%d+),(%d+)$")
return tonumber(x), tonumber(y)
end
function p.main(frame)
local args = getArgs(frame)
local out = {}
local text = args[1] or ''
local custom = args[2] or ''
local image = args['image'] or ''
local width = args['width'] or '60px'
local range = rangeMap[text]
table.insert(out, '<div ' .. (custom ~= '' and custom or 'style="position:relative;border:1px solid #cde;display:flex;justify-content:center;height:80px;align-items:center;margin:.5em auto;width:20em;min-width:60%;"><div style="color:#cde;font-size:small;line-height:1;position:absolute;top:.5em;left:.5em;">技能范围</div') .. '>')
if image ~= '' then
table.insert(out, '[[File:' .. image .. '|' .. width .. ']]')
else
if range then
local x, y = getXY(range)
local image_x = 56 * x - 56
local image_y = 56 * y - 56
table.insert(out, frame:expandTemplate{
title = 'image-clip',
args = {
img = 'Wqmt-sprite-skillrange.png', width = '560',
wd = '56', ht = '56', x = image_x, y = image_y,
img_css = frame:expandTemplate { title = '像素图' }
}
})
else
table.insert(out, '<strong class="error">无法识别的技能范围,请参考[[Template:无期迷途技能范围|模板说明]]!</strong>' .. frame:expandTemplate{ title = 'ac', args = { '无期迷途:需要检查的条目' } })
end
end
table.insert(out, '</div>')
return table.concat(out)
end
return p