Fix an issue with TimedDrop.can_earn_within not ignoring sub-based drops
This commit is contained in:
1 parent
84d0dc1045
commit
c7b89cae2f
1 file changed
+12
-6
+12
-6
@@ -95,21 +95,27 @@ class BaseDrop:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _base_can_earn(self) -> bool:
|
def _base_earn_conditions(self) -> bool:
|
||||||
|
# define when a drop can be earned or not
|
||||||
return (
|
return (
|
||||||
self.preconditions_met # preconditions are met
|
self.preconditions_met # preconditions are met
|
||||||
and not self.is_claimed # isn't already claimed
|
and not self.is_claimed # isn't already claimed
|
||||||
|
)
|
||||||
|
|
||||||
|
def _base_can_earn(self) -> bool:
|
||||||
|
# cross-participates in can_earn and can_earn_within handling, where a timeframe is added
|
||||||
|
return (
|
||||||
|
self._base_earn_conditions()
|
||||||
# is within the timeframe
|
# is within the timeframe
|
||||||
and self.starts_at <= datetime.now(timezone.utc) < self.ends_at
|
and self.starts_at <= datetime.now(timezone.utc) < self.ends_at
|
||||||
)
|
)
|
||||||
|
|
||||||
def can_earn(self, channel: Channel | None = None) -> bool:
|
def can_earn(self, channel: Channel | None = None) -> bool:
|
||||||
return self.campaign._base_can_earn(channel) and self._base_can_earn()
|
return self._base_can_earn() and self.campaign._base_can_earn(channel)
|
||||||
|
|
||||||
def can_earn_within(self, stamp: datetime) -> bool:
|
def can_earn_within(self, stamp: datetime) -> bool:
|
||||||
return (
|
return (
|
||||||
self.preconditions_met # preconditions are met
|
self._base_earn_conditions()
|
||||||
and not self.is_claimed # isn't already claimed
|
|
||||||
and self.ends_at > datetime.now(timezone.utc)
|
and self.ends_at > datetime.now(timezone.utc)
|
||||||
and self.starts_at < stamp
|
and self.starts_at < stamp
|
||||||
)
|
)
|
||||||
@@ -226,8 +232,8 @@ class TimedDrop(BaseDrop):
|
|||||||
return 1.0
|
return 1.0
|
||||||
return self.current_minutes / self.required_minutes
|
return self.current_minutes / self.required_minutes
|
||||||
|
|
||||||
def _base_can_earn(self) -> bool:
|
def _base_earn_conditions(self) -> bool:
|
||||||
return self.required_minutes > 0 and super()._base_can_earn()
|
return super()._base_earn_conditions() and self.required_minutes > 0
|
||||||
|
|
||||||
def _on_claim(self) -> None:
|
def _on_claim(self) -> None:
|
||||||
result = super()._on_claim()
|
result = super()._on_claim()
|
||||||
|
|||||||
Reference in new issue
Block a user