Added market commands

doc_update
Joey Hines 2019-05-11 11:46:30 -05:00
parent f1a7cb61e5
commit 985dd17dc0
2 changed files with 31 additions and 6 deletions

View File

@ -165,7 +165,7 @@ def add_town(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
:request: POST :request: POST
:param x_pos: MC X Coordinate :param x_pos: MC X Coordinate
:param z_pos: MC Z Coordinate :param z_pos: MC Z Coordinate
:param name: Shop Name (If None, Defaults to Player's Shop) :param name: Town Name (If None, Defaults to Player's Town)
:param discord_uuid: Discord UUID :param discord_uuid: Discord UUID
:param mc_uuid: Minecraft UUID :param mc_uuid: Minecraft UUID
:return: JSON representation of the new town :return: JSON representation of the new town
@ -182,10 +182,10 @@ def add_farm(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
:request: POST :request: POST
:param x_pos: MC X Coordinate :param x_pos: MC X Coordinate
:param z_pos: MC Z Coordinate :param z_pos: MC Z Coordinate
:param name: Shop Name (If None, Defaults to Player's Shop) :param name: Farm Name (If None, Defaults to Player's Farm)
:param discord_uuid: Discord UUID :param discord_uuid: Discord UUID
:param mc_uuid: Minecraft UUID :param mc_uuid: Minecraft UUID
:return: JSON representation of the new town :return: JSON representation of the new farm
:raises: EntryNameNotUniqueError, PlayerNotFound, LocationLookupError :raises: EntryNameNotUniqueError, PlayerNotFound, LocationLookupError
:help: Adds your public farm to the database. :help: Adds your public farm to the database.
""" """
@ -193,6 +193,22 @@ def add_farm(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=PublicFarm) return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=PublicFarm)
@command("POST")
def add_market(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
"""
:request: POST
:param x_pos: MC X Coordinate
:param z_pos: MC Z Coordinate
:param name: Market Name (If None, Defaults to Player's Market)
:param discord_uuid: Discord UUID
:param mc_uuid: Minecraft UUID
:return: JSON representation of the market
:raises: EntryNameNotUniqueError, PlayerNotFound, LocationLookupError
:help: Adds your market to the database.
"""
return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Market)
@command("POST") @command("POST")
def add_tunnel(tunnel_direction, tunnel_number, location_name=None, discord_uuid=None, mc_uuid=None): def add_tunnel(tunnel_direction, tunnel_number, location_name=None, discord_uuid=None, mc_uuid=None):
@ -339,6 +355,13 @@ def add_resource(resource_name, farm_name=None, discord_uuid=None, mc_uuid=None)
@command("GET") @command("GET")
def find_farm(resource_name): def find_farm(resource_name):
"""
:request: GET
:param resource_name: Resource to search for
:return: List of top matching farms
:raises: ResourceNotFoundError
:help: Lists farms that produce an object
"""
if len(resource_name) == 0: if len(resource_name) == 0:
raise EmptryString raise EmptryString
@ -350,7 +373,7 @@ def selling(item_name):
""" """
:request: GET :request: GET
:param item_name: Item name to search for :param item_name: Item name to search for
:return: List of top matching shops, sorted by the :return: List of top matching shops, sorted by the date last restocke
:raises: ItemNotFound :raises: ItemNotFound
:help: Lists shops selling an item. Sorted by when they were last restocked. :help: Lists shops selling an item. Sorted by when they were last restocked.
""" """

View File

@ -309,8 +309,10 @@ class Market(Location):
info_page = "GeoffreyMarketInfo" info_page = "GeoffreyMarketInfo"
def get_shops(self, market_radius=100, limit=10): def get_shops(self, market_radius=100, limit=10):
shops = Shop.objects.filter(x_coord__range=(self.x_coord - market_radius, self.x_coord + market_radius), x = int(self.x_coord)
z_coord__range=(self.z_coord - market_radius, self.z_coord + market_radius) z = int(self.z_coord)
shops = Shop.objects.filter(x_coord__range=(x - market_radius, x + market_radius),
z_coord__range=(z - market_radius, z + market_radius)
)[:limit] )[:limit]
return shops return shops