模块:IfInclude

来自PRTS
跳到导航 跳到搜索

{{#invoke:IfInclude|ifInclude|str=123456|pattern=123|include=包含123|notInclude=不包含123}}

包含123


{{#invoke:IfInclude|ifInclude|str=123456|pattern=012|include=包含012|notInclude=不包含012}}

不包含012


local p = {}
function p.ifInclude(frame)
	local args = (frame == mw.getCurrentFrame() and frame.args) or frame
	if string.find(args.str,args.pattern)==nil
	then
		return args.notInclude
	else
		return args.include
	end
end

function p.CheckDamageType(frame)
	local args = (frame == mw.getCurrentFrame() and frame.args) or frame
	if string.find(args.str,'治疗')
	then
		return '治疗'
	elseif string.find(args.str,'法术') ~=nil
	then
		return '法术'
	else 
		return '物理'
	end
end

function p.CheckAttackType(frame)
	local args = (frame == mw.getCurrentFrame() and frame.args) or frame
	if args.str =='不攻击'
	then
		return '不攻击'
	end
	result = ""
	if string.find(args.str, '近战') ~= nil
	then
		result = result .. ' 近战'
	end
	if string.find(args.str, "远程") ~= nil
	then
		result = result .. ' 远程'
	end
	return result
end

return p