Module:Infobox gacha

From Sekaipedia
Revision as of 05:23, 18 October 2022 by ChaoticShadow (talk | contribs)

To generate {{Infobox gacha}}, invoke using the main function.


--------------------------
-- Module for [[Template:Infobox gacha]]
------------------------
local getArgs   = require('Module:Arguments').getArgs
local InfoboxBuilder = require('Module:InfoboxBuilder')
local DisplayFns     = require('Module:InfoboxBuilderDisplayFunctions')
local ProcessingFns  = require('Module:InfoboxBuilderProcessingFunctions')

local p = {}


function p.main(frame)
	local args = getArgs(frame)
	local infobox = InfoboxBuilder.new()
	
	infobox:setName('Infobox gacha')
		:setParams{
			{ name = 'gacha id' },
			{ name = 'gacha name', default = mw.title.getCurrentTitle().text },
			{ name = 'logo' },
			{ name = 'banner' },
			{ name = 'japanese' },
			{ name = 'romaji' },
			{ name = 'start' },
			{ name = 'end' },
			{ name = 'type' },
			{ name = 'pity' },
			{ name = 'currency', fn = ProcessingFns.stringToArray(',') }
		}
		:setArgs(args)
		:processArgs()
		:setCategoryMap({
			['pity'] = {
				['Yes'] = 'Gachas with pity'
			}
		})

	infobox
		:addHeader({ tag = 'argth', content = 'gacha name' })
		:addImage({
			{ 
				tag = 'argtd', 
				content = 'logo',
				fn = DisplayFns.image('x100px'),
				tabName = 'Logo'
			},
			{ 
				tag = 'argtd', 
				content = 'banner',
				fn = DisplayFns.image('x100px'),
				tabName = 'Banner' 
			}
		})
		:addRow({
			{ tag = 'th', content = 'Japanese' },
			{ tag = 'argtd', content = 'japanese' }
		})
		:addRow({
			{ tag = 'th', content = 'Romaji' },
			{ tag = 'argtd', content = 'romaji' }
		})
		:addHeader({ tag = 'th', content = 'Gacha Information' }, { subheader = true })
		:addRow({
			{ tag = 'th', content = 'Gacha ID' },
			{ tag = 'argtd', content = 'gacha id' }
		})
		:addRow({
			{ tag = 'th', content = 'Start date' },
			{ tag = 'argtd', content = 'start' }
		})
		:addRow({
			{ tag = 'th', content = 'End date' },
			{ tag = 'argtd', content = 'end' }
		})
		:addRow({
			{ tag = 'th', content = 'Gacha type' },
			{ tag = 'argtd', content = 'type' }
		})
		:addRow({
			{ tag = 'th', content = 'Has pity?' },
			{ tag = 'argtd', content = 'pity' }
		})
		:addRow({
			{ tag = 'th', content = 'Currency' },
			{ tag = 'argtd', content = 'currency', fn = DisplayFns.list('unbulleted') }
		})

	local categories = ""
	if mw.title.getCurrentTitle().namespace == 0 then
		categories = "[[Category:Gachas]]" .. infobox:getCategories()
	end

	return infobox:tostring() .. categories
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.