Geoffrey-Bot/GeoffreyBot/GeoffreyApiHelper.py

30 lines
916 B
Python

def formatted_item_listing(item):
return "{} {} for {}D".format(item["amount"], item["item_name"], item["price"])
def formatted_location(location):
if location["tunnel"] is not None:
tunnel = "**{}** ".format(location["tunnel"])
else:
tunnel = ""
return '**{}** @ **{}** {}Owner: **{}**'.format(location["name"], formatted_position(location), tunnel,
location["owner"]["name"])
def formatted_tunnel(tunnel):
return '**{} {}**: {}'.format(tunnel["tunnel_direction"], tunnel["tunnel_number"], tunnel["location_name"])
def formatted_position(location):
return '(x={}, z={})'.format(location["x_coord"], location["z_coord"])
def formatted_shop(shop):
inventory = ""
for item in shop["items"]:
inventory = inventory + "\n" + (formatted_item_listing(item))
return formatted_location(shop) + inventory