-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathpotatoFarmer.py
66 lines (48 loc) · 1.55 KB
/
potatoFarmer.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
from wizAPI import *
import math
player = wizAPI().register_window()
def print_separator(*args):
sides = '+'*16
_str = " ".join([sides, " ".join(args), sides])
l = len(_str)
print('='*l)
print(_str)
print('='*l)
def print_time(timer):
minutes = math.floor(timer/60)
seconds = math.floor(timer % 60)
if minutes == 0:
print('Round completed in {} seconds.'.format(seconds))
else:
print('Round completed in {} minutes and {} seconds.'.format(minutes, seconds))
ROUND_COUNT = 0
while True:
ROUND_COUNT += 1
START_TIME = time.time()
print_separator('ROUND', str(ROUND_COUNT))
""" Check if we need to use a potion """
player.use_potion_if_needed()
""" Try to get in battle """
while player.is_idle():
(
player.hold_key('w', 1)
.hold_key('s', 1)
)
""" Success! now wait for our turn to play """
player.wait_for_turn_to_play()
while (not player.is_idle()) and (player.count_enemies() < 2):
print('Waiting for more enemies to join')
(player.wait(5)
.pass_turn())
player.wait_for_end_of_round()
inFight = not player.is_idle()
while inFight:
if player.enchant('meteor-strike', 'epic') or player.find_spell('meteor-strike-enchanted'):
player.cast_spell('meteor-strike-enchanted')
else:
player.pass_turn()
player.wait_for_end_of_round()
if player.is_idle():
inFight = False
print_time(time.time() - START_TIME)
# Fight complete!