refactor: use better algo for determining highest
This commit is contained in:
@@ -34,16 +34,16 @@ class FirstGuess(Scoring):
|
|||||||
|
|
||||||
class HighestAmount(Scoring):
|
class HighestAmount(Scoring):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.shares: set[ItemShare] = set()
|
self.max: ItemShare | None = None
|
||||||
|
|
||||||
def calculate_score(self, item: ItemShare) -> int:
|
def calculate_score(self, item: ItemShare) -> int:
|
||||||
self.shares.add(item)
|
if self.max is None or item.count > self.max.count:
|
||||||
|
self.max = item
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def calculate_end_score(self) -> ItemShare | None:
|
def calculate_end_score(self) -> ItemShare | None:
|
||||||
highest = max(self.shares, key=lambda s: s.count)
|
self.max.score = 1
|
||||||
highest.score = 1
|
return self.max
|
||||||
return highest
|
|
||||||
|
|
||||||
|
|
||||||
class FirstThenHighest(Scoring):
|
class FirstThenHighest(Scoring):
|
||||||
|
|||||||
Reference in New Issue
Block a user