Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from thebrumby:main #48

Merged
merged 24 commits into from
Sep 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update claimer.py
  • Loading branch information
thebrumby committed Sep 15, 2024
commit b45380ebfc5837f21f18813658b627640e13145f
25 changes: 21 additions & 4 deletions games/claimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,17 @@ def strip_non_numeric(self, text):
return re.sub(r'[^0-9.]', '', text)

def apply_random_offset(self, unmodifiedTimer):
# Helper function to format minutes into hours and minutes
def format_time(minutes):
hours = minutes // 60
mins = minutes % 60
time_parts = []
if hours > 0:
time_parts.append(f"{hours} hour{'s' if hours != 1 else ''}")
if mins > 0 or hours == 0:
time_parts.append(f"{mins} minute{'s' if mins != 1 else ''}")
return ' '.join(time_parts)

if self.allow_early_claim:
if self.settings['lowestClaimOffset'] <= self.settings['highestClaimOffset']:
self.random_offset = random.randint(
Expand All @@ -1402,10 +1413,13 @@ def apply_random_offset(self, unmodifiedTimer):
)
modifiedTimer = unmodifiedTimer + self.random_offset
self.output(
f"Step {self.step} - Random offset applied to the wait timer of: {self.random_offset} minutes.",
f"Step {self.step} - Random offset applied to the wait timer of: {self.random_offset} minutes ({format_time(self.random_offset)}).",
3
)
self.output(
f"Step {self.step} - Returned modified timer: {modifiedTimer} minutes ({format_time(modifiedTimer)}).",
3
)
self.output(f"Step {self.step} - Returned modified timer: {modifiedTimer} minutes.", 3)
return modifiedTimer
else:
if self.settings['lowestClaimOffset'] <= self.settings['highestClaimOffset']:
Expand All @@ -1422,8 +1436,11 @@ def apply_random_offset(self, unmodifiedTimer):
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.",
f"Step {self.step} - Random offset applied to the wait timer of: {self.random_offset} minutes ({format_time(self.random_offset)}).",
3
)
self.output(
f"Step {self.step} - Returned modified timer: {modifiedTimer} minutes ({format_time(modifiedTimer)}).",
3
)
self.output(f"Step {self.step} - Returned modified timer: {modifiedTimer} minutes.", 3)
return modifiedTimer