2019-01-04 16:54:38 +00:00
|
|
|
def formatted_item_listing(item):
|
2019-01-14 20:20:16 +00:00
|
|
|
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 = ""
|
|
|
|
|
2019-02-02 15:37:45 +00:00
|
|
|
return '**{}** @ **{}** {}{}'.format(location["name"], formatted_position(location), tunnel,
|
|
|
|
formatted_owners(location))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
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"])
|
|
|
|
|
|
|
|
|
2019-02-17 03:21:29 +00:00
|
|
|
def formatted_shop(shop, base_url):
|
|
|
|
shop_info_list = formatted_location_info(shop, base_url)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-02-17 03:21:29 +00:00
|
|
|
if len(shop["items"]) > 0:
|
|
|
|
shop_info_list.append("**Inventory:**")
|
|
|
|
for item in shop["items"]:
|
|
|
|
shop_info_list.append(formatted_item_listing(item))
|
|
|
|
|
|
|
|
return shop_info_list
|
|
|
|
|
|
|
|
|
2019-05-11 16:45:55 +00:00
|
|
|
def formatted_farm(farm, base_url):
|
|
|
|
farm_info_list = formatted_location_info(farm, base_url)
|
|
|
|
|
|
|
|
if len(farm["resources"]) > 0:
|
|
|
|
farm_info_list.append("**Produces:**")
|
|
|
|
for resource in farm["resources"]:
|
|
|
|
farm_info_list.append(resource["name"])
|
|
|
|
|
|
|
|
return farm_info_list
|
|
|
|
|
|
|
|
|
|
|
|
def formatted_market(market, base_url):
|
|
|
|
market_info_list = formatted_location_info(market, base_url)
|
|
|
|
|
|
|
|
if len(market["shops"]) > 0:
|
|
|
|
market_info_list.append("**Shops:**")
|
|
|
|
for shop in market["shops"]:
|
|
|
|
market_info_list.append(formatted_location(shop))
|
|
|
|
|
|
|
|
return market_info_list
|
|
|
|
|
|
|
|
|
2019-02-17 03:21:29 +00:00
|
|
|
def formatted_location_info(location, base_url):
|
|
|
|
info = []
|
|
|
|
|
|
|
|
info.append(formatted_location(location))
|
|
|
|
info.append(get_full_link(base_url, location["link"]))
|
|
|
|
|
|
|
|
return info
|
|
|
|
|
|
|
|
|
|
|
|
def formatted_town(town, base_url):
|
|
|
|
town_info_list = formatted_location_info(town, base_url)
|
|
|
|
|
|
|
|
if len(town["residents"]) > 0:
|
|
|
|
town_info_list.append("**Residents:**")
|
|
|
|
|
|
|
|
for resident in town["residents"]:
|
|
|
|
town_info_list.append(resident["name"])
|
|
|
|
|
|
|
|
return town_info_list
|
2019-01-31 19:56:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
def formatted_owners(location):
|
|
|
|
owner_list = ''
|
|
|
|
if "owner" in location:
|
|
|
|
|
2019-02-17 03:21:29 +00:00
|
|
|
if len(location["owner"]) == 1:
|
2019-02-02 15:37:45 +00:00
|
|
|
owner_list = 'Owner: **{}**'
|
|
|
|
owner_list = owner_list.format(location["owner"][0]["name"])
|
2019-01-31 19:56:50 +00:00
|
|
|
else:
|
2019-02-02 15:37:45 +00:00
|
|
|
owner_list = 'Owners: **{}**'
|
|
|
|
|
|
|
|
owners = location["owner"][0]["name"]
|
|
|
|
for owner in location["owner"][1:3]:
|
|
|
|
owners += ", " + owner["name"]
|
|
|
|
|
|
|
|
owner_list = owner_list.format(owners)
|
2019-01-31 19:56:50 +00:00
|
|
|
|
|
|
|
return owner_list
|
2019-02-17 03:21:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_full_link(base_url, link):
|
|
|
|
return base_url + link
|