Skip to content
Merged
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
18 changes: 14 additions & 4 deletions lua/wikis/leagueoflegends/PrizePool/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local Arguments = Lua.import('Module:Arguments')
local Class = Lua.import('Module:Class')
local Logic = Lua.import('Module:Logic')
local Variables = Lua.import('Module:Variables')
local HighlightConditions = Lua.import('Module:HighlightConditions')

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

Expand All @@ -20,6 +21,7 @@ local CustomLpdbInjector = Class.new(LpdbInjector)
local CustomPrizePool = {}

local TIER_VALUE = {8, 4, 2}
local TIER_TYPE_MODIFIER = {Showmatch = 0, Qualifier = 0.25, Monthly = 0.4, Weekly = 0.1}

-- Template entry point
---@param frame Frame
Expand All @@ -39,10 +41,13 @@ end
---@param opponent BasePlacementOpponent
---@return placement
function CustomLpdbInjector:adjust(lpdbData, placement, opponent)
lpdbData.publishertier = Variables.varDefault('tournament_publishertier', '')
lpdbData.weight = CustomPrizePool.calculateWeight(
lpdbData.prizemoney,
Variables.varDefault('tournament_liquipediatier'),
placement.placeStart
placement.placeStart,
Variables.varDefault('tournament_liquipediatiertype'),
HighlightConditions.tournament(lpdbData)
Comment thread
ElectricalBoy marked this conversation as resolved.
)

local team = lpdbData.participant or ''
Expand All @@ -60,15 +65,20 @@ end
---@param prizeMoney number
---@param tier string?
---@param place integer
---@return integer
function CustomPrizePool.calculateWeight(prizeMoney, tier, place)
---@param tierType string?
---@param isHighlighted boolean
---@return number
function CustomPrizePool.calculateWeight(prizeMoney, tier, place, tierType, isHighlighted)
if Logic.isEmpty(tier) then
return 0
end

local tierValue = TIER_VALUE[tier] or TIER_VALUE[tonumber(tier) or ''] or 1
local prizeFactor = (1000000 + prizeMoney) / 1000000
local tierTypeFactor = TIER_TYPE_MODIFIER[tierType] or 1
local highlightedFactor = isHighlighted and 2 or 1

return tierValue * math.max(prizeMoney, 1) / place
return prizeFactor * tierValue * tierTypeFactor * highlightedFactor / place
end

return CustomPrizePool
Loading