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

全站通知:

模块:Quest

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

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

local p = {}

local translations = {
	Easy = "简单",
	Medium = "普通",
	Hard = "困难",

	PrimaryOnly = "仅初级",
	Deflation = "通货紧缩",
	Reverse = "相反",
	MilitaryOnly = "仅军事",
	Apopalypse = "天启",
	MagicOnly = "仅魔法",
	DoubleMoabHealth = "双倍生命值MOAB",
	HalfCash = "金币减半",
	AlternateBloonsRounds = "替代气球回合",
	Impoppable = "不可击破",
	Clicks = "超猩星",
	Standard = "标准",

	bloonSpeed = "气球速度",
	moabSpeed = "飞艇速度",
	bossSpeed = "BOSS速度",
	ceramicHealth = "陶瓷气球生命",
	moabHealth = "飞艇生命",
	bossHealth = "BOSS生命",
	regrowRate = "重生速度",
	removeCost = "移除费用",
	abilityCooldown = "技能冷却时间",

	noMK = "禁用猴子知识",
	noSelling = "禁用出售",
	noPower = "禁用力量",
	noDoubleCash = "禁用双倍金币",
	noContinue = "禁用猴币复活",
	noFastTrack = "禁用快速路径",
	allCamo = "所有气球附带迷彩属性",
	allRegrow = "所有气球附带重生属性",
}

local towerType = {
	DartMonkey = "primary",
	BoomerangMonkey = "primary",
	BombShooter = "primary",
	TackShooter = "primary",
	IceMonkey = "primary",
	GlueGunner = "primary",
	Desperado = "primary",
	
	SniperMonkey = "military",
	MonkeySub = "military",
	MonkeyBuccaneer = "military",
	MonkeyAce = "military",
	HeliPilot = "military",
	MortarMonkey = "military",
	DartlingGunner = "military",
	
	WizardMonkey = "magic",
	SuperMonkey = "magic",
	NinjaMonkey = "magic",
	Alchemist = "magic",
	Druid = "magic",
	Mermonkey = "magic",
	
	BananaFarm = "support",
	SpikeFactory = "support",
	MonkeyVillage = "support",
	EngineerMonkey = "support",
	BeastHandler = "support",
}

local getLength = function(t)
	local count = 0
	for k, v in pairs(t) do
		count = count + 1
	end
	return count
end

local translateDifficulty = function(diff)
	return translations[diff]
end

local translateMode = function(mode)
	return translations[mode]
end

local handleNumber = function(num)
	if num == -1 then return "默认" end
	return tostring(num)
end

local handleLimit = function(num)
	if num == -1 then return "-" end
	return tostring(num)
end

local handleMap = function(map)
	if map == 'Tutorial' then return "MonkeyMeadow" end
	if map == '#Ouch' then return "Ouch" end
	return map
end

local handleBasic = function(basic, out)
	local map = handleMap(basic['map'])
	table.insert(out, "<tr><th colspan=4>基础信息</th></tr>")
	table.insert(out, string.format("<td colspan=4 style=\"padding:0px 0px 66.66%% 0px;position:relative\">[[file:MapSelect%sButton.png|link=|class=map-abs]]</td>", map))
	table.insert(out, string.format("<tr><td style=\"width:25%%\">难度</td><td style=\"width:25%%\">%s</td>", translateDifficulty(basic['difficulty'])))
	table.insert(out, string.format("<td style=\"width:25%%\">模式</td><td style=\"width:25%%\">%s</td></tr>", translateMode(basic['mode'])))
	table.insert(out, string.format("<tr><td>起始回合</td><td>%s</td><td>初始生命</td><td>%s</td></tr>", handleNumber(basic['startRound']), handleNumber(basic['lives'])))
	table.insert(out, string.format("<tr><td>结束回合</td><td>%s</td><td>最大生命</td><td>%s</td></tr>", handleNumber(basic['endRound']), handleNumber(basic['maxLives'])))
	table.insert(out, string.format("<tr><td>防御塔数</td><td>%s</td><td>初始金币</td><td>%s</td></tr>", handleLimit(basic['maxTowers']), handleNumber(basic['cash'])))
	table.insert(out, string.format("<tr><td>升级限制</td><td>%s</td><td>花费限制</td><td>%s</td></tr>", handleLimit(basic['leastTiersUsed']), handleLimit(basic['leastCash'])))
end

local handleHero = function(heroes, out)
	local length = getLength(heroes)
	if length == 0 then return end
	table.insert(out, "<tr><th colspan=4>可用英雄</th></tr><tr><td colspan=4 style=\"padding:0px;background:#FFF;overflow-x:auto;white-space:nowrap\">")
	for i, v in ipairs(heroes) do
		if v == "Corvus" then
			table.insert(out, "[[file:CorvusPortraitSpiritless.png|52px|link=|class=info-hero-bg]]")
		else
			table.insert(out, string.format("[[file:%sPortrait.png|52px|link=|class=info-hero-bg]]", v))
		end
	end
	table.insert(out, "</td></tr>")
end

local handleTowers = function(towers, out)
	local length = getLength(towers)
	if length == 0 then return end
	table.insert(out, "<tr><th colspan=4>可用猴子</th></tr><tr><td colspan=4 style=\"padding:0px;background:#FFF;overflow-x:auto;white-space: nowrap\">")
	for i, v in ipairs(towers) do
		local tower = mw.text.split(v, ':')
		table.insert(out, string.format('<div style="position:relative;display:inline-block" class="info-%s-bg">', towerType[tower[1]]))
		table.insert(out, string.format("[[file:%s.png|52px|link=]]", tower[1]))
		if tower[3] ~= 'Inf' then
			table.insert(out, '<div style="position:absolute;right:0px;top:0px;width:40%;text-align:center;background:#007dff;border-radius: 10px">')
			table.insert(out, string.format('<span style="color:#FFF;font-weight:bold;"><b>%s</b></span></div>', tower[3]))
		end
		if tower[2] ~='666' then
			table.insert(out, '<div style="position:absolute;right:0px;bottom:0px;width:100%;text-align:center;">')
			table.insert(out, '<span style="color:#fff;font-weight:bold;text-shadow:2px 2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, -2px -2px 0 #000, 2px 0px 0 #000, 0px 2px 0 #000, -2px 0px 0 #000, 0px -2px 0 #000;">')
			table.insert(out, string.format('<b>%s</b></span></div>', tower[2]:sub(1,1).."-"..tower[2]:sub(2,2).."-"..tower[2]:sub(3,3)))
		end
		table.insert(out, "</div>")
	end
	table.insert(out, "</td></tr>")
end

local handleModifier = function(modifier, out)
	local length = getLength(modifier)
	local hasMods = false
	local o = {"<tr><th colspan=4>参数设定</th></tr>"}
	for i,v in pairs(modifier) do
		if v~=1 then
			table.insert(o, string.format("<tr><td colspan=2>%s</td><td colspan=2>%s%%</td></tr>", translations[i], tostring(v*100)))
			hasMods = true
		end
	end
	if not hasMods then return end
	table.insert(out, table.concat(o, ""))
end

local handleSwitches = function(switches, out)
	local length = getLength(switches)
	local hasSwitches = false
	local o = {"<tr><th colspan=4>其他限制</th></tr><tr><td colspan=5>"}
	for i,v in pairs(switches) do
		if v then
			table.insert(o, string.format("\n*%s", translations[i]))
			hasSwitches = true
		end
	end
	if not hasSwitches then return end
	table.insert(o, "\n</td></tr>")
	table.insert(out, table.concat(o, ""))
end

p.main = function(frame)
	local questName = frame.args[1]
	local taskNo = tonumber(frame.args[2])
	local quest = mw.text.jsonDecode(mw.title.new("Module:QuestData.json"):getContent())[questName][taskNo]
	local lines = {'<table class="wikitable questtable">'}
	handleBasic(quest['basic'], lines)
	handleHero(quest['heroes'], lines)
	handleTowers(quest['towers'], lines)
	handleModifier(quest['multipliers'], lines)
	handleSwitches(quest['switches'], lines)
	table.insert(lines, "</table>")
	return table.concat(lines, "")
end

return p