-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_mine.py
More file actions
93 lines (67 loc) · 2.46 KB
/
auto_mine.py
File metadata and controls
93 lines (67 loc) · 2.46 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
92
import os
import argparse
from endpoints import *
from main_functions import *
import time
import subprocess
os.system('pipenv shell')
parser = argparse.ArgumentParser(description='Auto Miner')
parser.add_argument('--coin')
args = parser.parse_args()
coins_to_mine = int(args.coin)
coins_mined = 0
current_room = get_current_room()
# Cooldown penalty check
if current_room['errors'] is not None and len(current_room['errors']) > 0:
print('\n!!!! Cooldown Penalty !!!!')
cooldown(current_room)
print('Getting current room id...')
current_room = get_current_room()
cooldown(current_room)
else:
print('Getting current room id...')
cooldown(current_room)
status_res = status()
cooldown(status_res)
while coins_mined < coins_to_mine:
# Travel to well
# run_script = 'python fast_travel.py --room 55 --collect_treasure True'
run_script = 'python fast_travel.py --room 55'
if status_res['abilities']:
run_script += ' --abilities'
for ability in status_res['abilities']:
run_script += f' {ability}'
os.system(run_script)
# Get Message
print('Getting Well Data...')
well_data = examine('Well')
cooldown(well_data)
desc = well_data['description']
desc = desc.strip('You see a faint pattern in the water...\n\n').split('\n')
with open('well_data.txt', 'w') as well_data:
for i in desc:
well_data.write(f'{i}\n')
print('Updating well_data.txt...')
time.sleep(2)
cmd = ['python', 'ls8.py', 'well_data.txt']
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
output = output.decode('utf-8').replace('\n', '').split(' ')[-3]
mining_room = output.rstrip('HALTING')
print(f'\nTraveling to room {mining_room} to mine\n')
# run_script = f'python fast_travel.py --room {mining_room} --collect_treasure True'
run_script = f'python fast_travel.py --room {mining_room}'
if status_res['abilities']:
run_script += ' --abilities'
for ability in status_res['abilities']:
run_script += f' {ability}'
os.system(run_script)
os.system('python mine.py')
coins_mined += 1
print(f"\nYou've mined {coins_mined} out of {coins_to_mine}\n")
# if coins_mined % 4 == 0:
# #sell everything
# os.system('python fast_travel.py --room 1 --collect_treasure True')
balance = get_balance()
cooldown(balance)
balance_message = balance['messages'][0]
print(f'\n{balance_message}\n')