Skip to content

Commit

Permalink
Update random offset code
Browse files Browse the repository at this point in the history
Improved debugging output for the function.
  • Loading branch information
thebrumby authored Sep 15, 2024
1 parent e857906 commit 30b7f75
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions games/claimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,13 +1396,34 @@ def strip_non_numeric(self, text):
def apply_random_offset(self, unmodifiedTimer):
if self.allow_early_claim:
if self.settings['lowestClaimOffset'] <= self.settings['highestClaimOffset']:
self.random_offset = random.randint(self.settings['lowestClaimOffset'], self.settings['highestClaimOffset'])
self.random_offset = random.randint(
self.settings['lowestClaimOffset'],
self.settings['highestClaimOffset']
)
modifiedTimer = unmodifiedTimer + self.random_offset
self.output(f"Step {self.step} - Random offset applied to the wait timer of: {self.random_offset} minutes.", 3)
self.output(
f"Step {self.step} - Random offset applied to the wait timer of: {self.random_offset} minutes.",
3
)
self.output(f"Step {self.step} - Returned modified timer: {modifiedTimer} minutes.", 3)
return modifiedTimer
else:
if self.settings['lowestClaimOffset'] <= self.settings['highestClaimOffset']:
self.random_offset = random.randint(max(self.settings['lowestClaimOffset'],0), max(self.settings['highestClaimOffset'],0))
# Cap the offsets to at least 0
capped_lowest = max(self.settings['lowestClaimOffset'], 0)
capped_highest = max(self.settings['highestClaimOffset'], 0)
if (capped_lowest != self.settings['lowestClaimOffset'] or
capped_highest != self.settings['highestClaimOffset']):
self.output(
f"Step {self.step} - Offsets were capped to 0: "
f"lowestClaimOffset={capped_lowest}, highestClaimOffset={capped_highest}",
3
)
self.random_offset = random.randint(capped_lowest, capped_highest)
modifiedTimer = unmodifiedTimer + self.random_offset
self.output(f"Step {self.step} - Random offset applied to the wait timer of: {self.random_offset} minutes.", 3)
self.output(
f"Step {self.step} - Random offset applied to the wait timer of: {self.random_offset} minutes.",
3
)
self.output(f"Step {self.step} - Returned modified timer: {modifiedTimer} minutes.", 3)
return modifiedTimer

0 comments on commit 30b7f75

Please sign in to comment.