Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lua/spec/placement_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('placement', function()
it('check', function()
assert.is_nil(Placement.getBgClass{placement = 'DummyDummy'})
assert.are_equal('background-color-first-place', Placement.getBgClass{placement = 1})
assert.are_equal('bg-dq', Placement.getBgClass{placement = 'dq'})
assert.are_equal('background-color-dq-place', Placement.getBgClass{placement = 'dq'})
end)
end)

Expand Down
15 changes: 15 additions & 0 deletions lua/spec/prize_pool_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ describe('prize pool', function()
[2] = {usdprize = '130,000', playershare = '100,000', [1] = {'t1'}},
}

local specialPrizePoolArgs = {
type = {type = 'solo'},
import = false,
lpdb_storage = false,
cutafter = 7,
[1] = {dq = true},
[2] = {dnp = true},
[3] = {dnf = true},
[4] = {w = true},
[5] = {d = true},
[6] = {l = true},
[7] = {q = true},
}

it('parameters are correctly parsed', function()
local ppt = PrizePool(prizePoolArgs):create()

Expand Down Expand Up @@ -199,6 +213,7 @@ describe('prize pool', function()
GoldenTest('prize_pool', tostring(PrizePool(prizePoolArgs):create():build()))
local clubShareNoStore = Table.merge(clubSharePoolArgs, {storelpdb = false})
GoldenTest('prize_pool_club_share', tostring(PrizePool(clubShareNoStore):create():build()))
GoldenTest('prize_pool_special_placements', tostring(PrizePool(specialPrizePoolArgs):create():build()))
end)

it('lpdb storage', function()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions lua/wikis/commons/Placement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ local PLACEMENT_CLASSES = {
['q'] = 'placement-win',
['w'] = 'placement-win',
['l'] = 'placement-lose',
['dq'] = 'placement-lose',
['dq'] = 'placement-disqualified',
['dnf'] = 'placement-dnp',
['dns'] = 'placement-dnp',
['dnpq'] = 'placement-dnp',
Expand Down Expand Up @@ -88,16 +88,16 @@ local prizepoolClasses = {
'background-color-first-place',
'background-color-second-place',
'background-color-third-place',
w = 'bg-win',
q = 'bg-win',
l = 'bg-lose',
dq = 'bg-dq',
dnq = 'bg-dq',
dns = 'bg-dq',
dnf = 'bg-dq',
dnp = 'bg-dq',
dnpq = 'bg-dq',
nc = 'bg-dq',
w = 'background-color-win-place',
q = 'background-color-win-place',
l = 'background-color-lose-place',
dq = 'background-color-dq-place',
dnq = 'background-color-dq-place',
dns = 'background-color-dq-place',
dnf = 'background-color-dq-place',
dnp = 'background-color-dq-place',
dnpq = 'background-color-dq-place',
nc = 'background-color-dq-place',
}

local USE_BLACK_TEXT = {
Expand Down Expand Up @@ -203,7 +203,7 @@ end

---Takes string place value and returns prize pool color class.
---May return `nil` if no color is registered.
---@param args {placement: string|number}
---@param args {placement: string|number?}
---@return string?
function Placement.getBgClass(args)
return prizepoolClasses[args.placement]
Expand Down
41 changes: 13 additions & 28 deletions lua/wikis/commons/PrizePool/Placement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

local Lua = require('Module:Lua')

local Abbreviation = Lua.import('Module:Abbreviation')
local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local Logic = Lua.import('Module:Logic')
local Medals = Lua.import('Module:Medals')
local PlacementInfo = Lua.import('Module:Placement')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
Expand Down Expand Up @@ -49,7 +47,7 @@ Placement.specialStatuses = {
return Logic.readBool(args.dq)
end,
display = function ()
return Abbreviation.make{text = 'DQ', title = 'Disqualified'}
return 'DQ'
end,
lpdb = 'DQ',
},
Expand All @@ -58,7 +56,7 @@ Placement.specialStatuses = {
return Logic.readBool(args.dnf)
end,
display = function ()
return Abbreviation.make{text = 'DNF', title = 'Did not finish'}
return 'DNF'
end,
lpdb = 'DNF',
},
Expand All @@ -67,7 +65,7 @@ Placement.specialStatuses = {
return Logic.readBool(args.dnp)
end,
display = function ()
return Abbreviation.make{text = 'DNP', title = 'Did not participate'}
return 'DNP'
end,
lpdb = 'DNP',
},
Expand Down Expand Up @@ -103,7 +101,7 @@ Placement.specialStatuses = {
return Logic.readBool(args.q)
end,
display = function ()
return Abbreviation.make{text = 'Q', title = 'Qualified Automatically'}
return 'Q'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, there seems to be only ~10-15 pages using this (on CS). Maybe we can talk to them to get rid of it.
Search queries: hastemplate:Slot insource:"q=true" and hastemplate:prize_pool_slot insource:"place=q"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> #7824

@PiddyNydra any opinions? The usage seems to be kindof weird, see https://liquipedia.net/counterstrike/Circuito_Retake/Season_7/Points for example. They are placed in the rankings table as 1,2,3, but then they get place Q, and the 4th gets place 1 in the prizepool.

end,
lpdb = 'Q',
},
Expand Down Expand Up @@ -327,40 +325,27 @@ end

---@return string?
function Placement:getBackground()
for statusName, status in pairs(Placement.specialStatuses) do
if status.active(self.args) then
return PlacementInfo.getBgClass{placement = statusName:lower()}
end
end

return PlacementInfo.getBgClass{placement = self.placeStart}
return PlacementInfo.getBgClass{placement = self:getSpecialStatus() or self.placeStart}
end

---Returns the placement-badge color class for top-3 placements, else nil.
---Colored by the top of the range (placeStart).
---@return string?
function Placement:getBadgeClass()
if self:hasSpecialStatus() or self.placeStart > 3 then
local specialStatus = self:getSpecialStatus()
if (not specialStatus) and self.placeStart > 3 then
return nil
end
return PlacementInfo.raw(self.placeStart).backgroundClass
return PlacementInfo.raw(specialStatus or self.placeStart).backgroundClass
end

---@return string?
function Placement:getMedal()
if self:hasSpecialStatus() then
return
end

local medal = Medals.display{medal = self:_lpdbValue()}
if medal then
return tostring(medal)
function Placement:getSpecialStatus()
for statusName, status in pairs(Placement.specialStatuses) do
if status.active(self.args) then
return statusName:lower()
end
end
end

---@return boolean
function Placement:hasSpecialStatus()
return Table.any(Placement.specialStatuses, function(_, status) return status.active(self.args) end)
end

return Placement
42 changes: 29 additions & 13 deletions stylesheets/commons/Prizepooltable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,28 @@ so they must stay defined even though the redesigned table no longer uses them.
--prizepool-place-2-accent: var( --clr-semantic-silver-40 );
--prizepool-place-3-accent: var( --clr-semantic-bronze-40 );

--prizepool-place-w-accent: var( --position-up-color );
--prizepool-place-l-accent: var( --position-down-color );
--prizepool-place-dq-accent: var( --position-disqualified-color );

// Faint full-row tint per place (light theme; dark overrides in `.theme--dark`).
--prizepool-place-1-tint: #f7f2d9;
--prizepool-place-2-tint: #e6eaeb;
--prizepool-place-3-tint: #eceae4;

--prizepool-place-w-tint: var( --position-up-background-color );
--prizepool-place-l-tint: var( --position-down-background-color );
--prizepool-place-dq-tint: var( --position-disqualified-background-color );

// Hover tint derived from the row tint. hsl( from … ) is safe here — `:hover` is
// never captured by the exporter, so this value never reaches html2canvas.
--prizepool-place-1-tint-hover: hsl( from var( --prizepool-place-1-tint ) h s calc( l * 0.9 ) );
--prizepool-place-2-tint-hover: hsl( from var( --prizepool-place-2-tint ) h s calc( l * 0.9 ) );
--prizepool-place-3-tint-hover: hsl( from var( --prizepool-place-3-tint ) h s calc( l * 0.9 ) );

--prizepool-place-w-tint-hover: hsl( from var( --prizepool-place-w-tint ) h s calc( l * 0.9 ) );
--prizepool-place-l-tint-hover: hsl( from var( --prizepool-place-l-tint ) h s calc( l * 0.9 ) );
--prizepool-place-dq-tint-hover: hsl( from var( --prizepool-place-dq-tint ) h s calc( l * 0.9 ) );
}

.theme--light {
Expand Down Expand Up @@ -61,6 +73,10 @@ so they must stay defined even though the redesigned table no longer uses them.
--prizepool-place-1-tint-hover: hsl( from var( --prizepool-place-1-tint ) h s calc( l * 1.25 ) );
--prizepool-place-2-tint-hover: hsl( from var( --prizepool-place-2-tint ) h s calc( l * 1.25 ) );
--prizepool-place-3-tint-hover: hsl( from var( --prizepool-place-3-tint ) h s calc( l * 1.25 ) );

--prizepool-place-w-tint-hover: hsl( from var( --prizepool-place-w-tint ) h s calc( l * 1.25 ) );
--prizepool-place-l-tint-hover: hsl( from var( --prizepool-place-l-tint ) h s calc( l * 1.25 ) );
--prizepool-place-dq-tint-hover: hsl( from var( --prizepool-place-dq-tint ) h s calc( l * 1.25 ) );
}

/*******************************************************************************
Expand Down Expand Up @@ -345,6 +361,18 @@ share the `prizepooltable` class.
&.placement-3 {
background-color: var( --prizepool-place-3-accent );
}

&.placement-win {
background-color: var( --prizepool-place-w-accent );
}

&.placement-lose {
background-color: var( --prizepool-place-l-accent );
}

&.placement-disqualified {
background-color: var( --prizepool-place-dq-accent );
}
}

&.prizepooltable-placement {
Expand All @@ -368,7 +396,7 @@ share the `prizepooltable` class.
// `border-bottom: 0` drops the legacy per-place coloured row border. The hover tint
// re-applies on `table2__row--group-hover` (added by Table2.js to every row in a
// hovered group) since the base tint above out-specifies the generic group-hover rule.
$prizepool-top-placements: ( first: 1, second: 2, third: 3 );
$prizepool-top-placements: ( first: 1, second: 2, third: 3, win: w, lose: l, dq: dq );

@each $name, $n in $prizepool-top-placements {
tr.table2__row--body.background-color-#{ $name }-place {
Expand All @@ -394,18 +422,6 @@ share the `prizepooltable` class.
}
}
}

tr.table2__row--body.bg-win .prizepooltable-place {
background-color: var( --clr-forest-background-color, inherit );
}

tr.table2__row--body.bg-lose .prizepooltable-place {
background-color: var( --clr-cinnabar-background-color, inherit );
}

tr.table2__row--body.bg-dq .prizepooltable-place {
background-color: var( --clr-sapphire-background-color, inherit );
}
}

// Currency toggle: pill stacked above the card.
Expand Down