-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreally_powerful_gnomes.py
executable file
·73 lines (59 loc) · 1.4 KB
/
really_powerful_gnomes.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
#!/usr/bin/python2
import socket
from time import sleep
TCP_IP = 'jh2i.com'
TCP_PORT = 50031
BUFFER_SIZE = 1024 * 10
expected = 'send back this line exactly'
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
# buy sword 100 gold
data = s.recv(BUFFER_SIZE)
s.send('6\n')
data = s.recv(BUFFER_SIZE)
s.send('1\n')
# get 1000 gold
data = s.recv(BUFFER_SIZE)
while int(data.split('Gold: ')[1].split('\n')[0]) < 1000:
s.send('5\n')
data = s.recv(BUFFER_SIZE)
print(data)
# buy bow 1000 gold
s.send('6\n')
data = s.recv(BUFFER_SIZE)
s.send('2\n')
# get 2000 gold
data = s.recv(BUFFER_SIZE)
while int(data.split('Gold: ')[1].split('\n')[0]) < 2000:
s.send('4\n')
data = s.recv(BUFFER_SIZE)
print(data)
# buy axe 2000 gold
s.send('6\n')
data = s.recv(BUFFER_SIZE)
s.send('3\n')
# get 10000 gold
data = s.recv(BUFFER_SIZE)
while int(data.split('Gold: ')[1].split('\n')[0]) < 10000:
s.send('3\n')
data = s.recv(BUFFER_SIZE)
print(data)
# buy missle launcher 10000 gold
s.send('6\n')
data = s.recv(BUFFER_SIZE)
s.send('4\n')
# get 100000 gold
data = s.recv(BUFFER_SIZE)
while int(data.split('Gold: ')[1].split('\n')[0]) < 100000:
s.send('2\n')
data = s.recv(BUFFER_SIZE)
print(data)
# buy tank 100000 gold
s.send('6\n')
data = s.recv(BUFFER_SIZE)
s.send('5\n')
# beat boss
data = s.recv(BUFFER_SIZE)
s.send('1\n')
data = s.recv(BUFFER_SIZE)
print(data)