Module:Enemies

---	Enemies contains details of Risk of Rain 2's monsters. --	--	@module		enemies --	@alias		p --	@author		User:Cephalon Scientia --	@attribution	All who helped to update enemy infoboxes --	@require	Module:Enemies/Data --	@release	stable --

local MonsterData = mw.loadData('Module:Enemies/Data').Monsters

local p = {} table.unpack = unpack	-- pre-Lua 5.3 table library does not have unpack function

---	Creates a monster link. --	@function		p.MonsterLink --	@param			{table} frame Frame object --	@return			{string} Preprocessed wikitext of resultant link function p.MonsterLink(frame) local tooltip = "%s%s %s %s   " local data = MonsterData[frame.args[1]] local str = string.format(		tooltip,		data.Extension and "" or "",		frame.args[5] ~= "false" and "" or (""),		frame.args[3] or data.Link,		frame.args[2] or data.Name,		data.Name	) return frame:preprocess(str) end

---	Builds a wikitable of all monsters. --	@function		p.BuildAllMonstersTable --	@param			{table} frame Frame object --	@return			{string} Preprocessed wikitext of resultant wikitable --	@usage			p.BuildAllMonstersTable(mw.getCurrentFrame) or function p.BuildAllMonstersTable(frame) local wikitable = { [=[ {| class="wikitable sortable" ! Image ! Name ! Base Health ! Health Scaling ! Base Damage ! Damage Scaling ! Base Health Regen ! Scaling Health Regen ! Armor ! Movement Speed (m/s) ! Class ! Type }	-- Corresponding to key names in /Data -- Order will determine which where data will appear in below format string local keyNames = { "Image", "Link", "Name", "Expansion", "BaseHealth", "ScalingHealth", "BaseDamage", "ScalingDamage", "BaseHealthRegen", "ScalingHealthRegen", "BaseArmor", "BaseSpeed", "Class", "Type" }	-- Table row looks like format string: "| [[File:%s]] || %s%s || %s || ... || %s" -- Would eventually become something like: -- | [[File:Gup.png]] || Gup || 1000 || 300 || 12 || 2.4 || N/A || N/A || N/A || 12 local tableRow = (function		local temp = { "| %s || %s%s" }		-- For function chaining syntax		temp.remove = function(self, elem)			table.remove(self, #self)			return self		end		for _, key in ipairs(keyNames) do			table.insert(temp, " || %s")		end		-- Removing extra columns since first two columns have custom formatting		temp:remove:remove:remove:remove		table.insert(temp, "\n|-")		return table.concat(temp, "")	end) for _, monsterEntry in pairs(MonsterData) do		local keyValues = {} for _, key in pairs(keyNames) do			-- Adding expansion icon after monster name if (key == "Expansion") then table.insert(keyValues, monsterEntry[key] == "SotV" and "" or "") else table.insert(keyValues, monsterEntry[key] or "N/A") end end table.insert(wikitable, tableRow:format(table.unpack(keyValues))) end table.insert(wikitable, "|}") return frame:preprocess(table.concat(wikitable, "\n")) end
 * -]=]

return p