Module:Partner Data:修订间差异
(创建页面,内容为“local getArgs = require('Module:Arguments').getArgs local p = {} function generateBydTable(step,frag,over) local fragStrA,stepStrA,overStrA="","","" local fragStr…”) |
小无编辑摘要 |
||
第39行: | 第39行: | ||
{ | { | ||
'!属性', | '!属性', | ||
'!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15 | '!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15', | ||
'|-', | '|-', | ||
'!Frag', | '!Frag', | ||
fragStrA, | fragStrA, | ||
'|-', | |||
'!Step', | '!Step', | ||
stepStrA, | stepStrA, | ||
'|-', | |||
'!Over', | '!Over', | ||
overStrA, | overStrA, | ||
'|-', | |||
'!属性', | '!属性', | ||
'!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15 | '!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15', | ||
'|-', | '|-', | ||
'!Frag', | '!Frag', | ||
fragStrB, | fragStrB, | ||
'|-', | |||
'!Step', | '!Step', | ||
stepStrB, | stepStrB, | ||
'|-', | |||
'!Over', | '!Over', | ||
overStrB | overStrB | ||
第94行: | 第99行: | ||
'!Frag', | '!Frag', | ||
fragStr, | fragStr, | ||
'|-', | |||
'!Step', | '!Step', | ||
stepStr, | stepStr, | ||
'|-', | |||
'!Over', | '!Over', | ||
overStr | overStr | ||
第110行: | 第117行: | ||
function calculationt(level1,level2,value1,value2,byd) | function calculationt(level1,level2,value1,value2,byd) | ||
local byd=true | local byd=true | ||
local | local list={ | ||
[1] = 0, | [1] = 0, | ||
[2] = 1, | [2] = 1, | ||
第133行: | 第140行: | ||
} | } | ||
local s1= | local s1=list[level1] | ||
local s2= | local s2=list[level2] | ||
local s3=(value2-value1)/(s2-s1) | local s3=(value2-value1)/(s2-s1) | ||
local s4=value1-s1*s3 | local s4=value1-s1*s3 | ||
第143行: | 第150行: | ||
if i<=20 | if i<=20 | ||
then | then | ||
result[i]=s4+s3* | result[i]=s4+s3*list[i] | ||
else | else | ||
result[i]=result[20]+i-20 | result[i]=result[20]+i-20 | ||
第158行: | 第165行: | ||
if args.byd then byd=true end | if args.byd then byd=true end | ||
local step=calculationt(args | local step=calculationt(tonumber(args["stepLevel1"]),tonumber(args["stepLevel2"]),args["stepValue1"],args["stepValue2"],byd) | ||
local frag=calculationt(args | local frag=calculationt(tonumber(args["fragLevel1"]),tonumber(args["fragLevel2"]),args["fragValue1"],args["fragValue2"],byd) | ||
local over=calculationt(args | local over=calculationt(tonumber(args["overLevel1"]),tonumber(args["overLevel2"]),args["overValue1"],args["overValue2"],byd) | ||
if byd then return generateBydTable(step,frag,over) else return generateNormalTable(step,frag,over) end | if byd then return generateBydTable(step,frag,over) else return generateNormalTable(step,frag,over) end |
2021年4月18日 (日) 18:15的版本
该模块用于计算搭档条目中的搭档分级数据,为模板:Partner Data提供支持。
local getArgs = require('Module:Arguments').getArgs
local p = {}
function generateBydTable(step,frag,over)
local fragStrA,stepStrA,overStrA="","",""
local fragStrB,stepStrB,overStrB="","",""
for i=1,15 do
if i==1 then
fragStrA=fragStrA.."|"..string.format("%0.0f",frag[i])
stepStrA=stepStrA.."|"..string.format("%0.0f",step[i])
overStrA=overStrA.."|"..string.format("%0.0f",over[i])
else
fragStrA=fragStrA.."||"..string.format("%0.0f",frag[i])
stepStrA=stepStrA.."||"..string.format("%0.0f",step[i])
overStrA=overStrA.."||"..string.format("%0.0f",over[i])
end
end
for i=16,30 do
if i==1 then
fragStrB=fragStrB.."|"..string.format("%0.0f",frag[i])
stepStrB=stepStrB.."|"..string.format("%0.0f",step[i])
overStrB=overStrB.."|"..string.format("%0.0f",over[i])
else
fragStrB=fragStrB.."||"..string.format("%0.0f",frag[i])
stepStrB=stepStrB.."||"..string.format("%0.0f",step[i])
overStrB=overStrB.."||"..string.format("%0.0f",over[i])
end
end
local body = {
'{| class="wikitable" border="1" cellspacing="1" cellpadding="5" style="text-align:center"'
}
table.insert(
body,
table.concat(
{
'!属性',
'!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15',
'|-',
'!Frag',
fragStrA,
'|-',
'!Step',
stepStrA,
'|-',
'!Over',
overStrA,
'|-',
'!属性',
'!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15',
'|-',
'!Frag',
fragStrB,
'|-',
'!Step',
stepStrB,
'|-',
'!Over',
overStrB
},
'\n'
)
)
table.insert(body, '|}')
return table.concat(body, '\n')
end
function generateNormalTable(step,frag,over)
local fragStr,stepStr,overStr="","",""
for i=1,20 do
if i==1 then
fragStr=fragStr.."|"..string.format("%0.0f",frag[i])
stepStr=stepStr.."|"..string.format("%0.0f",step[i])
overStr=overStr.."|"..string.format("%0.0f",over[i])
else
fragStr=fragStr.."||"..string.format("%0.0f",frag[i])
stepStr=stepStr.."||"..string.format("%0.0f",step[i])
overStr=overStr.."||"..string.format("%0.0f",over[i])
end
end
local body = {
'{| class="wikitable" border="1" cellspacing="1" cellpadding="5" style="text-align:center"'
}
table.insert(
body,
table.concat(
{
'!属性',
'!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15!!16!!17!!18!!19!!20',
'|-',
'!Frag',
fragStr,
'|-',
'!Step',
stepStr,
'|-',
'!Over',
overStr
},
'\n'
)
)
table.insert(body, '|}')
return table.concat(body, '\n')
end
function calculationt(level1,level2,value1,value2,byd)
local byd=true
local list={
[1] = 0,
[2] = 1,
[3] = 8,
[4] = 27,
[5] = 64,
[6] = 125,
[7] = 216,
[8] = 343,
[9] = 512,
[10] = 729,
[11] = 985.75,
[12] = 1202.75,
[13] = 1371.75,
[14] = 1498.75,
[15] = 1589.75,
[16] = 1650.75,
[17] = 1687.75,
[18] = 1706.75,
[19] = 1713.75,
[20] = 1714.75,
}
local s1=list[level1]
local s2=list[level2]
local s3=(value2-value1)/(s2-s1)
local s4=value1-s1*s3
local result={}
local long=20
if byd then long=30 end
for i=1,long do
if i<=20
then
result[i]=s4+s3*list[i]
else
result[i]=result[20]+i-20
end
end
return result
end
function p.main(frame)
local args = getArgs(frame)
local byd=false
if args.byd then byd=true end
local step=calculationt(tonumber(args["stepLevel1"]),tonumber(args["stepLevel2"]),args["stepValue1"],args["stepValue2"],byd)
local frag=calculationt(tonumber(args["fragLevel1"]),tonumber(args["fragLevel2"]),args["fragValue1"],args["fragValue2"],byd)
local over=calculationt(tonumber(args["overLevel1"]),tonumber(args["overLevel2"]),args["overValue1"],args["overValue2"],byd)
if byd then return generateBydTable(step,frag,over) else return generateNormalTable(step,frag,over) end
end
return p