Module:Partner Data:修订间差异
(创建页面,内容为“local getArgs = require('Module:Arguments').getArgs local p = {} function generateBydTable(step,frag,over) local fragStrA,stepStrA,overStrA="","","" local fragStr…”) |
标签:撤销 |
||
(未显示同一用户的8个中间版本) | |||
第2行: | 第2行: | ||
local p = {} | local p = {} | ||
function | function generateAwakenTable(step,frag,over) | ||
local fragStrA,stepStrA,overStrA="","","" | local fragStrA,stepStrA,overStrA="","","" | ||
local fragStrB,stepStrB,overStrB="","","" | local fragStrB,stepStrB,overStrB="","","" | ||
第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, | ||
'|-', | |||
'!属性', | '!属性', | ||
'! | '!16!!17!!18!!19!!20!!21!!22!!23!!24!!25!!26!!27!!28!!29!!30', | ||
'|-', | '|-', | ||
'!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 | ||
第108行: | 第115行: | ||
end | end | ||
function calculationt(level1,level2,value1,value2, | function calculationt(level1,level2,value1,value2,awaken) | ||
local | local awaken=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 | ||
local result={} | local result={} | ||
local long=20 | local long=20 | ||
if | if awaken then long=30 end | ||
for i=1,long do | for i=1,long do | ||
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 | ||
第155行: | 第162行: | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local | local awaken=false | ||
if args. | if args.awaken then awaken=true end | ||
local step=calculationt(args | local step=calculationt(tonumber(args["stepLevel1"]),tonumber(args["stepLevel2"]),args["stepValue1"],args["stepValue2"],awaken) | ||
local frag=calculationt(args | local frag=calculationt(tonumber(args["fragLevel1"]),tonumber(args["fragLevel2"]),args["fragValue1"],args["fragValue2"],awaken) | ||
local over=calculationt(args | local over=calculationt(tonumber(args["overLevel1"]),tonumber(args["overLevel2"]),args["overValue1"],args["overValue2"],awaken) | ||
if | if awaken then return generateAwakenTable(step,frag,over) else return generateNormalTable(step,frag,over) end | ||
end | end | ||
return p | return p |
2021年9月25日 (六) 12:00的最新版本
该模块用于计算搭档条目中的搭档分级数据,为模板: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.."|"..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,
'|-',
'!属性',
'!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.."|"..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,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