Module:Partner Data:修订间差异
(创建页面,内容为“local getArgs = require('Module:Arguments').getArgs local p = {} function generateBydTable(step,frag,over) local fragStrA,stepStrA,overStrA="","","" local fragStr…”) |
(没有差异)
|
2021年4月18日 (日) 17:30的版本
该模块用于计算搭档条目中的搭档分级数据,为模板: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!!16!!17!!18!!19!!20',
'|-',
'!Frag',
fragStrA,
'!Step',
stepStrA,
'!Over',
overStrA,
'!属性',
'!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15!!16!!17!!18!!19!!20',
'|-',
'!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 c={
[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=c[level1]
local s2=c[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*c[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(args.stepLevel1,args.stepLevel2,args.stepValue1,args.stepValue2,args.byd)
local frag=calculationt(args.fragLevel1,args.fragLevel2,args.fragValue1,args.fragValue2,args.byd)
local over=calculationt(args.overLevel1,args.overLevel2,args.overValue1,args.overValue2,args.byd)
if byd then return generateBydTable(step,frag,over) else return generateNormalTable(step,frag,over) end
end
return p