Added find_farm command

master
Joey Hines 2019-05-14 17:38:39 -05:00
parent 3911daa430
commit a346cb3eb9
1 changed files with 38 additions and 19 deletions

View File

@ -179,13 +179,11 @@ class GeoffreyCommands(commands.Cog):
async def add_owner(self, ctx, new_owner_name, *args): async def add_owner(self, ctx, new_owner_name, *args):
""" """
{}add_owner <New Owner's Name> <Location Name> {}add_owner <New Owner's Name> <Location Name>
WARNING: The new owner had just as much power as you to edit or delete this location. WARNING: The new owner has just as much power as you to edit or delete this location.
""" """
errors = { errors = {
"OwnerNotFoundError": "ain't no one in this darn database named **{}** you goob".format( "OwnerNotFoundError": "ain't no one in this darn database named **{}** you goob".format(new_owner_name),
ctx.message.author.mention, new_owner_name), "IsOwnerError": "**{}** is already an owner, stop having amosia.".format(new_owner_name),
"IsOwnerError": "**{}** is already an owner, stop having amosia.".format(
ctx.message.author.mention, new_owner_name),
"LocationLookUpError": "you do not have a location by that name you ding dong goober." "LocationLookUpError": "you do not have a location by that name you ding dong goober."
} }
@ -207,7 +205,7 @@ class GeoffreyCommands(commands.Cog):
"ResidentNotFoundError": "ain't no one in this darn database named **{}** you goob".format( "ResidentNotFoundError": "ain't no one in this darn database named **{}** you goob".format(
new_resident_name), new_resident_name),
"IsResidentError": "**{}** is already a resident, stop having amosia.".format(new_resident_name), "IsResidentError": "**{}** is already a resident, stop having amosia.".format(new_resident_name),
"LocationLookupError": "you do not have a town by that name you ding dong goober." "LocationLookUpError": "you do not have a town by that name you ding dong goober."
} }
town_name = get_name(args) town_name = get_name(args)
@ -263,7 +261,7 @@ class GeoffreyCommands(commands.Cog):
@commands.command(pass_context=True) @commands.command(pass_context=True)
async def add_town(self, ctx, x_pos: int, z_pos: int, *args): async def add_town(self, ctx, x_pos: int, z_pos: int, *args):
""" """
{}add_town <X Coordinate> <Z Coordinate> <Shop Name> {}add_town <X Coordinate> <Z Coordinate> <Town Name>
The Town Name parameter is optional if this is your first town The Town Name parameter is optional if this is your first town
""" """
errors = { errors = {
@ -283,15 +281,15 @@ class GeoffreyCommands(commands.Cog):
@commands.command(pass_context=True) @commands.command(pass_context=True)
async def add_tunnel(self, ctx, tunnel_direction, tunnel_number: int, *args): async def add_tunnel(self, ctx, tunnel_direction, tunnel_number: int, *args):
""" """
{}add_tunnel <Tunnel Direction> <Tunnel Number> <Location Name> {}add_tunnel <Tunnel Direction> <X/Z Tunnel Number> <Location Name>
The Name parameter is optional if you only have one location The Name parameter is optional if you only have one location
""" """
errors = {
"InvalidTunnelError": "{} is not a valid tunnel direction ya gub".format(tunnel_direction),
"LocationLookUpError": "you do not have a location by the name you ding dong goober."
}
name = get_name(args) name = get_name(args)
errors = {
"InvalidTunnelError": "{} is not a valid tunnel direction ya gub".format(tunnel_direction),
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(name)
}
tunnel = await run_command(ctx, self.base_url, self.api_token, "POST", "add_tunnel", errors=errors, tunnel = await run_command(ctx, self.base_url, self.api_token, "POST", "add_tunnel", errors=errors,
tunnel_direction=tunnel_direction, tunnel_direction=tunnel_direction,
@ -369,7 +367,7 @@ class GeoffreyCommands(commands.Cog):
errors = { errors = {
"EntryNameNotUniqueError": "a location is already called **{}** you ding dong goober".format(old_name), "EntryNameNotUniqueError": "a location is already called **{}** you ding dong goober".format(old_name),
"LocationLookupError": "you do not have a location by the name **{}** you ding dong goober.".format( "LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(
old_name) old_name)
} }
@ -383,7 +381,7 @@ class GeoffreyCommands(commands.Cog):
@commands.command(pass_conext=True) @commands.command(pass_conext=True)
async def edit_pos(self, ctx, new_x: int, new_z: int, *args): async def edit_pos(self, ctx, new_x: int, new_z: int, *args):
""" """
{}edit_post <New X Coordinate> <New Z Coordinate> <Location Name> {}edit_pos <New X Coordinate> <New Z Coordinate> <Location Name>
""" """
loc_name = get_name(args) loc_name = get_name(args)
@ -409,8 +407,8 @@ class GeoffreyCommands(commands.Cog):
errors = { errors = {
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format( "LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(
"loc_name"), loc_name),
"InvalidLookUpError": "{} is not a valid tunnel direction ya gub".format(new_tunnel_direction) "InvalidTunnelError": "{} is not a valid tunnel direction ya gub".format(new_tunnel_direction)
} }
location = await run_command(ctx, self.base_url, self.api_token, "POST", "edit_tunnel", errors=errors, location = await run_command(ctx, self.base_url, self.api_token, "POST", "edit_tunnel", errors=errors,
@ -438,7 +436,7 @@ class GeoffreyCommands(commands.Cog):
radius = 200 radius = 200
locations = await run_command(ctx, self.base_url, self.api_token, "GET", "find_around", errors=errors, locations = await run_command(ctx, self.base_url, self.api_token, "GET", "find_around", errors=errors,
x_pos=x_pos, z_pos=z_pos) x_pos=x_pos, z_pos=z_pos, radius=radius)
message = ["{}, the following locations are within **{}** blocks of (x={}, z={}):".format( message = ["{}, the following locations are within **{}** blocks of (x={}, z={}):".format(
ctx.message.author.mention, radius, x_pos, z_pos)] ctx.message.author.mention, radius, x_pos, z_pos)]
@ -448,6 +446,27 @@ class GeoffreyCommands(commands.Cog):
await self.bot.send_list(ctx, message) await self.bot.send_list(ctx, message)
@commands.command(pass_context=True)
async def find_farm(self, ctx, *args):
"""
{}find_farm <Resource>
"""
search = get_name(args)
errors = {
"ResourceNotFoundError": "there are no farms that match **{}**.".format(search)
}
locations = await run_command(ctx, self.base_url, self.api_token, "GET", "find_farm", errors=errors,
resource_name=search)
message = ["{}, the following farms produce **{}**:".format(ctx.message.author.mention, search)]
for location in locations:
message.append(formatted_location(location))
await self.bot.send_list(ctx, message)
@commands.command(pass_context=True, aliases=["find"]) @commands.command(pass_context=True, aliases=["find"])
async def find_location(self, ctx, *args): async def find_location(self, ctx, *args):
""" """
@ -557,7 +576,7 @@ class GeoffreyCommands(commands.Cog):
town_name = get_name(args) town_name = get_name(args)
errors = { errors = {
"ResidentNotFoundError": "ain't no one your town named {} you goob".format(resident_name), "ResidentNotFoundError": "ain't no one in your town named {} you goob".format(resident_name),
"LocationLookUpError": "you do not have a town called **{}** you ding dong goober.".format(town_name) "LocationLookUpError": "you do not have a town called **{}** you ding dong goober.".format(town_name)
} }
@ -595,7 +614,7 @@ class GeoffreyCommands(commands.Cog):
@commands.command(pass_context=True) @commands.command(pass_context=True)
async def selling_price(self, ctx, *args): async def selling_price(self, ctx, *args):
""" """
{}selling_rpice <Item Name> {}selling_price <Item Name>
Sorts by best price Sorts by best price
""" """
item = get_name(args) item = get_name(args)