-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfarmer.py
More file actions
91 lines (71 loc) · 2.27 KB
/
farmer.py
File metadata and controls
91 lines (71 loc) · 2.27 KB
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
81
82
83
84
85
86
87
88
89
90
91
from typing import cast
from pygame import mixer # Load the popular external library
import time
import sys
import os
import psutil
import logging
from pynput import keyboard
if os.name == 'nt':
import msvcrt
import ctypes
class _CursorInfo(ctypes.Structure):
_fields_ = [("size", ctypes.c_int),
("visible", ctypes.c_byte)]
def hide_cursor():
if os.name == 'nt':
ci = _CursorInfo()
handle = ctypes.windll.kernel32.GetStdHandle(-11)
ctypes.windll.kernel32.GetConsoleCursorInfo(handle, ctypes.byref(ci))
ci.visible = False
ctypes.windll.kernel32.SetConsoleCursorInfo(handle, ctypes.byref(ci))
elif os.name == 'posix':
sys.stdout.write("\033[?25l")
sys.stdout.flush()
def clearConsole():
command = 'clear'
if os.name in ('nt', 'dos'): # If Machine is running on Windows, use cls
command = 'cls'
os.system(command)
def remove_curser():
hide_cursor()
def clear_line():
print(f" ", end="\r")
def starting_timer():
print("---------Starting timer---------")
def restart_timer():
print("----------Restarting timer----------")
restart_program()
def restart_program():
"""Restarts the current program
"""
clearConsole()
os.execl(sys.executable, 'python', __file__, *sys.argv[1:])
keyboard.GlobalHotKeys({'<ctrl>+r': restart_timer}).start()
if __name__ == '__main__':
remove_curser()
starting_timer()
farming_period = 0
loot_period = 0
try:
file = open('../properties.txt')
lines = file.readlines()
farming_period = int(lines[0].split(':')[1].replace(" ", ""))
loot_period = int(lines[1].split(':')[1].replace(" ", ""))
except Exception as e:
print(e)
mixer.init()
try:
while True:
for tick in range(farming_period):
time.sleep(1)
print(f"Farming : {tick+1}", end="\r")
clear_line()
mixer.music.load('../sounds/monney.mp3')
mixer.music.play()
for tick in range(loot_period-3):
time.sleep(1)
print(f"looting : {tick+1+3}", end="\r")
clear_line()
except KeyboardInterrupt:
pass