-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
80 lines (64 loc) · 2.55 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import keyboard
import pyautogui
import threading
import time
import utility
import atomic_game_actions as actions
from ShopItems import ShopItems
# Main thread state
shop_item_to_buy = ShopItems.FRESHWATER_FRIENDS
running = False
main_thread = None
def change_shop_item(shop_item):
global shop_item_to_buy
shop_item_to_buy = shop_item
print(f"Shop item to buy set to: {shop_item_to_buy}")
def change_running_state(next_state):
global running, main_thread
running = next_state
if running and main_thread == None:
print("Starting main logic")
main_thread = threading.Thread(target=main)
main_thread.start()
elif running and main_thread:
print("Main logic will continue indefinitely again")
elif not running and main_thread == None:
print("No actively running main logic thread found to close")
elif not running and main_thread:
print("Main logic will stop gracefully after it finishes its current iteration")
def main():
global main_thread
while running:
try:
actions.close_any_popup_windows()
actions.open_shop()
actions.open_shop_fish_tab()
actions.buy_max_fish(shop_item_to_buy)
print("Closing shop")
actions.close_any_popup_windows()
actions.open_all_packs()
actions.put_fish_into_tank()
actions.open_current_tank()
actions.click_color_tank_filter()
actions.filter_golden_and_rainbow_to_other_tank()
actions.click_color_tank_filter()
actions.filter_golden_and_rainbow_to_other_tank()
actions.sell_all_unlocked_fish()
pyautogui.moveTo(utility.get_window_centre_point())
time.sleep(1)
except:
print("... Main logic failed")
utility.print_help()
main_thread = None
print("Main thread stopped gracefully")
# Registering keyboard events
keyboard.on_press_key("F1", lambda e: change_shop_item(ShopItems.FRESHWATER_FRIENDS))
keyboard.on_press_key("F2", lambda e: change_shop_item(ShopItems.RIVERS_AND_PONDS))
keyboard.on_press_key("F3", lambda e: change_shop_item(ShopItems.REEF_FELLAS))
keyboard.on_press_key("F4", lambda e: change_shop_item(ShopItems.MARINE_DWELLERS))
keyboard.on_press_key("F5", lambda e: change_shop_item(ShopItems.GIANTS))
keyboard.on_press_key("F6", lambda e: change_shop_item(ShopItems.SPRING_PALS))
keyboard.on_press_key("F11", lambda e: change_running_state(not running))
utility.print_help()
# Keep the program running and listening
keyboard.wait()