欢迎来到气球塔防6 BWIKI!
除特殊说明外,本站内容采用CC BY-NC-SA 4.0协议。
欢迎各位到留言板留言或者加入QQ群:950568164

全站通知:

模块:TowerUtility

来自气球塔防6WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:TowerUtility/doc创建

local p = {}

p.upgrade = function(frame)
	local prices = mw.text.jsonDecode(mw.title.new("Prices.json"):getContent())
	local tower = frame.args[1]
	local path = tonumber(frame.args[2])
	local tier = tonumber(frame.args[3])
	return prices[tower][path][tier]
end

p.base = function(frame)
	local prices = mw.text.jsonDecode(mw.title.new("Prices.json"):getContent())
	local tower = frame.args[1]
	return prices[tower]["base"]
end

p.paragon = function(frame)
	local prices = mw.text.jsonDecode(mw.title.new("Prices.json"):getContent())
	local tower = frame.args[1]
	return prices[tower]["paragon"]
end

p.cleanCrossPath = function(frame)
	local xPaths = mw.text.split(frame.args[1], ';')
	local result = {}
	for k, v in ipairs(xPaths) do
		local xPathStats = mw.text.trim(v)
		if xPathStats ~= '' then
			local lines = mw.text.split(xPathStats, '\n')
			if #lines <= 1 then
				error("details not provided")
			end
			local resultLine = string.format("'''%s''':%s", lines[1], lines[2])
			table.insert(result, resultLine)
		end
	end
	return table.concat(result, '<br>')
end

return p