Tunnel color changed to tunnel direction.
parent
8a8374b77d
commit
407566a488
|
@ -74,7 +74,7 @@ class Commands:
|
||||||
|
|
||||||
return shop_name
|
return shop_name
|
||||||
|
|
||||||
def add_tunnel(self, tunnel_color, tunnel_number, location_name=None, discord_uuid=None, mc_uuid=None):
|
def add_tunnel(self, tunnel_direction, tunnel_number, location_name=None, discord_uuid=None, mc_uuid=None):
|
||||||
|
|
||||||
session = self.interface.database.Session()
|
session = self.interface.database.Session()
|
||||||
try:
|
try:
|
||||||
|
@ -88,7 +88,7 @@ class Commands:
|
||||||
|
|
||||||
location_name = location_list[0].name
|
location_name = location_list[0].name
|
||||||
|
|
||||||
tunnel = self.interface.add_tunnel(session, player, tunnel_color, tunnel_number, location_name)
|
tunnel = self.interface.add_tunnel(session, player, tunnel_direction, tunnel_number, location_name)
|
||||||
tunnel_info = tunnel.__str__()
|
tunnel_info = tunnel.__str__()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
@ -223,7 +223,7 @@ class Commands:
|
||||||
|
|
||||||
return loc_str
|
return loc_str
|
||||||
|
|
||||||
def edit_tunnel(self, tunnel_color, tunnel_number, loc_name, discord_uuid=None, mc_uuid=None):
|
def edit_tunnel(self, tunnel_direction, tunnel_number, loc_name, discord_uuid=None, mc_uuid=None):
|
||||||
session = self.interface.database.Session()
|
session = self.interface.database.Session()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -231,10 +231,10 @@ class Commands:
|
||||||
location = self.interface.find_location_by_name_and_owner(session, player, loc_name)[0]
|
location = self.interface.find_location_by_name_and_owner(session, player, loc_name)[0]
|
||||||
|
|
||||||
if location.tunnel is not None:
|
if location.tunnel is not None:
|
||||||
location.tunnel.tunnel_direction = TunnelDirection.str_to_tunnel_dir(tunnel_color)
|
location.tunnel.tunnel_direction = TunnelDirection.str_to_tunnel_dir(tunnel_direction)
|
||||||
location.tunnel.tunnel_number = tunnel_number
|
location.tunnel.tunnel_number = tunnel_number
|
||||||
else:
|
else:
|
||||||
self.interface.add_tunnel(session, player, tunnel_color, tunnel_number, loc_name)
|
self.interface.add_tunnel(session, player, tunnel_direction, tunnel_number, loc_name)
|
||||||
|
|
||||||
loc_str = location.__str__()
|
loc_str = location.__str__()
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class DatabaseInterface:
|
||||||
self.database.add_object(session, loc)
|
self.database.add_object(session, loc)
|
||||||
return loc
|
return loc
|
||||||
|
|
||||||
def add_tunnel(self, session, owner, color, number, location_name):
|
def add_tunnel(self, session, owner, direction, number, location_name):
|
||||||
tunnels = self.find_tunnel_by_owner(session, owner)
|
tunnels = self.find_tunnel_by_owner(session, owner)
|
||||||
if location_name is None:
|
if location_name is None:
|
||||||
if len(tunnels):
|
if len(tunnels):
|
||||||
|
@ -34,7 +34,7 @@ class DatabaseInterface:
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise LocationLookUpError
|
raise LocationLookUpError
|
||||||
|
|
||||||
tunnel = Tunnel(owner, color, number, location)
|
tunnel = Tunnel(owner, direction, number, location)
|
||||||
self.database.add_object(session, tunnel)
|
self.database.add_object(session, tunnel)
|
||||||
|
|
||||||
return tunnel
|
return tunnel
|
||||||
|
|
|
@ -84,17 +84,17 @@ class Add_Commands:
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@commands.cooldown(5, 60, commands.BucketType.user)
|
@commands.cooldown(5, 60, commands.BucketType.user)
|
||||||
async def add_tunnel(self, ctx, tunnel_color: str, tunnel_number: int, *args):
|
async def add_tunnel(self, ctx, tunnel_direction: str, tunnel_number: int, *args):
|
||||||
"""
|
"""
|
||||||
Adds your tunnel to the database. If you only have one location, you do not need to specify a location name
|
Adds your tunnel to the database. If you only have one location, you do not need to specify a location name
|
||||||
|
|
||||||
Directions: North South East West
|
Directions: North South East West
|
||||||
?tunnel [Tunnel Direction] [Tunnel Number] [Location Name]
|
?tunnel [Tunnel Direction] [Tunnel Number] [Location Name]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
loc_name = get_name(args)
|
loc_name = get_name(args)
|
||||||
try:
|
try:
|
||||||
self.bot.bot_commands.add_tunnel(tunnel_color, tunnel_number, discord_uuid=ctx.message.author.id,
|
self.bot.bot_commands.add_tunnel(tunnel_direction, tunnel_number, discord_uuid=ctx.message.author.id,
|
||||||
location_name=loc_name)
|
location_name=loc_name)
|
||||||
await ctx.send('{}, your tunnel has been added to the database'.format(ctx.message.author.mention))
|
await ctx.send('{}, your tunnel has been added to the database'.format(ctx.message.author.mention))
|
||||||
except LocationLookUpError:
|
except LocationLookUpError:
|
||||||
|
@ -103,13 +103,13 @@ class Add_Commands:
|
||||||
except LocationHasTunnelError:
|
except LocationHasTunnelError:
|
||||||
await ctx.send('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, loc_name))
|
await ctx.send('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, loc_name))
|
||||||
except TunnelInitError:
|
except TunnelInitError:
|
||||||
await ctx.send('{}, invalid tunnel name.'.format(ctx.message.author.mention))
|
await ctx.send('{}, invalid tunnel direction.'.format(ctx.message.author.mention))
|
||||||
except EntryNameNotUniqueError:
|
except EntryNameNotUniqueError:
|
||||||
await ctx.send('{}, you have more than one location, you need to specify a location.'
|
await ctx.send('{}, you have more than one location, you need to specify a location.'
|
||||||
.format(ctx.message.author.mention))
|
.format(ctx.message.author.mention))
|
||||||
except InvalidTunnelError:
|
except InvalidTunnelError:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
'{}, **{}** is an invalid tunnel color.'.format(ctx.message.author.mention, tunnel_color))
|
'{}, **{}** is an invalid tunnel direction.'.format(ctx.message.author.mention, tunnel_direction))
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@commands.cooldown(5, 60, commands.BucketType.user)
|
@commands.cooldown(5, 60, commands.BucketType.user)
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Delete_Commands:
|
||||||
async def delete(self, ctx, *args):
|
async def delete(self, ctx, *args):
|
||||||
"""
|
"""
|
||||||
Deletes a location from the database
|
Deletes a location from the database
|
||||||
|
|
||||||
?delete [Location name]
|
?delete [Location name]
|
||||||
"""
|
"""
|
||||||
loc = get_name(args)
|
loc = get_name(args)
|
||||||
|
@ -34,7 +35,7 @@ class Delete_Commands:
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def delete_item(self, ctx, item: str, *args):
|
async def delete_item(self, ctx, item: str, *args):
|
||||||
"""
|
"""
|
||||||
Deletes an item listing from a shop inventory
|
Deletes an item listing from a shop inventory
|
||||||
|
|
||||||
?delete_name [Item] [Shop Name]
|
?delete_name [Item] [Shop Name]
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -17,6 +17,7 @@ class Edit_Commands:
|
||||||
async def edit_pos(self, ctx, x_pos: int, y_pos: int, *args):
|
async def edit_pos(self, ctx, x_pos: int, y_pos: int, *args):
|
||||||
"""
|
"""
|
||||||
Edits the position of a location
|
Edits the position of a location
|
||||||
|
|
||||||
?edit_pos [X Coordinate] [Z Coordinate] [Location Name]
|
?edit_pos [X Coordinate] [Z Coordinate] [Location Name]
|
||||||
"""
|
"""
|
||||||
loc = get_name(args)
|
loc = get_name(args)
|
||||||
|
@ -31,14 +32,16 @@ class Edit_Commands:
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@commands.cooldown(5, 60, commands.BucketType.user)
|
@commands.cooldown(5, 60, commands.BucketType.user)
|
||||||
async def edit_tunnel(self, ctx, tunnel_color: str, tunnel_number: int, *args):
|
async def edit_tunnel(self, ctx, tunnel_direction: str, tunnel_number: int, *args):
|
||||||
"""
|
"""
|
||||||
Edits the tunnel of a location
|
Edits the tunnel of a location
|
||||||
?edit_tunnel [Tunnel Color] [Tunnel Number] [Location Name]
|
|
||||||
|
Directions: North South East West
|
||||||
|
?edit_tunnel [Tunnel Direction] [Tunnel Number] [Location Name]
|
||||||
"""
|
"""
|
||||||
loc = get_name(args)
|
loc = get_name(args)
|
||||||
try:
|
try:
|
||||||
loc_str = self.bot.bot_commands.edit_tunnel(tunnel_color, tunnel_number, loc,
|
loc_str = self.bot.bot_commands.edit_tunnel(tunnel_direction, tunnel_number, loc,
|
||||||
discord_uuid=ctx.message.author.id)
|
discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
|
@ -48,13 +51,14 @@ class Edit_Commands:
|
||||||
ctx.message.author.mention, loc))
|
ctx.message.author.mention, loc))
|
||||||
except InvalidTunnelError:
|
except InvalidTunnelError:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
'{}, **{}** is an invalid tunnel color.'.format(ctx.message.author.mention, tunnel_color))
|
'{}, **{}** is an invalid tunnel direction.'.format(ctx.message.author.mention, tunnel_direction))
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@commands.cooldown(5, 60, commands.BucketType.user)
|
@commands.cooldown(5, 60, commands.BucketType.user)
|
||||||
async def edit_name(self, ctx, new_name: str, current_name: str):
|
async def edit_name(self, ctx, new_name: str, current_name: str):
|
||||||
"""
|
"""
|
||||||
Edits the name of a location
|
Edits the name of a location
|
||||||
|
|
||||||
IF A NAME HAS SPACES IN IT YOU NEED TO WRAP IT IN QUOTATION MARKS. eg. "Cool Shop 123"
|
IF A NAME HAS SPACES IN IT YOU NEED TO WRAP IT IN QUOTATION MARKS. eg. "Cool Shop 123"
|
||||||
?edit_name [New Name] [Current Name]
|
?edit_name [New Name] [Current Name]
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -98,6 +98,7 @@ class Search_Commands:
|
||||||
async def selling(self, ctx, item_name: str):
|
async def selling(self, ctx, item_name: str):
|
||||||
"""
|
"""
|
||||||
Lists all the shops selling an item
|
Lists all the shops selling an item
|
||||||
|
|
||||||
?selling [item]
|
?selling [item]
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
@ -112,6 +113,7 @@ class Search_Commands:
|
||||||
async def info(self, ctx, *args):
|
async def info(self, ctx, *args):
|
||||||
"""
|
"""
|
||||||
Displays info about a location.
|
Displays info about a location.
|
||||||
|
|
||||||
If the location is a shop, it displays the shop's inventory
|
If the location is a shop, it displays the shop's inventory
|
||||||
?info [Location Name]
|
?info [Location Name]
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -238,7 +238,7 @@ class TestCommands(TestCase):
|
||||||
def test_update_mc_uuid(self):
|
def test_update_mc_uuid(self):
|
||||||
self.commands.register('BirbHD', '143072699567177728')
|
self.commands.register('BirbHD', '143072699567177728')
|
||||||
|
|
||||||
self.commands.update_mc_uuid('0', '143072699567177728')
|
self.commands.update_mc_uuid('143072699567177728', '0')
|
||||||
|
|
||||||
self.assertRaises(PlayerNotFound, self.commands.add_shop, 0, 0, shop_name='test shop',
|
self.assertRaises(PlayerNotFound, self.commands.add_shop, 0, 0, shop_name='test shop',
|
||||||
mc_uuid='fe7e84132570458892032b69ff188bc3')
|
mc_uuid='fe7e84132570458892032b69ff188bc3')
|
||||||
|
|
Loading…
Reference in New Issue