Skip to content

Commit

Permalink
Try to be better about keeping ratings sane
Browse files Browse the repository at this point in the history
  • Loading branch information
mbattersby committed Nov 28, 2023
1 parent 800381d commit e3c62da
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions LiteKeystone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ function LiteKeystone:UpdateWeekly(playerName, weekBest)
end
end

function LiteKeystone:ReceiveKey(newKey, action, isUnreliable)
function LiteKeystone:ReceiveKey(newKey, action)
local existingKey = self.db.playerKeys[newKey.playerName]

-- Don't accept our own keys back from other people
Expand All @@ -481,33 +481,21 @@ function LiteKeystone:ReceiveKey(newKey, action, isUnreliable)
return
end

-- Third party reports are unreliable, try to make sure we don't
-- overwrite better info.

if isUnreliable then
newKey.weekBest = math.max(existingKey.weekBest or 0, newKey.weekBest or 0)
if newKey.rating then
newKey.rating = math.max(existingKey.rating or 0, newKey.rating or 0)
end
if existingKey and existingKey.weekTime >= newKey.weekTime then
return
end

if not self:IsNewKey(existingKey, newKey) then
return
if existingKey then
newKey.weekBest = math.max(existingKey.weekBest or 0, newKey.weekBest or 0)
newKey.rating = math.max(existingKey.rating or 0, newKey.rating or 0)
end

if existingKey and newKey.weekTime <= existingKey.weekTime then
existingKey.weekBest = math.max(existingKey.weekBest, newKey.weekBest)
if newKey.rating then
existingKey.rating = math.max(existingKey.rating or 0, newKey.rating)
end
self:Fire()
return
if self:IsNewKey(existingKey, newKey) then
debug('%s via %s: %s %s', newKey.source, action, newKey.playerName, newKey.link)
end

self.db.playerKeys[newKey.playerName] = newKey

debug('Got key from %s via %s: %s %s', newKey.source, action, newKey.playerName, newKey.link)

self:Fire()

return true
Expand Down

0 comments on commit e3c62da

Please sign in to comment.