Skip to content

Commit

Permalink
Fix ZeroDivisionError in TimedDrop.availability
Browse files Browse the repository at this point in the history
  • Loading branch information
DevilXD committed Sep 25, 2024
1 parent d333c86 commit 93d5d87
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,10 @@ def progress(self) -> float:

@property
def availability(self) -> float:
if not self._base_can_earn():
# this verifies "self.total_remaining_minutes > 0" and "now < self.ends_at"
return math.inf
now = datetime.now(timezone.utc)
return ((self.ends_at - now).total_seconds() / 60) / self.total_remaining_minutes
if self.required_minutes > 0 and self.total_remaining_minutes > 0 and now < self.ends_at:
return ((self.ends_at - now).total_seconds() / 60) / self.total_remaining_minutes
return math.inf

def _base_earn_conditions(self) -> bool:
return super()._base_earn_conditions() and self.required_minutes > 0
Expand Down

0 comments on commit 93d5d87

Please sign in to comment.