File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -159,9 +159,22 @@ export async function calculateNewMMR(
159159 const mmrChange = isWinner ? ratingChange : - ratingChange / loserCount
160160
161161 for ( const player of ts . team . players ) {
162- const oldMMR = player . elo ?? queueSettings . default_elo
162+ // If this match was already processed, revert the previous MMR change
163+ // to get the pre-match MMR before applying the new change
164+ let currentMMR = player . elo ?? queueSettings . default_elo
165+ const previousEloChange = player . elo_change ?? 0
166+ const isRecalculation = previousEloChange !== 0
167+
168+ // Revert previous MMR change if it exists
169+ const oldMMR = currentMMR - previousEloChange
170+
163171 const oldRank = await getLeaderboardPosition ( queueId , player . user_id )
164- const oldVolatility = player . volatility ?? 0
172+ const currentVolatility = player . volatility ?? 0
173+
174+ // Only increment volatility if this is the first time processing this match
175+ const oldVolatility = isRecalculation
176+ ? currentVolatility - 1
177+ : currentVolatility
165178
166179 const newMMR = parseFloat ( ( oldMMR + mmrChange ) . toFixed ( 1 ) )
167180 const newVolatility = Math . min ( oldVolatility + 1 , 10 )
You can’t perform that action at this time.
0 commit comments