Stardew Valley: Make sure number of month in time logic is a int to improve performance by ~20% (#3665)

* make sure number of month is actually a int

* improve rule explain like in pr

* remove redundant if in can_complete_bundle

* assert number is int so cache is not bloated
This commit is contained in:
Jérémie Bolduc
2024-07-20 15:24:24 -04:00
committed by GitHub
parent e33a9991ef
commit 34e7748f23
6 changed files with 38 additions and 9 deletions

View File

@@ -26,8 +26,10 @@ class TimeLogic(BaseLogic[Union[TimeLogicMixin, HasLogicMixin]]):
@cache_self1
def has_lived_months(self, number: int) -> StardewRule:
assert isinstance(number, int), "Can't have lived a fraction of a month. Use // instead of / when dividing."
if number <= 0:
return self.logic.true_
number = min(number, MAX_MONTHS)
return HasProgressionPercent(self.player, number * MONTH_COEFFICIENT)