-
Notifications
You must be signed in to change notification settings - Fork 1
/
gets_and_posts.py
203 lines (177 loc) · 3.89 KB
/
gets_and_posts.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import json
import requests
from mine import proof_of_work, valid_proof
from util import (Move,
Mine,
Init,
Receive,
Inventory,
Dash,
Carry,
Wear,
Warp,
Wise_Explorer,
Fly ,
Pray,
Drop,
Last_Proof,
Coin_Balance,
Sell,
Take,
Examine,
Change_your_name)
# for api-key
from decouple import config
api_key = config('API_KEY')
header = {
'Authorization': f"{api_key}",
'Content-Type': 'application/json',
}
def init(api_key):
header
response = requests.get(
Init,
headers = header,
data = json.dumps({})
)
return response
# MOVEMENT ENDPOINTS
def move(direction, api_key):
header
response = requests.post(
Move,
headers = header,
data = json.dumps({'direction': direction})
)
return response
def wise_explorer(direction, room_id, api_key):
header
response = requests.post(
Wise_Explorer,
headers = header,
data = json.dumps({'directions': direction, 'Next Rooms Id': str(room_id)})
)
return response
# TREASURE ENDPOINTS
def pickup_treasure(treasure, api_key):
header
response = requests.post(
Take,
headers = header,
data = json.dumps({'name': treasure})
)
return response
def examine(treasure_name, player_name, api_key):
header
response = requests.post(
Examine,
headers=header,
data=json.dumps({"name":f"{treasure_name or player_name}"}),
)
return response
def drop_treasure(treasure, api_key):
header
response = requests.post(
Drop,
headers = header,
data=json.dumps({'Name': f"{treasure}"})
)
return response
def sell_treasure(treasure, api_key):
header
response = requests.post(
Sell,
headers = header,
data=json.dumps({"Name": f"{treasure}", "Confirm": "yes"})
)
return response
def status_inventory(api_key):
header
response = requests.post(
Inventory,
headers=header,
data=json.dumps({}),
)
return response
def name_change(name, api_key):
header
response = requests.post(
Change_your_name,
headers=header,
data=json.dumps({'Name': f"{name}"})
)
return response
def pray_at_shrine(api_key):
header
response=requests.post(
Pray,
headers=header,
data = json.dumps({})
)
return response
def fly(direction, api_key):
header
response = requests.post(
Fly,
headers = header,
data = json.dumps({'direction': f"{direction}"})
)
return response
def dash(direction, num_rooms, room_id, api_key):
header
response = requests.post(
Dash,
headers = header,
data = json.dumps({'direction': f"{direction}", 'Number of rooms': f"{num_rooms}", 'Next Room Id': f"{room_id}"})
)
return response
def carry(item_name, api_key):
header
response = requests.post(
Carry,
headers = header,
data = json.dumps({'Item Name': f"{item_name}"})
)
return response
def receive(api_key):
header
response = requests.post(
Receive,
headers = header,
data = json.dumps({})
)
return response
def warp(api_key):
header
response = requests.post(
Warp,
headers = header,
data = json.dumps({})
)
return response
def mine():
header
response = requests.get(
Last_Proof,
headers= header
)
print(response, "LOOKIE!")
last_block = response['proof']
new_proof = proof_of_work(last_block)
data = {'proof': new_proof}
response = requests.post(
Mine,
headers = header,
data = data
)
return response
def get_balance(api_key):
header
response = requests.get(
Coin_Balance,
headers = header,
data=json.dumps({})
)
return response
def transmogrify(item_name, api_key):
pass