Skip to content

Commit 5608193

Browse files
Don't drop below zero when calculating glory
Doesn't really matter anymore since this feature is likely dead under the new Glory system but we were showing negative glory values for players at zero glory (season just reset). This was definitely a bad bug for players using the app without any comp history yet because even when they weren't seeing negative values, they were potentially still getting values lower than what they would actually receive in-game. Which sucks. Profiles without any Glory is an obvious test condition that I shouldn't have missed. Blargh.
1 parent 141d119 commit 5608193

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Fabled/Model/Profile.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public extension Profile {
170170

171171
while matches < GloryRank.WeeklyMatchCompletionThreshold {
172172
matches += 1
173-
points -= rank.lossDeficit
173+
points = max(points - rank.lossDeficit, 0)
174174
rank = GloryRank(points: points)
175175
}
176176

Fabled/ModelTests/ProfileTests.swift

+5
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@ class ProfileTests: XCTestCase {
469469
XCTAssert(profile.pessimisticGloryAtNextWeeklyReset == expectedAmount)
470470
}
471471

472+
func testPessimisticGloryAtNextWeeklyResetDoesNotReturnNegativeValues() {
473+
let zeroGloryProfile = generateProfile(at: GloryRank(points: 0))
474+
XCTAssertGreaterThanOrEqual(zeroGloryProfile.pessimisticGloryAtNextWeeklyReset, 0)
475+
}
476+
472477
func testOptimisticGloryAtNextWeeklyResetReturnsExpectedAmountWithNoMatchesYetPlayed() {
473478
let rank = GloryRank.heroic(.III)
474479
let profile = generateProfile(at: rank, progressOffset: 200) //ensures no profile rank-down with losses

0 commit comments

Comments
 (0)