Module:Templates/enemy

local p = {} local function isEmpty(s) return s == nil or s == '' or s == "None" end -- ======================================== -- Function outputs the lifebar of an enemy -- ======================================== -- Output ME enemy lifebar local function lifebar_ME(param) local s = "" local shields = 0 if not isEmpty(param.args['shields']) then shields = tonumber(param.args['shields']) end if shields > 0 then for i=1,shields,1 do           s = s .. ""       end end local result = "" .. s   return result end -- Output ME2 enemy lifebar local function lifebar_ME2(param) -- ME2 lifebar combos: -- Health, Health + Armor + Barrier, Health + Armor + Shields, Health + Barrier, Health + Shields, or    -- Armor, Armor + Barrier, Armor + Shields or    -- Barrier or Shields local list = { ["h"] = "", ["ha"] = "", ["has"] = "", ["hab"] = "", ["hb"] = "", ["hs"] = "", ["a"] = "", ["ab"] = "", ["as"] = "", ["b"] = "", ["s"] = "", }   local life = param.args local combo = ""; if not isEmpty(life['health']) then if not isEmpty(life['armor']) then if not isEmpty(life['shields']) then combo = "has" elseif not isEmpty(life['barrier']) then combo = "hab" else combo = "ha" end else if not isEmpty(life['shields']) then combo = "hs" elseif not isEmpty(life['barrier']) then combo = "hb" else combo = "h" end end elseif not isEmpty(life['armor']) then if not isEmpty(life['shields']) then combo = "as" elseif not isEmpty(life['barrier']) then combo = "ab" else combo = "a" end else if not isEmpty(life['shields']) then combo = "s" elseif not isEmpty(life['barrier']) then combo = "b" else combo = "" end end return list[combo] end -- Output ME3 enemy lifebar local function lifebar_ME3(param) -- ME3 lifebar combos: -- Health, Health + Barrier, Health + Shields, or   -- Armor, Armor + Barrier, Armor + Shields or    -- Barrier or Shields local list = { ["h"] = "", ["hb"] = "", ["hs"] = "", ["a"] = "", ["ab"] = "", ["as"] = "", ["b"] = "", ["s"] = "", }   local life = param.args local combo = ""; if not isEmpty(life['health']) then if not isEmpty(life['shields']) then combo = "hs" elseif not isEmpty(life['barrier']) then combo = "hb" else combo = "h" end elseif not isEmpty(life['armor']) then if not isEmpty(life['shields']) then combo = "as" elseif not isEmpty(life['barrier']) then combo = "ab" else combo = "a" end else if not isEmpty(life['shields']) then combo = "s" elseif not isEmpty(life['barrier']) then combo = "b" else combo = "" end end return list[combo] end -- Outputs lifebar function p.lifebar(param) local game = param.args['game'] local result if game == "me" then result = lifebar_ME(param) end if game == "me2" then result = lifebar_ME2(param) end if game == "me3" then result = lifebar_ME3(param) end return result end -- ======================================= -- Function outputs the powers of an enemy -- ======================================= function p.powers(param) local args = mw.text.split(param.args[1], "%s*,%s*") local result = ""; local game = param.args['game'] for i, name in ipairs(args) do       result = result .. " "   end return param:preprocess("") end return p