调用ask函数,并生成分类汇总表格。
参数:
参数名 |
默认值 |
值域 |
描述 |
使用例
|
1 |
情报编号 |
—— |
ask函数的查找项(askitem),必填 |
情报编号
|
2 |
—— |
以逗号分隔的字符串 |
预设类。使用此参数时,将优先以预设类进行分类。类之间用逗号相隔 |
R,A,PA
|
askcondition |
[[askitem::+]] |
—— |
ask函数的查找条件 |
askcondition=[[分类:干员]]
|
replacenumber |
yes |
yes/no |
将查找项的数字删除,以便分类。相当于replaceitem=%d |
replacenumber=no
|
replaceitem |
—— |
以逗号分隔的字符串 |
将查找项的指定目标删除,以便分类。支持lua的字符串模式匹配语法。目标之间用逗号相隔 |
replaceitem=<.->
|
comparemode |
strict |
strict/loose |
分类比较模式。使用strict时,要求类名与查找项完全相同。使用loose时,要求类名包含查找项或查找项包含类名。 |
comparemode=loose
|
row |
8 |
整数 |
表格的列数 |
row=6
|
sortclass |
no |
yes/no |
对类按照查询结果从小到大进行排序 |
sortclass=yes
|
matchpattern |
no |
yes/no |
模式匹配。在comparemode=loose的情况下,对类名中含有matchpattern_tag的类分类时进行模式匹配。支持lua的字符串模式匹配语法 |
matchpattern=yes
|
matchpattern_tag |
模式匹配 |
—— |
模式匹配标记。见参数“matchpattern” |
matchpattern_tag=
|
hideempty |
no |
yes/no |
隐藏空类。将隐藏查询结果为0的类 |
hideempty=yes
|
displaytarget |
对象 |
—— |
表格中显示的对象名 |
displaytarget=干员
|
displayclass |
类 |
—— |
表格中显示的类名 |
displaytarget=种
|
用法:
{{#invoke:AskSubtotal|get|情报编号|sortclass=yes}}
情报编号(396对象-53类)
|
AZ(1) |
BW(1) |
DWDB(1) |
HT(1) |
REX(1) |
RR(1) |
RV(1) |
SK(1)
|
|
|
|
|
|
|
|
|
U(1) |
AE(2) |
CR(2) |
L(2) |
US(2) |
FO(3) |
IU(3) |
MH(3)
|
|
|
|
|
|
对象 |
情报编号
|
闪灵 |
FO01
|
临光 |
FO02
|
夜莺 |
FO03
|
|
|
|
ST(3) |
SW(3) |
A(4) |
DB(4) |
DD(4) |
GG(4) |
SS(4) |
BV(5)
|
|
|
|
|
|
|
对象 |
情报编号
|
锡兰 |
SS01
|
黑 |
SS02
|
苍苔 |
SS03
|
青枳 |
SS04
|
|
|
MN(5) |
PL(5) |
RCX(5) |
SI(5) |
USS(5) |
AA(6) |
B(6) |
NM(6)
|
|
|
|
|
|
|
|
对象 |
情报编号
|
年 |
NM01
|
夕 |
NM02
|
令 |
NM03
|
重岳 |
NM04
|
黍 |
NM05
|
余 |
NM06
|
|
RF(6) |
BS(7) |
HK(7) |
RE(7) |
II(8) |
RS(8) |
JC(9) |
LN(10)
|
|
|
|
|
|
|
|
|
RL(10) |
KZ(12) |
LT(12) |
RB(12) |
YD(12) |
SR(13) |
LM(14) |
PA(15)
|
|
|
|
|
|
|
|
|
SG(15) |
CB(16) |
None(23) |
VC(24) |
R(56)
|
|
|
|
|
|
{{#invoke:AskSubtotal|get
|askcondition=[[职业::术师]][[:+]]
|特性|攻击造成法术伤害$,^攻击造成群体法术伤害,超远距离,浮游单元,跳跃,通常时不攻击|
replacenumber=no
|sortclass=no
|row=6
|comparemode=loose
|replaceitem=<.->|
matchpattern=yes
|matchpattern_tag=|
displaytarget=干员
|displayclass=类特性
|hideempty=no
|}}
特性(55干员-9类特性)
|
攻击造成法术伤害$(14) |
^攻击造成群体法术伤害(13) |
超远距离(3) |
浮游单元(6) |
跳跃(4) |
通常时不攻击(4)
|
|
|
干员 |
特性
|
伊芙利特 |
攻击造成超远距离的群体法术伤害
|
蚀清 |
攻击造成超远距离的群体法术伤害
|
阿罗玛 |
攻击造成超远距离的群体法术伤害
|
|
干员 |
特性
|
卡达 |
操作浮游单元造成法术伤害 单元攻击同一敌人伤害提升(最高造成干员110%攻击力的伤害)
|
洛洛 |
操作浮游单元造成法术伤害 单元攻击同一敌人伤害提升(最高造成干员110%攻击力的伤害)
|
澄闪 |
操作浮游单元造成法术伤害 单元攻击同一敌人伤害提升(最高造成干员110%攻击力的伤害)
|
耶拉 |
操作浮游单元造成法术伤害 单元攻击同一敌人伤害提升(最高造成干员110%攻击力的伤害)
|
至简 |
操作浮游单元造成法术伤害 单元攻击同一敌人伤害提升(最高造成干员110%攻击力的伤害)
|
荒芜拉普兰德 |
操作浮游单元造成法术伤害 单元攻击同一敌人伤害提升(最高造成干员110%攻击力的伤害)
|
|
干员 |
特性
|
布丁 |
攻击造成法术伤害,且会在4个敌人间跳跃,每次跳跃伤害降低15%并造成短暂停顿
|
星源 |
攻击造成法术伤害,且会在4个敌人间跳跃,每次跳跃伤害降低15%并造成短暂停顿
|
异客 |
攻击造成法术伤害,且会在4个敌人间跳跃,每次跳跃伤害降低15%并造成短暂停顿(0.5s)
|
惊蛰 |
攻击造成法术伤害,且会在4个敌人间跳跃,每次跳跃伤害降低15%并造成短暂停顿(0.5s)
|
|
干员 |
特性
|
卡涅利安 |
通常时不攻击且防御力和法术抗性大幅度提升,技能开启时攻击造成群体法术伤害
|
林 |
通常时不攻击且防御力和法术抗性大幅度提升,技能开启时攻击造成群体法术伤害
|
薄绿 |
通常时不攻击且防御力和法术抗性大幅度提升,技能开启时攻击造成群体法术伤害
|
蜜蜡 |
通常时不攻击且防御力和法术抗性大幅度提升,技能开启时攻击造成群体法术伤害
|
|
攻击造成法术伤害,可以通过击倒敌人生成召唤物,可攻击到自身召唤物阻挡的敌人(2) |
攻击造成法术伤害,可以造成元素伤害(4) |
攻击造成法术伤害,在找不到攻击目标时可以将攻击能量储存起来之后一齐发射(最多3个)(5)
|
干员 |
特性
|
死芒 |
攻击造成法术伤害,可以通过击倒敌人生成召唤物,可攻击到自身召唤物阻挡的敌人
|
特克诺 |
攻击造成法术伤害,可以通过击倒敌人生成召唤物,可攻击到自身召唤物阻挡的敌人
|
|
干员 |
特性
|
妮芙 |
攻击造成法术伤害,可以造成元素伤害
|
折光 |
攻击造成法术伤害,可以造成元素伤害
|
温米 |
攻击造成法术伤害,可以造成元素伤害
|
烛煌 |
攻击造成法术伤害,可以造成元素伤害
|
|
干员 |
特性
|
和弦 |
攻击造成法术伤害,在找不到攻击目标时可以将攻击能量储存起来之后一齐发射(最多3个)
|
戴菲恩 |
攻击造成法术伤害,在找不到攻击目标时可以将攻击能量储存起来之后一齐发射(最多3个)
|
深靛 |
攻击造成法术伤害,在找不到攻击目标时可以将攻击能量储存起来之后一齐发射(最多3个)
|
爱丽丝 |
攻击造成法术伤害,在找不到攻击目标时可以将攻击能量储存起来之后一齐发射(最多3个)
|
黑键 |
攻击造成法术伤害,在找不到攻击目标时可以将攻击能量储存起来之后一齐发射(最多3个)
|
|
p={}
function spilt_ask(str,sep2)
--name=""
--prop={}
hasprop=string.find(str, "(.*)")
if(hasprop)then
name=string.gsub(str,"(.*)","")
prop_str=string.sub(str, string.find(str, "(.*)"))
prop_str=string.sub(prop_str, 4,-4)
prop=mw.text.split(prop_str, sep2, true)
else
name=str
prop=nil
end
--print("aa"..name.."bb")
--print("aa"..prop_str.."bb")
return name,prop
end
function ask_fileNumber(frame,askitem,askcondition)
local sep1='@sep1@'
local sep2='@sep2@'
local sep3='@sep2@'
local str=frame:callParserFunction{
name = '#ask:'..askcondition, args={
'?'..askitem,
format='plainlist',
propsep=sep2,
valuesep=sep3,
sep=sep1,
headers='hide',
link='none',
limit='1000',
order='asc'
}}
local str_table = mw.text.split(str, sep1, true)
local name_table={}
local prop_table={}
for i = 1, #str_table do
name_table[i],temp=spilt_ask(str_table[i],sep2)
if(temp)then
prop_table[i]=temp[1]
else
prop_table[i]=""
end
end
return name_table ,prop_table
end
function stringcanceltrans(str)
local tranlist={'%','(',')','.','+','-','*','?','[','^','$'}
for i = 1, #tranlist do
str=string.gsub(str,"%"..tranlist[i],"%%%"..tranlist[i])
end
return str
end
function findclass(class_table,tag,comparemode,matchpattern,matchpattern_tag)
local rtn={}
for i = 1, #class_table do
local compareresult
if(comparemode =="strict")then
compareresult=(class_table[i]==tag)
else
local tempstra=class_table[i]
local tempstrb=tag
local temptaga
local temptagb
if(matchpattern~="no" and string.find(tempstra,matchpattern_tag))then
temptaga=string.gsub(tempstra,matchpattern_tag,"")
else
temptaga=stringcanceltrans(tempstra)
end
if(matchpattern~="no" and string.find(tempstrb,matchpattern_tag))then
temptagb=string.gsub(tempstrb,matchpattern_tag,"")
else
temptagb=stringcanceltrans(tempstrb)
end
compareresult=(string.find(tempstrb,temptaga) or string.find(tempstra,temptagb))
end
if(compareresult)then
--rtn=i
--break
table.insert(rtn,i)
end
end
return rtn
end
local function intableSort2( a, b )
if(#a[2] < #b[2])then
return true
end
if(#a[2] > #b[2])then
return false
end
if(a[1] < b[1])then
return true
end
return false
end
local function intableSort( a, b )
local str_a=a[2]
local str_b=b[2]
local tag_a=string.gsub(str_a,"%d","")
local tag_b=string.gsub(str_b,"%d","")
if(tag_a == tag_b)then
local num_a_str=string.gsub(str_a,"%D","")
local num_b_str=string.gsub(str_b,"%D","")
local num_a=tonumber(num_a_str)
local num_b=tonumber(num_b_str)
if(num_a and num_b)then
if(num_a < num_b)then
return true
else
if(num_a > num_b)then
return false
end
end
end
end
if(str_a < str_b)then
return true
end
if(str_a > str_b)then
return false
end
if(a[1] < b[1])then
return true
end
return false
end
function sorttablebynum(name_table,fileNumber_table)
local temptable={}
for i = 1, #name_table do
temptable[i]={}
temptable[i][1]=name_table[i]
temptable[i][2]=fileNumber_table[i]
--table.insert(temptable[i],name_table[i])
--table.insert(temptable[i],fileNumber_table[i])
end
table.sort(temptable,intableSort)
for i = 1, #name_table do
name_table[i]=temptable[i][1]
fileNumber_table[i]=temptable[i][2]
end
return name_table,fileNumber_table
end
function makeclasstable(i_class,spilt_class_table,name_table,fileNumber_table,askitem)
local tablehead=
[[{|border="1" style="border-collapse:collapse;border: darkgray;margin: auto;"
|-style="background-color:#eaebee;"
!style="width:80px;"|]]..displaytarget..[[!!style="width:60px;"|]]..askitem.."\n"
local tableend="|}\n"
local rtn=""
for j = 1, #spilt_class_table[i_class] do
local i_num=spilt_class_table[i_class][j]
rtn=rtn.."|-\n|[["..name_table[i_num].."]]||"..fileNumber_table[i_num].."\n"
end
rtn=tablehead..rtn..tableend
if(#spilt_class_table[i_class]==0)then
rtn=""
end
return rtn
end
function makeplainoutput(class_table,spilt_class_table,name_table,fileNumber_table)
local rtn=""
for i = 1, #class_table do
rtn=rtn..class_table[i]..": \n\n"
for j = 1, #spilt_class_table[i] do
i_num=spilt_class_table[i][j]
rtn=rtn.."("..name_table[i_num]..","..fileNumber_table[i_num]..")"
end
rtn=rtn.."\n\n----"
end
return rtn
end
function p.get(frame)
local args = (frame == mw.getCurrentFrame() and frame.args) or frame
--local argv = #args
local argv = 0
while(args[argv+1])do
argv=argv+1
end
local askitem="情报编号"
local class_table_str=""
local askcondition =""
local replacenumber ="yes"
local comparemode ="strict"
local N_row=8
local sortclass="no"
local matchpattern="no"
local replaceitem_str=""
local matchpattern_tag="模式匹配"
local hideempty="no"
displaytarget="对象"
displayclass="类"
local class_table={}
local replaceitem_table={}
if(args[1])then
askitem=args[1]
end
if(args[2])then
class_table_str=args[2]
class_table=mw.text.split(class_table_str, ",", true)
end
if(args["askcondition"])then
askcondition=args["askcondition"]
else
askcondition='[['..askitem..'::+]][[:+]]'
end
if(args["replacenumber"])then
replacenumber=args["replacenumber"]
end
if(args["comparemode"])then
comparemode=args["comparemode"]
end
if(args["row"])then
N_row=tonumber(args["row"])
end
if(args["sortclass"])then
sortclass=args["sortclass"]
end
if(args["matchpattern"])then
matchpattern=args["matchpattern"]
end
if(args["matchpattern_tag"])then
matchpattern_tag=args["matchpattern_tag"]
end
if(args["replaceitem"])then
replaceitem_str=args["replaceitem"]
replaceitem_table=mw.text.split(replaceitem_str, ",", true)
end
if(args["hideempty"])then
hideempty=args["hideempty"]
end
if(args["displaytarget"])then
displaytarget=args["displaytarget"]
end
if(args["displayclass"])then
displayclass=args["displayclass"]
end
---------------------------------------------------------------------------------------------
name_table ,fileNumber_table=ask_fileNumber(frame,askitem,askcondition)
name_table ,fileNumber_table=sorttablebynum(name_table,fileNumber_table)
local tag_table={}
for i = 1, #fileNumber_table do
if(replacenumber=="yes")then
tag_table[i]=string.gsub(fileNumber_table[i],"%d","")
else
tag_table[i]=fileNumber_table[i]
end
for j = 1, #replaceitem_table do
tag_table[i]=string.gsub(tag_table[i],replaceitem_table[j],"")
end
end
local spilt_class_table={}
for i = 1, #class_table do
spilt_class_table[i]={}
end
for i = 1, #name_table do
local i_class_table=findclass(class_table,tag_table[i],comparemode,matchpattern,matchpattern_tag)
if(#i_class_table==0)then
table.insert(class_table,tag_table[i])
table.insert(spilt_class_table,{})
i_class=#class_table
table.insert(spilt_class_table[i_class], i)
else
for j = 1, #i_class_table do
i_class=i_class_table[j]
table.insert(spilt_class_table[i_class], i)
end
end
end
if(hideempty~="no")then
local temp=#spilt_class_table
for i = temp, 1 ,-1 do
if #spilt_class_table[i]==0 then
table.remove (spilt_class_table , i)
table.remove (class_table , i)
end
end
end
local classsorttable={}
if(sortclass~="no")then
for i = 1, #spilt_class_table do
classsorttable[i]={}
classsorttable[i][1]=i
classsorttable[i][2]=spilt_class_table[i]
end
table.sort(classsorttable,intableSort2)
end
local class_row_table={{}}
local i_row=1
local n_row=1
local n_valid_class=0
for i = 1, #class_table do
if(n_row==N_row+1)then
n_row=1
i_row=i_row+1
table.insert(class_row_table, {})
end
local i_choose=i
if(sortclass~="no")then
i_choose=classsorttable[i][1]
end
class_row_table[i_row][n_row]=i_choose
n_row=n_row+1
if(#spilt_class_table[i]>0)then
n_valid_class=n_valid_class+1
end
end
local tablehead=[[{|class="wikitable" style="white-space:normal; text-align:center;"]].."\n"
tablehead=tablehead..'|-\n!colspan="'..N_row..'"|'..askitem..'('..#name_table..displaytarget..'-'..n_valid_class..displayclass..')\n'
local tableend="|}\n"
local rtn2=""
local setwidthstr=""
if(#class_table>=N_row)then
setwidthstr='style="width:'..string.format("%.2f",(100/N_row))..'%;"|'
end
for i = 1, #class_row_table do
local str_title=""
local str_contant=[[|-style="vertical-align:top;"]].."\n"
for j = 1, #class_row_table[i] do
local i_class=class_row_table[i][j]
if(j==1)then
str_title=str_title.."|-\n!"..setwidthstr..class_table[i_class]
else
str_title=str_title.."!!"..setwidthstr..class_table[i_class]
end
if(#spilt_class_table[i_class]>0)then
str_title=str_title.."("..#spilt_class_table[i_class]..")"
end
str_contant=str_contant.."||\n"..makeclasstable(i_class,spilt_class_table,name_table,fileNumber_table,askitem)
end
str_title=str_title.."\n"
rtn2=rtn2..str_title..str_contant
end
rtn2=tablehead..rtn2..tableend
--local rtn=makeplainoutput(class_table,spilt_class_table,name_table,fileNumber_table)
--return rtn.."\n\n\n\n"..rtn2
return rtn2
end
return p