Module:Enemy

Documentation for this module may be created at Module:Enemy/doc

local p = {}
local data = mw.loadData("Module:Data/Enemies")

function p.createInfobox(frame)
	local enemy = data[frame.args.name]
	local str = { 
		category = (enemy.isBoss == true and 'Boss' or 'Regular enemy'), 
		location = frame.args.location,
		scanner = frame.args.scanner,
		aggro = frame.args.aggro,
		faction = enemy.faction,
		health = formatNum(enemy.maxHealth),
		prespawn = frame.args.prespawn,
		summon = frame.args.summon
	}
	
	return frame:expandTemplate{title = 'Enemy infobox', args = str}
end

function formatNum(i)
	return tostring(i):reverse():gsub("%d%d%d", "%1,"):reverse():gsub("^,", "")
end

return p