Streamline and improve the active drop search process
This commit is contained in:
1 parent
ddf5113810
commit
bceb49b23a
2 files changed
+52
-39
No files matched your search
+8
-5
@@ -156,8 +156,11 @@ class DropsCampaign:
|
||||
def get_drop(self, drop_id: str) -> Optional[TimedDrop]:
|
||||
return self.timed_drops.get(drop_id)
|
||||
|
||||
def get_active_drop(self) -> Optional[TimedDrop]:
|
||||
for drop in self.timed_drops.values():
|
||||
if drop.can_earn:
|
||||
return drop
|
||||
return None
|
||||
def get_active_drop(self) -> TimedDrop:
|
||||
if not self.active:
|
||||
raise RuntimeError("You can't call this for an unactive campaign")
|
||||
drops = sorted(
|
||||
(drop for drop in self.timed_drops.values() if drop.can_earn),
|
||||
key=lambda d: d.remaining_minutes,
|
||||
)
|
||||
return drops[0]
|
||||
Reference in new issue
Block a user