-
Notifications
You must be signed in to change notification settings - Fork 104
feat(PrizePool): add playerShare & clubShare support. #7284
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
base: main
Are you sure you want to change the base?
Changes from all commits
5761d96
dd5da0f
c4861c6
3537a31
f6aca54
e58b61c
55896e3
8b480b3
69c0c0d
312fe20
a1f69c4
a596874
652a6b8
65fb79b
317736e
d4f3d71
5f94b42
5b914eb
7009493
218d90a
c536845
8fa7212
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,8 @@ local PRIZE_TYPE_QUALIFIES = 'QUALIFIES' | |
| local PRIZE_TYPE_POINTS = 'POINTS' | ||
| local PRIZE_TYPE_PERCENTAGE = 'PERCENT' | ||
| local PRIZE_TYPE_FREETEXT = 'FREETEXT' | ||
| local PRIZE_TYPE_PLAYER_SHARE = 'PLAYER_SHARE' | ||
| local PRIZE_TYPE_CLUB_SHARE = 'CLUB_SHARE' | ||
|
|
||
| BasePrizePool.config = { | ||
| showBaseCurrency = { | ||
|
|
@@ -357,9 +359,55 @@ BasePrizePool.prizeTypes = { | |
| end | ||
| end, | ||
| }, | ||
| [PRIZE_TYPE_FREETEXT] = { | ||
| [PRIZE_TYPE_PLAYER_SHARE] = { | ||
| sortOrder = 60, | ||
|
|
||
| header = 'playershare', | ||
| headerParse = function (prizePool, input, context, index) | ||
| return {title = 'Player Share'} | ||
| end, | ||
| headerDisplay = function (data) | ||
| return TableCell{children = {data.title}} | ||
| end, | ||
|
|
||
| row = 'playershare', | ||
| rowParse = function (placement, input, context, index) | ||
| return BasePrizePool._parseInteger(input) | ||
| end, | ||
| rowDisplay = function (headerData, data) | ||
| if data > 0 then | ||
| return TableCell{children = { | ||
| Currency.display(BASE_CURRENCY, data, | ||
| {formatValue = true, formatPrecision = headerData.roundPrecision, displayCurrencyCode = false}) | ||
| }} | ||
| end | ||
| end, | ||
| }, | ||
| [PRIZE_TYPE_CLUB_SHARE] = { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know valve calls it club share, but this is for all wikis, so we should consider whether there's a better name for it.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dota2 is still Valve :D
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its not a term from Valve though. Originally it was ESL https://www.hltv.org/news/40576/club-financial-incentives-introduced-as-esl-reveals-more-ept-details and then other TO's followed suit. Maybe an arg to rename the header? but in current context all applciations of a club / team share are called club share across dota, cs. Its also the term used for Esports World Cup (still ESL eotd) for all titles, not just Valve |
||
| sortOrder = 70, | ||
| header = 'clubshare', | ||
| headerParse = function(prizePool, input, context, index) | ||
| return {title = String.isNotEmpty(input) and input or 'Club Share'} | ||
| end, | ||
| headerDisplay = function(data) | ||
| return TableCell{children = {data.title}} | ||
| end, | ||
| row = 'clubshare', | ||
| rowParse = function(placement, input, context, index) | ||
| return input | ||
| end, | ||
| rowDisplay = function(headerData, data) | ||
| if data and tonumber(data) > 0 then | ||
| return TableCell{children = { | ||
| Currency.display(BASE_CURRENCY, data, | ||
| {formatValue = true, formatPrecision = headerData.roundPrecision, displayCurrencyCode = false}) | ||
| }} | ||
| end | ||
| end, | ||
| }, | ||
| [PRIZE_TYPE_FREETEXT] = { | ||
| sortOrder = 80, | ||
|
|
||
| header = 'freetext', | ||
| headerParse = function (prizePool, input, context, index) | ||
| return {title = input} | ||
|
|
@@ -423,6 +471,22 @@ function BasePrizePool:create() | |
| self:setConfig('showBaseCurrency', true) | ||
| self:addPrize(PRIZE_TYPE_BASE_CURRENCY, 1, {roundPrecision = self.options.currencyRoundPrecision}) | ||
|
|
||
| local hasPlayerShare = Array.any(self.prizes, function(prize) | ||
| return prize.type == PRIZE_TYPE_PLAYER_SHARE | ||
| end) | ||
| if hasPlayerShare then | ||
MischiefCS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| local alreadyHasClubShare = Array.any(self.prizes, function(prize) | ||
| return prize.type == PRIZE_TYPE_CLUB_SHARE | ||
| end) | ||
| if not alreadyHasClubShare then | ||
| local clubShareTitle = self.args.clubshare | ||
| self:addPrize(PRIZE_TYPE_CLUB_SHARE, 1, { | ||
| title = String.isNotEmpty(clubShareTitle) and clubShareTitle or 'Club Share', | ||
| roundPrecision = self.options.currencyRoundPrecision | ||
| }) | ||
| end | ||
| end | ||
|
|
||
| if self.options.autoExchange then | ||
| local canConvertCurrency = function(prize) | ||
| return prize.type == PRIZE_TYPE_LOCAL_CURRENCY | ||
|
|
@@ -642,6 +706,26 @@ function BasePrizePool:_buildRows() | |
|
|
||
| self:applyToggleExpand(previousPlacement, placement, rows) | ||
|
|
||
| -- Calculate club share for the placement | ||
| Array.forEach(placement.opponents, function(opponent) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems out of place here. Probably move somewhere into PrizePool/Placement/Base.lua As an alternative, can require that via input as well. Not sure whether there could be an instance where player+club != total money (e.g. cause there are extras were no split is known)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldnt movement there not allow it to be visually displayed?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and player+club would always = total (from a Liquipedia stance) theoretically not all player may go to player, but thats how the rest of the wiki works
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Don't think so, iirc placements are parsed already
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Currently in CS that is the case, but again, this implementation affects all wikis, so I'm considering other (potential) cases as well. |
||
| local basePrize | ||
| local playerShare | ||
| Array.forEach(self.prizes, function(prize) | ||
| if prize.type == PRIZE_TYPE_BASE_CURRENCY then | ||
| basePrize = opponent.prizeRewards[prize.id] or placement.prizeRewards[prize.id] | ||
| return | ||
| end | ||
| if prize.type == PRIZE_TYPE_PLAYER_SHARE then | ||
| playerShare = opponent.prizeRewards[prize.id] or placement.prizeRewards[prize.id] | ||
| end | ||
| end) | ||
| if basePrize and playerShare then | ||
| local clubShare = tonumber(basePrize) - tonumber(playerShare) | ||
| if not opponent.prizeRewards then opponent.prizeRewards = {} end | ||
MischiefCS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| opponent.prizeRewards[PRIZE_TYPE_CLUB_SHARE .. '1'] = clubShare | ||
| end | ||
| end) | ||
|
|
||
| local cells = {} | ||
| table.insert(cells, self:placeOrAwardCell(placement)) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.