本模块用于输出功法详细信息


在任意页面输入

{{#invoke:GongFa|mian|太极拳}}

或在太极拳页面输入

{{#invoke:GongFa|mian}}

使用模板:模板:GongFa/基础模板:GongFa/内功模板:GongFa/摧破模板:GongFa/轻灵模板:GongFa/护体模板:GongFa/运功模板:GongFa/发挥控制输出页面格式


require('Module:no globals')

local function FindOne(key)
	local Data = require('Module:GongFa/data')
    key = Data.name[key] or Data.id[key]
    return Data.raw[key]
end

local TemplateName = {
	[-1] = '内功',
	[0] = '内功',
	[1] = '摧破',
	[2] = '轻灵',
	[3] = '护体',
}
-- =p{args={'断魂幽吟曲'}}
local function p(frame) 
	local args = frame.args
	local name = args[1] or mw.title.getCurrentTitle().text
	name = mw.ustring.gsub(name, '功法/', '')
	local raw = FindOne(name)
	if raw==nil or next(raw)==nil then
		error("无此功法:"..name)
	end

	local translated = require('Module:GongFa/value').change(raw, true)
	for k,v in pairs(raw) do
		translated[k] = v
	end
	raw = nil

	local result = mw.getCurrentFrame():expandTemplate{ title = 'GongFa/基础', args = translated }
	if TemplateName[translated.data6 or 0] then
		result = result..mw.getCurrentFrame():expandTemplate{ title = 'GongFa/'..TemplateName[translated.data6 or 0], args = translated }
	end
	if translated['运功效果'] then
		result = result..mw.getCurrentFrame():expandTemplate{ title = 'GongFa/运功'}..'\n'..translated['运功效果']
	end
	if translated['需求'] then
		result = result..mw.getCurrentFrame():expandTemplate{ title = 'GongFa/发挥'}..'\n'..translated['需求']
	end
	result = result..'<br/>'..require('Module:GongFa').power(translated, args)
	result = '<div style="max-width:500px">'..result..'</div>'
	return result
end

return p
avatar