Skip to content

Commit

Permalink
more wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Oct 17, 2024
1 parent 3649bbb commit 2014487
Show file tree
Hide file tree
Showing 9 changed files with 418 additions and 186 deletions.
17 changes: 4 additions & 13 deletions components/match2/wikis/dota2/match_page.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ local Operator = require('Module:Operator')
local String = require('Module:StringUtils')
local Table = require('Module:Table')
local Tabs = require('Module:Tabs')
local TemplateEngine = require('Module:TemplateEngine')
local VodLink = require('Module:VodLink')

local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local MatchGroupUtil = Lua.import('Module:MatchGroup/Util')
local Display = Lua.import('Module:MatchPage/Template')

local HtmlWidgets = Lua.import('Module:Widget/Html/All')
local Div = HtmlWidgets.Div
Expand Down Expand Up @@ -61,13 +59,6 @@ function MatchPage.getByMatchId(props)
---@field opponents Dota2MatchPageViewModelOpponent[]
local viewModel = props.match

local function makeItemDisplay(item)
if String.isEmpty(item.name) then
return '[[File:EmptyIcon itemicon dota2 gameasset.png|64px|Empty|link=]]'
end
return '[[File:'.. item.image ..'|64px|'.. item.name ..'|link=]]'
end

-- Update the view model with game and team data
Array.forEach(viewModel.games, function(game)
game.finished = game.winner ~= nil and game.winner ~= -1
Expand All @@ -81,9 +72,9 @@ function MatchPage.getByMatchId(props)
local newPlayer = Table.mergeInto(player, {
displayName = player.name or player.player,
link = player.player,
items = Array.map(player.items or {}, makeItemDisplay),
backpackitems = Array.map(player.backpackitems or {}, makeItemDisplay),
neutralitem = makeItemDisplay(player.neutralitem or {}),
items = player.items or {},
backpackitems = player.backpackitems or {},
neutralitem = player.neutralitem or {},
})

newPlayer.displayDamageDone = MatchPage._abbreviateNumber(player.damagedone)
Expand Down Expand Up @@ -217,7 +208,7 @@ function MatchPage.games(model)
local games = Array.map(Array.filter(model.games, function(game)
return game.resultType ~= NOT_PLAYED
end), function(game)
return tostring(MatchPageWidgets.game(game)) .. TemplateEngine():render(Display.game, Table.merge(model, game))
return tostring(MatchPageWidgets.game(game))
end)

if #games < 2 then
Expand Down
129 changes: 0 additions & 129 deletions components/match2/wikis/dota2/match_page_template.lua

This file was deleted.

53 changes: 9 additions & 44 deletions components/widget/match/page/widget_match_page_game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,28 @@
-- 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 Widget = Lua.import('Module:Widget')
local HtmlWidgets = Lua.import('Module:Widget/Html/All')
local Div = HtmlWidgets.Div
local Link = Lua.import('Module:Widget/Basic/Link')
local HeaderOpponent = Lua.import('Module:Widget/Match/Page/Header/Opponent')
local Fragment = HtmlWidgets.Fragment
local MatchPageGameDraft = Lua.import('Module:Widget/Match/Page/Game/Draft')
local MatchPageGameStats = Lua.import('Module:Widget/Match/Page/Game/Stats')
local MatchPageGamePlayers = Lua.import('Module:Widget/Match/Page/Game/Players')

---@class MatchPageGame: Widget
---@operator call(table): MatchPageGame
local MatchPageGame = Class.new(Widget)

---@return Widget
function MatchPageGame:render()
return Div{
classes = {'match-bm-lol-match-header'},
return Fragment{
children = {
Div{
classes = {'match-bm-match-header-powered-by'},
children = {'[[File:DataProvidedSAP.svg|link=]]'},
},
Div{
classes = {'match-bm-lol-match-header-overview'},
children = {
HeaderOpponent{self.props.opponents[1]},
Div{
classes = {'match-bm-match-header-result'},
children = {
self.props.opponents[1].score,
'&ndash;',
self.props.opponents[2].score,
Div{
classes = {'match-bm-match-header-result-text'},
children = {self.props.matchPhase},
},
},
},
HeaderOpponent{self.props.opponents[2]},
},
},
Div{
classes = {'match-bm-lol-match-header-tournament'},
children = {Link{link = self.props.parent, children = self.props.tournament}},
},
Div{
classes = {'match-bm-lol-match-header-date'},
children = {self.props.dateCountdown},
},
Div{
classes = {'match-bm-lol-match-mvp'},
children = {'<b>MVP</b>', Array.map(self.props.mvp.players, function(player)
return Link{link = player.name, children = player.displayname}
end)},
},
},
MatchPageGameDraft{},
MatchPageGameStats{},
MatchPageGamePlayers{},
}
}
end

Expand Down
99 changes: 99 additions & 0 deletions components/widget/match/page/widget_match_page_game_player.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
-- @Liquipedia
-- wiki=commons
-- page=Module:Widget/Match/Page/Game/Player
--
-- 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 Widget = Lua.import('Module:Widget')
local HtmlWidgets = Lua.import('Module:Widget/Html/All')
local Div = HtmlWidgets.Div
local MatchPageHeaderGamePlayerStat = Lua.import('Module:Widget/Match/Page/Game/Player/Stat')
local MatchPageHeaderGamePlayerItem = Lua.import('Module:Widget/Match/Page/Game/Player/Item')
local Link = Lua.import('Module:Widget/Basic/Link')

---@class MatchPageHeaderGamePlayer: Widget
---@operator call(table): MatchPageHeaderGamePlayer
local MatchPageHeaderGamePlayer = Class.new(Widget)

---@return Widget
function MatchPageHeaderGamePlayer:render()
return Div{
classes = {'match-bm-players-player'},
children = {
Div{
classes = {'match-bm-players-player-character'},
children = {
Div{
classes = {'match-bm-players-player-avatar'},
children = {
Div{classes = {'match-bm-players-player-icon'}, children = self.props.heroIcon},
Div{classes = {'match-bm-players-player-role', 'role--' .. self.props.teams[1].side}, children = {'[[File:Dota2 {{facet}} facet icon darkmode.png|link=|{{facet}}]]'}},
},
},
Div{classes = {'match-bm-players-player-name'}, children = {
Link{link = self.props.link, children = self.props.displayName},
'<i>' .. self.props.character .. '</i>',
}},
},
},
Div{
classes = {'match-bm-players-player-loadout'},
children = {
Div{
classes = {'match-bm-players-player-loadout-items'},
children = {
Div{classes = {'match-bm-players-player-loadout-item'}, children = Array.map(self.props.items, MatchPageHeaderGamePlayerItem)},
Div{classes = {'match-bm-players-player-loadout-item item--backpack'}, children = Array.map(self.props.backpackitems, MatchPageHeaderGamePlayerItem)},
},
},
Div{
classes = {'match-bm-players-player-loadout-rs-wrap'},
children = {
Div{classes = {'match-bm-players-player-loadout-rs'}, children = MatchPageHeaderGamePlayerItem(self.props.neutralitem)},
Div{classes = {'match-bm-players-player-loadout-rs'}, children = self.props.shard and MatchPageHeaderGamePlayerItem{name = 'Aghanim\'s Shard', image = 'Dota2_Aghanim\'s_Shard_symbol_allmode.png'}},
Div{classes = {'match-bm-players-player-loadout-rs'}, children = self.props.scepter and MatchPageHeaderGamePlayerItem{name = 'Aghanim\'s Scepter', image = 'Dota2_Aghanim\'s_Scepter_symbol_allmode.png'}},
},
},
},
},
Div{
classes = {'match-bm-players-player-stats'},
children = {
MatchPageHeaderGamePlayerStat{
icon = '<i class="fas fa-skull-crossbones"></i>',
title = 'KDA',
children = self.props.kills .. '<span class="slash">/</span>' .. self.props.deaths .. '<span class="slash">/</span>' .. self.props.assists
},
MatchPageHeaderGamePlayerStat{
icon = '<i class="fas fa-sword"></i>',
title = 'DMG',
children = self.props.displayDamageDone
},
MatchPageHeaderGamePlayerStat{
icon = '<i class="fas fa-swords"></i>',
title = 'LH/DN',
children = self.props.lasthits .. '<span class="slash">/</span>' .. self.props.denies
},
MatchPageHeaderGamePlayerStat{
icon = '<i class="fas fa-coin"></i>',
title = 'NET',
children = self.props.displayGold
},
MatchPageHeaderGamePlayerStat{
icon = '<i class="fas fa-coins"></i>',
title = 'GPM',
children = self.props.gpm
},
}
}
}
}
end

return MatchPageHeaderGamePlayer
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
-- @Liquipedia
-- wiki=commons
-- page=Module:Widget/Match/Page/Game/Item
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

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

local Widget = Lua.import('Module:Widget')

---@class MatchPageHeaderGameItem: Widget
---@operator call(table): MatchPageHeaderGameItem
local MatchPageHeaderGameItem = Class.new(Widget)

---@return string
function MatchPageHeaderGameItem:render()
if Logic.isEmpty(self.props.name) then
return '[[File:EmptyIcon itemicon dota2 gameasset.png|64px|Empty|link=]]'
end
return '[[File:'.. self.props.image ..'|64px|'.. self.props.name ..'|link=]]'
end

return MatchPageHeaderGameItem
Loading

0 comments on commit 2014487

Please sign in to comment.