From 38df2713767c58fcd287748e54000e603b600b37 Mon Sep 17 00:00:00 2001 From: Semjon Kerner Date: Sun, 13 Dec 2020 20:13:15 +0100 Subject: [PATCH] fixup rebase and max waittime --- fishy/engine/semifisher/fishing_event.py | 13 +++++++------ fishy/gui/config_top.py | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fishy/engine/semifisher/fishing_event.py b/fishy/engine/semifisher/fishing_event.py index e56f2d2..c297280 100644 --- a/fishy/engine/semifisher/fishing_event.py +++ b/fishy/engine/semifisher/fishing_event.py @@ -34,11 +34,12 @@ class FishEvent: uid = None sound = False -def _fishing_sleep(waittime, lower_limit = 16, upper_limit = 58): +def _fishing_sleep(waittime, lower_limit_ms = 16, upper_limit_ms = 2500): reaction = 0.0 - if (FishEvent.jitter): - reaction = float( random.randrange(lower_limit, upper_limit) )/100.0 - time.sleep(waittime+reaction) + if (FishEvent.jitter and (upper_limit_ms > lower_limit_ms)): + reaction = float( random.randrange(lower_limit_ms, upper_limit_ms) )/1000.0 + max_wait_t = waittime+reaction if (waittime+reaction <= 2.5) else 2.5 + time.sleep(max_wait_t) def init(): @@ -82,14 +83,14 @@ def on_hook(): FishEvent.fish_times.append(time_to_hook) logging.info("HOOOOOOOOOOOOOOOOOOOOOOOK....... " + str(FishEvent.fishCaught) + " caught " + "in " + str( round(time_to_hook, 2)) + " secs. " + "Total: " + str(FishEvent.totalFishCaught)) - _fishing_sleep(0.0) + keyboard.press_and_release(FishEvent.action_key) if FishEvent.collect_allow_auto: _fishing_sleep(0.1) keyboard.press_and_release('r') _fishing_sleep(0.1) - _fishing_sleep(0.0, upper_limit=48) + _fishing_sleep(0.0) def on_look(): diff --git a/fishy/gui/config_top.py b/fishy/gui/config_top.py index 96623c8..c22ff99 100644 --- a/fishy/gui/config_top.py +++ b/fishy/gui/config_top.py @@ -108,9 +108,9 @@ def start_semifisher_config(gui: 'GUI'): sound = Checkbutton(controls_frame, var=BooleanVar(value=config.get("sound_notification"))) sound.grid(row=5, column=1) - Label(controls_frame, text="Human-Like Delay: ").grid(row=4, column=0, pady=(5, 5)) + Label(controls_frame, text="Human-Like Delay: ").grid(row=6, column=0, pady=(5, 5)) jitter = Checkbutton(controls_frame, var=BooleanVar(value=config.get("jitter"))) - jitter.grid(row=4, column=1) + jitter.grid(row=6, column=1) controls_frame.pack(padx=(5, 5), pady=(5, 5)) top.start()