Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(standard): one import for most of the standard lib #4504

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions components/team_card/team_card_storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--
local Standard = require('Module:Standard')
local Opponent = Standard.Opponent
local Variables = Standard.Variables

local Json = require('Module:Json')
local Lua = require('Module:Lua')
local String = require('Module:StringUtils')
local Table = require('Module:Table')
local Variables = require('Module:Variables')

local Custom = Lua.import('Module:TeamCard/Custom')

local OpponentLibrary = require('Module:OpponentLibraries')
local Opponent = OpponentLibrary.Opponent
local Custom = Standard.Lua.import('Module:TeamCard/Custom')

local TeamCardStorage = {}

Expand Down Expand Up @@ -48,16 +42,16 @@ function TeamCardStorage.saveToLpdb(args, teamObject, players, playerPrize)
lpdbData = Custom.adjustLpdb and Custom.adjustLpdb(lpdbData, team, args, lpdbPrefix) or lpdbData

-- Store aliases (page names) for opponenets for setting page vars
if Table.isNotEmpty(teamObject.aliases) then
if Standard.Table.isNotEmpty(teamObject.aliases) then
Rathoz marked this conversation as resolved.
Show resolved Hide resolved
lpdbData.extradata.opponentaliases = teamObject.aliases
end

-- Store into the standardized lpdb fields
lpdbData = Table.mergeInto(lpdbData, Opponent.toLpdbStruct(Opponent.resolve(
lpdbData = Standard.Table.mergeInto(lpdbData, Opponent.toLpdbStruct(Opponent.resolve(
Opponent.readOpponentArgs{type = Opponent.team, template = teamTemplateName} or Opponent.tbd(Opponent.team),
lpdbData.date
)))
lpdbData = Json.stringifySubTables(lpdbData)
lpdbData = Standard.Json.stringifySubTables(lpdbData)
lpdbData.opponentplayers = lpdbData.players -- Until this is included in Opponent

mw.ext.LiquipediaDB.lpdb_placement(lpdbData.objectName, lpdbData)
Expand Down Expand Up @@ -112,7 +106,7 @@ end
---@return string
function TeamCardStorage._getLpdbObjectName(team, lpdbPrefix)
local storageName = (team == 'TBD' and 'participant') or 'ranking'
if String.isNotEmpty(lpdbPrefix) then
if Standard.String.isNotEmpty(lpdbPrefix) then
storageName = storageName .. '_' .. lpdbPrefix
end
storageName = storageName .. '_' .. mw.ustring.lower(team)
Expand Down Expand Up @@ -163,5 +157,4 @@ function TeamCardStorage._parseQualifier(rawQualifier)
end
end


return TeamCardStorage
34 changes: 34 additions & 0 deletions standard/standard.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
-- @Liquipedia
-- wiki=commons
-- page=Module:Standard
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Lua = require('Module:Lua')
local OpponentLibrary = Lua.import('Module:OpponentLibraries')

return {
Array = Lua.import('Module:Array'),
Class = Lua.import('Module:Class'),
Condition = Lua.import('Module:Condition'),
DateExt = Lua.import('Module:Date/Ext'),
Game = Lua.import('Module:Game'),
Rathoz marked this conversation as resolved.
Show resolved Hide resolved
I18n = Lua.import('Module:I18n'),
Icon = Lua.import('Module:Icon'),
Image = Lua.import('Module:Image'),
Rathoz marked this conversation as resolved.
Show resolved Hide resolved
Info = Lua.import('Module:Info'),
Json = Lua.import('Module:Json'),
Logic = Lua.import('Module:Logic'),
Lpdb = Lua.import('Module:Lpdb'),
Lua = Lua,
Operator = Lua.import('Module:Operator'),
Opponent = OpponentLibrary.Opponent,
OpponentDisplay = OpponentLibrary.OpponentDisplay,
Rathoz marked this conversation as resolved.
Show resolved Hide resolved
Page = Lua.import('Module:Page'),
String = Lua.import('Module:StringUtils'),
Table = Lua.import('Module:Table'),
Tier = Lua.import('Module:Tier'),
Rathoz marked this conversation as resolved.
Show resolved Hide resolved
Variables = Lua.import('Module:Variables'),
}
Loading