Module:Partner Data:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
第8行: | 第8行: | ||
for i=1,15 do | for i=1,15 do | ||
if i==1 then | if i==1 then | ||
fragStrA=fragStrA.."|".. | fragStrA=fragStrA.."|"..math.modf(frag[i]) | ||
stepStrA=stepStrA.."|".. | stepStrA=stepStrA.."|"..math.modf(step[i]) | ||
overStrA=overStrA.."|".. | overStrA=overStrA.."|"..math.modf(over[i]) | ||
else | else | ||
fragStrA=fragStrA.."||".. | fragStrA=fragStrA.."||"..math.modf(frag[i]) | ||
stepStrA=stepStrA.."||".. | stepStrA=stepStrA.."||"..math.modf(step[i]) | ||
overStrA=overStrA.."||".. | overStrA=overStrA.."||"..math.modf(over[i]) | ||
end | end | ||
end | end | ||
第20行: | 第20行: | ||
for i=16,30 do | for i=16,30 do | ||
if i==1 then | if i==1 then | ||
fragStrB=fragStrB.."|".. | fragStrB=fragStrB.."|"..math.modf(frag[i]) | ||
stepStrB=stepStrB.."|".. | stepStrB=stepStrB.."|"..math.modf(step[i]) | ||
overStrB=overStrB.."|".. | overStrB=overStrB.."|"..math.modf(over[i]) | ||
else | else | ||
fragStrB=fragStrB.."||".. | fragStrB=fragStrB.."||"..math.modf(frag[i]) | ||
stepStrB=stepStrB.."||".. | stepStrB=stepStrB.."||"..math.modf(step[i]) | ||
overStrB=overStrB.."||".. | overStrB=overStrB.."||"..math.modf(over[i]) | ||
end | end | ||
end | end | ||
第76行: | 第76行: | ||
for i=1,20 do | for i=1,20 do | ||
if i==1 then | if i==1 then | ||
fragStr=fragStr.."|".. | fragStr=fragStr.."|"..math.modf(frag[i]) | ||
stepStr=stepStr.."|".. | stepStr=stepStr.."|"..math.modf(step[i]) | ||
overStr=overStr.."|".. | overStr=overStr.."|"..math.modf(over[i]) | ||
else | else | ||
fragStr=fragStr.."||".. | fragStr=fragStr.."||"..math.modf(frag[i]) | ||
stepStr=stepStr.."||".. | stepStr=stepStr.."||"..math.modf(step[i]) | ||
overStr=overStr.."||".. | overStr=overStr.."||"..math.modf(over[i]) | ||
end | end | ||
end | end |
2021年4月18日 (日) 22:04的版本
该模块用于计算搭档条目中的搭档分级数据,为模板:Partner Data提供支持。
local getArgs = require('Module:Arguments').getArgs
local p = {}
function generateAwakenTable(step,frag,over)
local fragStrA,stepStrA,overStrA="","",""
local fragStrB,stepStrB,overStrB="","",""
for i=1,15 do
if i==1 then
fragStrA=fragStrA.."|"..math.modf(frag[i])
stepStrA=stepStrA.."|"..math.modf(step[i])
overStrA=overStrA.."|"..math.modf(over[i])
else
fragStrA=fragStrA.."||"..math.modf(frag[i])
stepStrA=stepStrA.."||"..math.modf(step[i])
overStrA=overStrA.."||"..math.modf(over[i])
end
end
for i=16,30 do
if i==1 then
fragStrB=fragStrB.."|"..math.modf(frag[i])
stepStrB=stepStrB.."|"..math.modf(step[i])
overStrB=overStrB.."|"..math.modf(over[i])
else
fragStrB=fragStrB.."||"..math.modf(frag[i])
stepStrB=stepStrB.."||"..math.modf(step[i])
overStrB=overStrB.."||"..math.modf(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,
'|-',
'!属性',
'!16!!17!!18!!19!!20!!21!!22!!23!!24!!25!!26!!27!!28!!29!!30',
'|-',
'!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.."|"..math.modf(frag[i])
stepStr=stepStr.."|"..math.modf(step[i])
overStr=overStr.."|"..math.modf(over[i])
else
fragStr=fragStr.."||"..math.modf(frag[i])
stepStr=stepStr.."||"..math.modf(step[i])
overStr=overStr.."||"..math.modf(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,awaken)
local awaken=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 awaken 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 awaken=false
if args.awaken then awaken=true end
local step=calculationt(tonumber(args["stepLevel1"]),tonumber(args["stepLevel2"]),args["stepValue1"],args["stepValue2"],awaken)
local frag=calculationt(tonumber(args["fragLevel1"]),tonumber(args["fragLevel2"]),args["fragValue1"],args["fragValue2"],awaken)
local over=calculationt(tonumber(args["overLevel1"]),tonumber(args["overLevel2"]),args["overValue1"],args["overValue2"],awaken)
if awaken then return generateawakenTable(step,frag,over) else return generateNormalTable(step,frag,over) end
end
return p