Added market commands
parent
f1a7cb61e5
commit
985dd17dc0
|
@ -165,7 +165,7 @@ def add_town(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: 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 mc_uuid: Minecraft UUID
|
||||
: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
|
||||
:param x_pos: MC X 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 mc_uuid: Minecraft UUID
|
||||
:return: JSON representation of the new town
|
||||
:return: JSON representation of the new farm
|
||||
:raises: EntryNameNotUniqueError, PlayerNotFound, LocationLookupError
|
||||
: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)
|
||||
|
||||
|
||||
@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")
|
||||
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")
|
||||
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:
|
||||
raise EmptryString
|
||||
|
||||
|
@ -350,7 +373,7 @@ def selling(item_name):
|
|||
"""
|
||||
:request: GET
|
||||
: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
|
||||
:help: Lists shops selling an item. Sorted by when they were last restocked.
|
||||
"""
|
||||
|
|
|
@ -309,8 +309,10 @@ class Market(Location):
|
|||
info_page = "GeoffreyMarketInfo"
|
||||
|
||||
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),
|
||||
z_coord__range=(self.z_coord - market_radius, self.z_coord + market_radius)
|
||||
x = int(self.x_coord)
|
||||
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]
|
||||
|
||||
return shops
|
||||
|
|
Loading…
Reference in New Issue