48 lines
1.4 KiB
Python
48 lines
1.4 KiB
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 '**{}** @ **{}** {}{}'.format(location["name"], formatted_position(location), tunnel,
|
|
formatted_owners(location))
|
|
|
|
|
|
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
|
|
|
|
|
|
def formatted_owners(location):
|
|
owner_list = ''
|
|
if "owner" in location:
|
|
|
|
if len(location["owner"]) == 0:
|
|
owner_list = 'Owner: **{}**'
|
|
owner_list = owner_list.format(location["owner"][0]["name"])
|
|
else:
|
|
owner_list = 'Owners: **{}**'
|
|
|
|
owners = location["owner"][0]["name"]
|
|
for owner in location["owner"][1:3]:
|
|
owners += ", " + owner["name"]
|
|
|
|
owner_list = owner_list.format(owners)
|
|
|
|
return owner_list
|