模块:Hydrogina/sandbox/AllEnemyInfo2

可在模块:Hydrogina/sandbox/AllEnemyInfo2/doc创建此模块的帮助文档

p={}

tablehead=[[{| class="wikitable filterable sortable" style="text-align:center; display:table; white-space:normal;"
|-
! class="filterable-head" style="width:15%" |关卡
! class="filterable-head" style="width:15%" |敌人
! class="filterable-head" style="width:7%" data-sort-type="number"|数量
! class="filterable-head" style="width:7%" |地位
! class="filterable-head" style="width:7%" data-sort-type="number"|级别
! class="filterable-head" style="width:7%" data-sort-type="number"|生命值
! class="filterable-head" style="width:7%" data-sort-type="number"|攻击力
! class="filterable-head" style="width:7%" data-sort-type="number"|防御力
! class="filterable-head" style="width:8%" data-sort-type="number"|法术抗性
! class="filterable-head" style="width:8%" data-sort-type="number"|攻击间隔
! class="filterable-head" style="width:8%" data-sort-type="number"|重量等级
! class="filterable-head" style="width:8%" data-sort-type="number"|移动速度
! class="filterable-head" style="width:7%" data-sort-type="number"|攻击范围半径
! class="filterable-head" style="width:7%" data-sort-type="number"|生命恢复速度
]]	
tableend="|}\n"

function p.get(frame)
	local args = (frame == mw.getCurrentFrame() and frame.args) or frame

	local askcondition ='[[分类:普通难度关卡]]OR[[分类:剿灭关卡]]'
	local levellimit =-1
	local printlevellist ="no"
	local preloaddata ="no"
	local preloadpath ="模板:详细敌人一览"
	local rtn=""
	
	if(args["askcondition"])then
		askcondition=args["askcondition"]
	end
	
	if(args["levellimit"])then
		levellimit=tonumber(args["levellimit"])
	end
	
	if(args["printlevellist"])then
		printlevellist=args["printlevellist"]
	end
	
	if(args["preloaddata"])then
		preloaddata=args["preloaddata"]
	end
	
	if(args["preloadpath"])then
		preloadpath=args["preloadpath"]
	end
	
	-------------------------------------------------------------------------
	
	datastr=frame:callParserFunction{
		name = '#ask:'..askcondition, args={
		"?关卡敌人信息",
		format="array",
		pagetitle="show",
		sep=']],["',
		propsep='",[',
		limit=5000
	}}
	datastr='[["'..datastr..']]]'

	--datastr=mw.ustring.gsub(datastr,",,",",")
	--if(string.sub(datastr, 1, 1)==",")then
	--	datastr=string.sub(datastr, 2)
	--end
	--if(string.sub(datastr, -1, -1)==",")then
	--	datastr=string.sub(datastr,1,-2)
	--end
	--datastr="["..datastr.."]"
	--datastr=mw.ustring.gsub(datastr,",%]","]")
	--datastr=mw.ustring.gsub(datastr,"%[,","[")
	
	datatable=mw.text.jsonDecode(datastr)
	
	strstyle="style='background:#2F2F2F;color:#FFF'|"
	
	for i, stage in ipairs(datatable) do
    	stagename="[["..stage[1].."]]"
    	enemys=stage[2]
    	if(#enemys==0)then
    		rtn=rtn.."|-\n|"..stagename.."||无||—||—||—||—||—||—||—||—||—||—||—||—\n"
    	else
	    	for j, enemy in ipairs(enemys) do
	    		enemydata=enemy[1]
	    		changes=enemy[2]
	    		
	    		enemydata[1]="[["..enemydata[1].."]]"
	    		
	    		for k, cg in ipairs(changes) do
	    			enemydata[cg+4]=strstyle..enemydata[cg+4]
	    		end
	    		rtn=rtn.."|-\n|"..stagename.."||"..table.concat( enemydata, "||").."\n"
	    	end	
    	end
	end 
	
	rtn=tablehead..rtn..tableend
	
	return rtn
end

return p