Skip to content

Commit

Permalink
Custom Infobox Game for Esports wiki (#3440)
Browse files Browse the repository at this point in the history
* Create infobox_game.lua

* Update and rename infobox_game.lua to infobox_game_custom.lua

* Remove whitespace

* Update components/infobox/wikis/esports/infobox_game_custom.lua

Co-authored-by: hjpalpha <[email protected]>

* Update components/infobox/wikis/esports/infobox_game_custom.lua

Co-authored-by: hjpalpha <[email protected]>

* Update components/infobox/wikis/esports/infobox_game_custom.lua

Co-authored-by: hjpalpha <[email protected]>

* Update components/infobox/wikis/esports/infobox_game_custom.lua

Co-authored-by: hjpalpha <[email protected]>

* Removing whitespace and unused variables

* Update components/infobox/wikis/esports/infobox_game_custom.lua

Co-authored-by: hjpalpha <[email protected]>

* Update components/infobox/wikis/esports/infobox_game_custom.lua

Co-authored-by: hjpalpha <[email protected]>

* Update components/infobox/wikis/esports/infobox_game_custom.lua

Co-authored-by: hjpalpha <[email protected]>

* Update components/infobox/wikis/esports/infobox_game_custom.lua

Co-authored-by: hjpalpha <[email protected]>

* Update components/infobox/wikis/esports/infobox_game_custom.lua

Co-authored-by: hjpalpha <[email protected]>

---------

Co-authored-by: hjpalpha <[email protected]>
Co-authored-by: Cameron <[email protected]>
  • Loading branch information
3 people authored Jan 10, 2024
1 parent ed3505b commit f3cce73
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions components/infobox/wikis/esports/infobox_game_custom.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

---
-- @Liquipedia
-- wiki=esports
-- page=Module:Infobox/Game/Custom
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Array = require('Module:Array')
local Class = require('Module:Class')
local Lua = require('Module:Lua')

local Game = Lua.import('Module:Infobox/Game', {requireDevIfEnabled = true})

local Injector = Lua.import('Module:Infobox/Widget/Injector', {requireDevIfEnabled = true})

local Widgets = require('Module:Infobox/Widget/All')
local Cell = Widgets.Cell

---@class EsportsGameInfobox: GameInfobox
local CustomGame = Class.new(Game)
local CustomInjector = Class.new(Injector)

---@param frame Frame
---@return Html
function CustomGame.run(frame)
local game = CustomGame(frame)
game:setWidgetInjector(CustomInjector(game))

return game:createInfobox()
end

---@param id string
---@param widgets Widget[]
---@return Widget[]
function CustomInjector:addCustomCells(id, widgets)
local args = self.caller.args
if id == 'custom' then
Array.append(widgets,
Cell{name = 'Engine', content = {args.engine}},
Cell{name = 'Genre(s)', content = {args.genre}},
Cell{name = 'Mode(s)', content = {args.mode}}
)
end

return widgets
end

---@param lpdbData table
---@param args table
---@return table
function CustomGame:addToLpdb(lpdbData, args)
lpdbData.extradata.engine = args.engine
lpdbData.extradata.genre = args.genre
lpdbData.extradata.mode = args.mode

return lpdbData
end

return CustomGame

0 comments on commit f3cce73

Please sign in to comment.