# HG changeset patch # User Laman # Date 2021-10-20 11:50:32 # Node ID 2a3c04d4730009a3f52c27444f0ca6bda82fa0d6 # Parent 068be3e00177908fba5796cddc750df530834cfa limited promotion when pushing the personal best diff --git a/rank_progress.py b/rank_progress.py --- a/rank_progress.py +++ b/rank_progress.py @@ -36,6 +36,7 @@ class RankTracker: def __init__(self, rating): assert rating >= -900 self._rounded_rating = round_rating(rating) + self._best = self._rounded_rating @property def rank(self): @@ -53,15 +54,22 @@ class RankTracker: if rounded_rating == self._rounded_rating: pass elif rounded_rating > self._rounded_rating: # promotion - self._rounded_rating = rounded_rating + # when pushing the best by 2 and more ranks you have to cross the hundred, not just the fifty + if rounded_rating >= self._best+200 and rating < rounded_rating: + self._rounded_rating = rounded_rating-100 + else: + self._rounded_rating = rounded_rating else: # demotion + # 100 points for 5k and better if self._rounded_rating >= 1600 and self._rounded_rating - rating > 100: self._rounded_rating = rounded_rating + # 150 points for the others elif self._rounded_rating - rating > 150: self._rounded_rating = rounded_rating+100 else: pass + self._best = max(self._best, self._rounded_rating) new_rank = self.rank return new_rank if new_rank != old_rank else False diff --git a/test.py b/test.py --- a/test.py +++ b/test.py @@ -18,7 +18,7 @@ class TestRankTracker(TestCase): # 2+ ranks leaps # limited when pushing the personal best - self.skipTest("not yet implemented") + # self.skipTest("not yet implemented") t = RankTracker(1100) self.assertEqual(t.update(1299), "9k") self.assertEqual(t.update(1250), "8k")