def main(): i = 1 print(i) i += 1 if i <= 5: goto(6) return
def pick_up_item(current_room_id, item_name, can_fly=False, can_dash=False): TOKEN = config("TOKEN") room_details = [] room_map = {} with open("room_details_copy.py", "r") as f: room_details = json.loads(f.read()) with open("room_graph_copy.py", "r") as f: room_map = json.loads(f.read()) # Go to item goto(current_room_id, item_name, can_fly, can_dash) # Pick up item data = requests.post( "https://lambda-treasure-hunt.herokuapp.com/api/adv/take/", json={ "name": item_name }, headers={ 'Authorization': f"Token {TOKEN}" }).json() print(data) cooldown = data["cooldown"] sleep(cooldown) # Remove item from room_details current_room_id = get_current_room() for room_info in room_details: if str(room_info['room_id']) == current_room_id: if 'items' in room_info and item_name in room_info['items']: room_info['items'].remove(item_name) with open("room_details_copy.py", "w") as f: f.write(json.dumps(room_details)) if 'Item not found: +5s CD' in data['errors']: return False else: print(f"\n****** Picked up {item_name} ******\n") return True
def examine(): res = requests.post( "https://lambda-treasure-hunt.herokuapp.com/api/adv/examine/", headers=auth, json={"name": "well"}) res_json = res.json() time.sleep(res_json["cooldown"]) return res.json() if __name__ == "__main__": # get the current room current_room = get_current_room() # wishing well room wishing_well_room = "55" # go to the room if not there already goto(str(current_room), wishing_well_room) # examine the well response = examine() # write the well prophecy to a file with open("wishing_well_prophecy.txt", "w") as f: f.write(response["description"]) # print response print(response)
DESIRED_NAME = config("NAME") auth = {"Authorization": "Token " + TOKEN} def get_current_room(): res = requests.get( "https://lambda-treasure-hunt.herokuapp.com/api/adv/init/", headers=auth ) res_json = res.json() time.sleep(res_json["cooldown"]) return res_json["room_id"] def change_name(): res = requests.post( "https://lambda-treasure-hunt.herokuapp.com/api/adv/change_name/", headers=auth, json={"name": DESIRED_NAME, "confirm": "aye"} ) return res.json() if __name__ == "__main__": current_room = get_current_room() change_name_room = "467" goto(str(current_room), change_name_room) response = change_name() print(response)
while True: # get the player's current room current_room = get_current_room() # set variable found_treasure to None found_treasure = None # while found_treasure is None while found_treasure is None: # generate a random interval between 2 and 500 target_room = str(randint(2, 499)) # call goto_treasure found_treasure = goto_treasure(current_room, target_room) # get current room current_room = get_current_room() # call goto and pass current location and 1 goto(current_room, "1") # sell the treasure response = requests.post( "https://lambda-treasure-hunt.herokuapp.com/api/adv/sell/", json={ "name": "treasure" }, headers={ 'Authorization': f"Token {TOKEN}" }).json() # get cooldown and sleep for the cooldown period cooldown = response["cooldown"] sleep(cooldown) # sell the treasure
def upload(): global ans products = User_Products if request.method == 'POST': if request.form.get('Do_something'): pro = request.form.get('Do_something') pro = pro.split(" ") for i in pro: print(i) user_id = products.insert_one({ "email": session["username"], "product_name": pro[0], "price": pro[1], "product_link": pro[2], "img_link": pro[3], "web_img": pro[4] }) if user_id: print("Inserted") flash('Product added to track', 'success') return render_template('Result.html', dictionary=ans) else: query = request.form['query'] category = request.form['category'] print(query) print(category) query = query.lower() check_product = check_pro(query, category) if check_product: products = Products pid = products.find({"query": query, "category": category}) answer = {} y = {} for doc in pid: y = doc key = y["title"] answer.setdefault(key, []) answer[key].append(y["price"]) answer[key].append(y["link"]) answer[key].append(y["image"]) answer[key].append(y["shop_image"]) else: if (category == "Grocery"): df1 = daraz.daraz(query) answer = dict(df1) answer.update(yayvo.yayvo(query)) answer.update(hummart.hummart(query)) #print(answer) elif (category == "Mobile and Tablets" or category == "Laptop and Desktop"): df1 = daraz.daraz(query) answer = dict(df1) answer.update(yayvo.yayvo(query)) answer.update(goto.goto(query)) #answer.update(ishopping.ishopping(driver,query)) answer.update(mega.mega(query)) answer.update(rocket.rocket(query)) answer.update(itshop.itshop(query)) answer.update(symbios.symbios(query)) else: #answer.update(shophive.shophive(driver,query)) df1 = daraz.daraz(query) answer = dict(df1) answer.update(rocket.rocket(query)) answer.update(yayvo.yayvo(query)) answer.update(goto.goto(query)) #answer.update(ishopping.ishopping(driver,query)) ans = answer ans = sorted(ans.items(), key=lambda e: e[1][0]) ans = dict(ans) store_product(ans, query, category) return render_template('Result.html', dictionary=ans)