本站文本内容除另有声明外,转载时均必须注明出处,并遵守CC BY-NC-SA 3.0协议。(转载须知
本站是中文Minecraft Wiki的镜像站,与Mojang Studios、Weird Gloop没有从属关系。(免责声明

全站通知:

模块:Armor info

来自我的世界地下城WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

armorDamageTable基于盔甲防御点数和攻击强度,展示一个关于受到的伤害的表格。

local p = {}

local function armorDamage( damage, defensePoints, toughness )
	local value1 = defensePoints / 5
	local value2 = defensePoints - damage / (2 + 0.25 * toughness)
	local choose = 'partial'
	if value1 > value2 then choose = 'no' end
	if value1 < value2 then choose = 'yes' end
	return math.max( 0, damage * ( 1 - math.max( value1, value2 ) / 25 ) ), choose
end

local function armorDamageTable( mindamage, maxdamage, stepsize, toughness )
	local t = {}

	table.insert( t, '{| class="wikitable" style="text-align:center"' )
	table.insert( t, '|-' )
	table.insert( t, '! rowspan="2" | 护甲值' )
	table.insert( t, '! colspan="' .. math.max(1, math.floor((maxdamage - mindamage) / stepsize) + 1) .. '" | 伤害' )

	table.insert( t, '|-' )
	for i = mindamage, maxdamage, stepsize do
		table.insert( t, '! ' .. i )
	end

	for defensePoints = 0, 30 do
		local r = {}
		table.insert( t, '|-' )
		table.insert( t, '! ' .. defensePoints )
		for damage = mindamage, maxdamage, stepsize do
			local reducedDamage, choose = armorDamage( damage, defensePoints, toughness )
			table.insert( t, '| class="tc-'
				.. choose
				.. '" | '
				.. string.format( '%.2f', reducedDamage )
				)
		end
	end

	table.insert( t, '|}' )

	return table.concat( t, '\n' )
end

local function armoredWolfKillDamageTable( mindamage, maxdamage, stepsize )
	local t = {}

	table.insert( t, '{| class="wikitable" style="text-align:center"' )
	table.insert( t, '|+ 不同伤害击杀装备了狼铠的狼需要的攻击次数' )
	table.insert( t, '! 伤害' )
	table.insert( t, '! 击杀需要的次数' )
	local lastCounts = 999999
	for damage = mindamage, maxdamage, stepsize do
		local reducedDamage, choose = armorDamage( damage, 11, 0 )
		local countsToKill = math.ceil(20 / ((reducedDamage + 1) / 2))
		if countsToKill < lastCounts then
			lastCounts = countsToKill
			table.insert( t, '|-' )
			table.insert( t, '| ' .. mw.getCurrentFrame():expandTemplate { title = 'Hp', args = {damage} } )
			table.insert( t, '| ' .. countsToKill)
		end
	end

	table.insert( t, '|}' )

	return table.concat( t, '\n' )
end

function p.armorDamageTable( frame )
	return armorDamageTable(1, 20, 1, 0)
end

function p.armoredWolfKillDamageTable( frame )
	return armoredWolfKillDamageTable(0, 50, 1)
end

return p