Module:UnitEnlightenmentSinList

local p = {}

require("Module:Database") local dataModel = require("Module:Data").model

local tagMap = mw.loadData("Module:Data/Extra/TagMap") local statNameMap = mw.loadData("Module:Data/Extra/StatNameMap") local gateList = mw.loadData("Module:Data/MasterParam/UnitEnlightenment/Gluttony")

local supportedSins = {'Envy', 'Wrath', 'Gluttony', 'Greed', 'Lust', 'Sloth', 'Pride'}

local getUnitName = function(iname) return dataModel.getLoc('Data:Game/MasterParam/Unit/' .. string.gsub(iname, '_', ' '), 'name') end

function p.unitEnlightenmentSinList local unitOutputList = {} for iname, unitGateData in pairs(gateList) do       local tempUnit = { unitKey = iname, unitName = getUnitName(iname), }       local sinCount = 0 for ignore, tempStat in pairs(unitGateData['maxBonus']['stats']) do           if ((tempStat['max'] > 0) and (tempStat['type'] == 'Tokkou')) then local tempTag = (tagMap[tempStat['tktag']] or tempStat['tktag']) tempUnit[tempTag] = tempStat['max'] sinCount = sinCount + 1 end end if sinCount > 0 then table.insert(unitOutputList, tempUnit) end end table.sort(unitOutputList, function(a, b) return a.unitName < b.unitName end) local enlightenmentOutput = { '{| class="wikitable sortable"', "|-",       '! Portrait !! Name !! '..table.concat(supportedSins, ' !! '), }   local render_unit_icon = require('Module:Render/Unit')._icon local render_unit_name = require('Module:Render/Unit')._pageName for key, unitSinData in ipairs(unitOutputList) do       table.insert(enlightenmentOutput, '|-') table.insert(enlightenmentOutput, '|'..render_unit_icon({unitSinData['unitKey'], name='none', size='small'})) table.insert(enlightenmentOutput, '|'..render_unit_name({unitSinData['unitKey']})) for ignore, sinName in ipairs(supportedSins) do          table.insert(enlightenmentOutput, '|'..(unitSinData[sinName] or ' ')) end end table.insert(enlightenmentOutput, "|}") return table.concat(enlightenmentOutput, "\n") end

return p