Added edit commands for locations
parent
87ca99f146
commit
5b0027668b
76
Commands.py
76
Commands.py
|
@ -1,4 +1,6 @@
|
||||||
from DatabaseInterface import *
|
from DatabaseInterface import *
|
||||||
|
from itertools import zip_longest
|
||||||
|
from discord.ext.commands import UserInputError
|
||||||
|
|
||||||
|
|
||||||
class Commands:
|
class Commands:
|
||||||
|
@ -33,7 +35,7 @@ class Commands:
|
||||||
|
|
||||||
return player_name
|
return player_name
|
||||||
|
|
||||||
def addbase(self, x_pos, z_pos, base_name=None, discord_uuid=None, mc_uuid=None):
|
def add_base(self, x_pos, z_pos, base_name=None, discord_uuid=None, mc_uuid=None):
|
||||||
|
|
||||||
session = self.interface.database.Session()
|
session = self.interface.database.Session()
|
||||||
|
|
||||||
|
@ -46,7 +48,7 @@ class Commands:
|
||||||
elif base_name is None:
|
elif base_name is None:
|
||||||
raise EntryNameNotUniqueError
|
raise EntryNameNotUniqueError
|
||||||
|
|
||||||
base = self.interface.add_location(session, player, base_name, x_pos, z_pos)
|
base = self.interface.add_base(session, player, base_name, x_pos, z_pos)
|
||||||
|
|
||||||
base_str = base.__str__()
|
base_str = base.__str__()
|
||||||
finally:
|
finally:
|
||||||
|
@ -54,7 +56,7 @@ class Commands:
|
||||||
|
|
||||||
return base_str
|
return base_str
|
||||||
|
|
||||||
def addshop(self, x_pos, z_pos, shop_str=None, discord_uuid=None, mc_uuid=None):
|
def add_shop(self, x_pos, z_pos, shop_str=None, discord_uuid=None, mc_uuid=None):
|
||||||
session = self.interface.database.Session()
|
session = self.interface.database.Session()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -74,7 +76,7 @@ class Commands:
|
||||||
|
|
||||||
return shop_str
|
return shop_str
|
||||||
|
|
||||||
def addtunnel(self, tunnel_color, tunnel_number, location_name, discord_uuid=None, mc_uuid=None):
|
def add_tunnel(self, tunnel_color, tunnel_number, location_name, discord_uuid=None, mc_uuid=None):
|
||||||
|
|
||||||
session = self.interface.database.Session()
|
session = self.interface.database.Session()
|
||||||
try:
|
try:
|
||||||
|
@ -106,7 +108,7 @@ class Commands:
|
||||||
finally:
|
finally:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
def findaround(self, x_pos, z_pos, radius=200, dimension='Overworld'):
|
def find_around(self, x_pos, z_pos, radius=200, dimension='Overworld'):
|
||||||
|
|
||||||
session = self.interface.database.Session()
|
session = self.interface.database.Session()
|
||||||
|
|
||||||
|
@ -117,7 +119,7 @@ class Commands:
|
||||||
|
|
||||||
return loc_list
|
return loc_list
|
||||||
|
|
||||||
def additem(self, item_name, quantity, diamond_price, shop_name, discord_uuid=None, mc_uuid=None):
|
def add_item(self, item_name, quantity, diamond_price, shop_name, discord_uuid=None, mc_uuid=None):
|
||||||
session = self.interface.database.Session()
|
session = self.interface.database.Session()
|
||||||
try:
|
try:
|
||||||
player = self.get_player(session, discord_uuid, mc_uuid)
|
player = self.get_player(session, discord_uuid, mc_uuid)
|
||||||
|
@ -176,3 +178,65 @@ class Commands:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
return tunnel_str
|
return tunnel_str
|
||||||
|
|
||||||
|
def edit_pos(self, x, z, loc_name, discord_uuid=None, mc_uuid=None):
|
||||||
|
session = self.interface.database.Session()
|
||||||
|
|
||||||
|
try:
|
||||||
|
player = self.get_player(session, discord_uuid=discord_uuid, mc_uuid=mc_uuid)
|
||||||
|
location = self.interface.find_location_by_name_and_owner(session, player, loc_name)[0]
|
||||||
|
|
||||||
|
location.x = x
|
||||||
|
location.z = z
|
||||||
|
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
loc_str = location.__str__()
|
||||||
|
except IndexError:
|
||||||
|
raise LocationLookUpError
|
||||||
|
finally:
|
||||||
|
session.close()
|
||||||
|
|
||||||
|
return loc_str
|
||||||
|
|
||||||
|
def edit_tunnel(self, tunnel_color, tunnel_number, loc_name, discord_uuid=None, mc_uuid=None):
|
||||||
|
session = self.interface.database.Session()
|
||||||
|
|
||||||
|
try:
|
||||||
|
player = self.get_player(session, discord_uuid=discord_uuid, mc_uuid=mc_uuid)
|
||||||
|
location = self.interface.find_location_by_name_and_owner(session, player, loc_name)[0]
|
||||||
|
|
||||||
|
if location.tunnel is not None:
|
||||||
|
location.tunnel.tunnel_direction = TunnelDirection.str_to_tunnel_dir(tunnel_color)
|
||||||
|
location.tunnel.tunnel_number = tunnel_number
|
||||||
|
else:
|
||||||
|
self.interface.add_tunnel(session, player, tunnel_color, tunnel_number, loc_name)
|
||||||
|
|
||||||
|
loc_str = location.__str__()
|
||||||
|
|
||||||
|
session.commit()
|
||||||
|
except IndexError:
|
||||||
|
raise LocationLookUpError
|
||||||
|
finally:
|
||||||
|
session.close()
|
||||||
|
|
||||||
|
return loc_str
|
||||||
|
|
||||||
|
def edit_name(self, new_name, loc_name, discord_uuid=None, mc_uuid=None):
|
||||||
|
session = self.interface.database.Session()
|
||||||
|
|
||||||
|
try:
|
||||||
|
player = self.get_player(session, discord_uuid=discord_uuid, mc_uuid=mc_uuid)
|
||||||
|
location = self.interface.find_location_by_name_and_owner(session, player, loc_name)[0]
|
||||||
|
|
||||||
|
location.name = new_name
|
||||||
|
loc_str = location.__str__()
|
||||||
|
session.commit()
|
||||||
|
except IndexError:
|
||||||
|
raise LocationLookUpError
|
||||||
|
finally:
|
||||||
|
session.close()
|
||||||
|
|
||||||
|
return loc_str
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ class DatabaseInterface:
|
||||||
def __init__(self, db_engine_arg):
|
def __init__(self, db_engine_arg):
|
||||||
self.database = GeoffreyDatabase(db_engine_arg)
|
self.database = GeoffreyDatabase(db_engine_arg)
|
||||||
|
|
||||||
def add_location(self, session, owner, name, x_pos, z_pos, dimension=None):
|
def add_base(self, session, owner, name, x_pos, z_pos, dimension=None):
|
||||||
location = Location(name, x_pos, z_pos, owner, dimension)
|
base = Base(name, x_pos, z_pos, owner, dimension)
|
||||||
self.database.add_object(session, location)
|
self.database.add_object(session, base)
|
||||||
return location
|
return base
|
||||||
|
|
||||||
def add_shop(self, session, owner, name, x_pos, z_pos, dimension=None):
|
def add_shop(self, session, owner, name, x_pos, z_pos, dimension=None):
|
||||||
shop = Shop(name, x_pos, z_pos, owner, dimension)
|
shop = Shop(name, x_pos, z_pos, owner, dimension)
|
||||||
|
|
|
@ -8,6 +8,8 @@ from difflib import SequenceMatcher
|
||||||
|
|
||||||
from BotErrors import *
|
from BotErrors import *
|
||||||
from MinecraftAccountInfoGrabber import *
|
from MinecraftAccountInfoGrabber import *
|
||||||
|
world_name = 'season3'
|
||||||
|
|
||||||
|
|
||||||
SQL_Base = declarative_base()
|
SQL_Base = declarative_base()
|
||||||
|
|
||||||
|
@ -204,8 +206,8 @@ class Location(SQL_Base):
|
||||||
raise LocationInitError
|
raise LocationInitError
|
||||||
|
|
||||||
def dynmap_link(self):
|
def dynmap_link(self):
|
||||||
return '<http://24carrotcraft.com:8123/?worldname=season3&mapname=surface&zoom=4&x={}&y=65&z={}>'.\
|
return '<http://24carrotcraft.com:8123/?worldname={}&mapname=surface&zoom=4&x={}&y=65&z={}>'.\
|
||||||
format(self.x, self.z)
|
format(world_name, self.x, self.z)
|
||||||
|
|
||||||
def pos_to_str(self):
|
def pos_to_str(self):
|
||||||
return '(x= {}, z= {}) in the {}'.format(self.x, self.z, self.dimension.value.title())
|
return '(x= {}, z= {}) in the {}'.format(self.x, self.z, self.dimension.value.title())
|
||||||
|
@ -224,6 +226,16 @@ class Location(SQL_Base):
|
||||||
return self.info_str()
|
return self.info_str()
|
||||||
|
|
||||||
|
|
||||||
|
class Base(Location):
|
||||||
|
__tablename__ = 'Bases'
|
||||||
|
base_id = Column(Integer, ForeignKey('Locations.id', ondelete='CASCADE'), primary_key=True)
|
||||||
|
name = column_property(Column(String(128)), Location.name)
|
||||||
|
|
||||||
|
__mapper_args__ = {
|
||||||
|
'polymorphic_identity': 'Base',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Shop(Location):
|
class Shop(Location):
|
||||||
__tablename__ = 'Shops'
|
__tablename__ = 'Shops'
|
||||||
shop_id = Column(Integer, ForeignKey('Locations.id', ondelete='CASCADE'), primary_key=True)
|
shop_id = Column(Integer, ForeignKey('Locations.id', ondelete='CASCADE'), primary_key=True)
|
||||||
|
|
78
Geoffrey.py
78
Geoffrey.py
|
@ -90,13 +90,13 @@ async def addbase(ctx, x_pos: int, z_pos: int, * args):
|
||||||
'''
|
'''
|
||||||
Adds your base to the database.
|
Adds your base to the database.
|
||||||
The name is optional.
|
The name is optional.
|
||||||
?addbase [X Coordinate] [Y Coordinate] [Z Coordinate] [Base Name]
|
?addbase [X Coordinate] [Z Coordinate] [Base Name]
|
||||||
'''
|
'''
|
||||||
|
|
||||||
name = get_name(args)
|
name = get_name(args)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
base = bot_commands.addbase(x_pos, z_pos, base_name=name, discord_uuid=ctx.message.author.id)
|
base = bot_commands.add_base(x_pos, z_pos, base_name=name, discord_uuid=ctx.message.author.id)
|
||||||
await bot.say('{}, your base has been added to the database: \n\n{}'.format(ctx.message.author.mention, base))
|
await bot.say('{}, your base has been added to the database: \n\n{}'.format(ctx.message.author.mention, base))
|
||||||
except LocationInitError:
|
except LocationInitError:
|
||||||
raise commands.UserInputError
|
raise commands.UserInputError
|
||||||
|
@ -115,13 +115,13 @@ async def addshop(ctx, x_pos: int, z_pos: int, *args):
|
||||||
'''
|
'''
|
||||||
Adds your shop to the database.
|
Adds your shop to the database.
|
||||||
The name is optional.
|
The name is optional.
|
||||||
?addshop [X Coordinate] [Y Coordinate] [Z Coordinate] [Shop Name]
|
?addshop [X Coordinate] [Z Coordinate] [Shop Name]
|
||||||
'''
|
'''
|
||||||
|
|
||||||
name = get_name(args)
|
name = get_name(args)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shop = bot_commands.addshop(x_pos, z_pos, shop_str=name, discord_uuid=ctx.message.author.id)
|
shop = bot_commands.add_shop(x_pos, z_pos, shop_str=name, discord_uuid=ctx.message.author.id)
|
||||||
await bot.say('{}, your shop has been added to the database: \n\n{}'.format(ctx.message.author.mention, shop))
|
await bot.say('{}, your shop has been added to the database: \n\n{}'.format(ctx.message.author.mention, shop))
|
||||||
except LocationInitError:
|
except LocationInitError:
|
||||||
raise commands.UserInputError
|
raise commands.UserInputError
|
||||||
|
@ -143,9 +143,9 @@ async def addtunnel(ctx, tunnel_color: str, tunnel_number: int, *args):
|
||||||
?tunnel [Tunnel Color] [Tunnel Number] [Location Name]
|
?tunnel [Tunnel Color] [Tunnel Number] [Location Name]
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
location_name = get_name(args)
|
loc_name = get_name(args)
|
||||||
|
|
||||||
bot_commands.addtunnel(tunnel_color, tunnel_number, discord_uuid=ctx.message.author.id, location_name=location_name)
|
bot_commands.add_tunnel(tunnel_color, tunnel_number, discord_uuid=ctx.message.author.id, location_name=loc_name)
|
||||||
await bot.say('{}, your tunnel has been added to the database'.format(ctx.message.author.mention))
|
await bot.say('{}, your tunnel has been added to the database'.format(ctx.message.author.mention))
|
||||||
except EntryNameNotUniqueError:
|
except EntryNameNotUniqueError:
|
||||||
await bot.say('{}, you already have one tunnel in the database, please specify a location.'.format(
|
await bot.say('{}, you already have one tunnel in the database, please specify a location.'.format(
|
||||||
|
@ -153,9 +153,9 @@ async def addtunnel(ctx, tunnel_color: str, tunnel_number: int, *args):
|
||||||
return
|
return
|
||||||
except LocationLookUpError:
|
except LocationLookUpError:
|
||||||
await bot.say('{}, you do not have a location called **{}**.'.format(
|
await bot.say('{}, you do not have a location called **{}**.'.format(
|
||||||
ctx.message.author.mention, args[0]))
|
ctx.message.author.mention, loc_name))
|
||||||
except LocationHasTunnelError:
|
except LocationHasTunnelError:
|
||||||
await bot.say('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, args[0]))
|
await bot.say('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, loc_name))
|
||||||
except TunnelInitError:
|
except TunnelInitError:
|
||||||
await bot.say('{}, invalid tunnel color.'.format(ctx.message.author.mention))
|
await bot.say('{}, invalid tunnel color.'.format(ctx.message.author.mention))
|
||||||
except InvalidTunnelError:
|
except InvalidTunnelError:
|
||||||
|
@ -245,7 +245,7 @@ async def findaround(ctx, x_pos: int, z_pos: int, * args):
|
||||||
if args[1] == '-d':
|
if args[1] == '-d':
|
||||||
dimension = args[2]
|
dimension = args[2]
|
||||||
|
|
||||||
base_string = bot_commands.findaround(x_pos, z_pos, radius, dimension)
|
base_string = bot_commands.find_around(x_pos, z_pos, radius, dimension)
|
||||||
|
|
||||||
if len(base_string) != 0:
|
if len(base_string) != 0:
|
||||||
await bot.say('{}, the following locations(s) within **{}** blocks of that point: \n {}'.format(
|
await bot.say('{}, the following locations(s) within **{}** blocks of that point: \n {}'.format(
|
||||||
|
@ -269,7 +269,7 @@ async def additem(ctx, item_name: str, quantity: int, diamond_price: int, * args
|
||||||
try:
|
try:
|
||||||
shop_name = get_name(args)
|
shop_name = get_name(args)
|
||||||
|
|
||||||
bot_commands.additem(item_name, quantity, diamond_price, shop_name=shop_name,
|
bot_commands.add_item(item_name, quantity, diamond_price, shop_name=shop_name,
|
||||||
discord_uuid=ctx.message.author.id)
|
discord_uuid=ctx.message.author.id)
|
||||||
await bot.say('{}, **{}** has been added to the inventory of your shop.'.format(ctx.message.author.mention,
|
await bot.say('{}, **{}** has been added to the inventory of your shop.'.format(ctx.message.author.mention,
|
||||||
item_name))
|
item_name))
|
||||||
|
@ -317,9 +317,63 @@ async def info(ctx, * args):
|
||||||
info_str = bot_commands.info(loc)
|
info_str = bot_commands.info(loc)
|
||||||
await bot.say(info_str)
|
await bot.say(info_str)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
await bot.say('{}, no locations in the database match {}.'.format(ctx.message.author.mention, name))
|
await bot.say('{}, no locations in the database match {}.'.format(ctx.message.author.mention, loc))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@commands.cooldown(5, 60, commands.BucketType.user)
|
||||||
|
@bot.command(pass_context=True)
|
||||||
|
async def edit_pos(ctx, x_pos: int, y_pos: int, * args):
|
||||||
|
'''
|
||||||
|
Edits the position of a location
|
||||||
|
|
||||||
|
?edit_pos [X Coordinate] [Z Coordinate] [Location Name]
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
loc = get_name(args)
|
||||||
|
loc_str = bot_commands.edit_pos(x_pos, y_pos, loc, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
await bot.say('{}, the following location has been updated: \n\n{}'.format(ctx.message.author.mention, loc_str))
|
||||||
|
except LocationLookUpError:
|
||||||
|
await bot.say('{}, you do not have a location called **{}**.'.format(
|
||||||
|
ctx.message.author.mention, loc))
|
||||||
|
|
||||||
|
|
||||||
|
@commands.cooldown(5, 60, commands.BucketType.user)
|
||||||
|
@bot.command(pass_context=True)
|
||||||
|
async def edit_tunnel(ctx, tunnel_color: str, tunnel_number: int, * args):
|
||||||
|
'''
|
||||||
|
Edits the tunnel of a location
|
||||||
|
|
||||||
|
?edit_tunnel [Tunnel Color] [Tunnel Number] [Location Name]
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
loc = get_name(args)
|
||||||
|
loc_str = bot_commands.edit_tunnel(tunnel_color, tunnel_number, loc, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
await bot.say('{}, the following location has been updated: \n\n{}'.format(ctx.message.author.mention, loc_str))
|
||||||
|
except LocationLookUpError:
|
||||||
|
await bot.say('{}, you do not have a location called **{}**.'.format(
|
||||||
|
ctx.message.author.mention, loc))
|
||||||
|
|
||||||
|
@commands.cooldown(5, 60, commands.BucketType.user)
|
||||||
|
@bot.command(pass_context=True)
|
||||||
|
async def edit_name(ctx, new_name: str, current_name: str):
|
||||||
|
'''
|
||||||
|
Edits the name of a location
|
||||||
|
|
||||||
|
IF A NAME HAS SPACES IN IT YOU NEED TO WRAP IT IN QUOTATION MARKS. ie "Cool Shop 123"
|
||||||
|
?edit_name [New Name] [Current Name]
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
loc_str = bot_commands.edit_name(new_name, current_name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
await bot.say('{}, the following location has been updated: \n\n{}'.format(ctx.message.author.mention, loc_str))
|
||||||
|
except LocationLookUpError:
|
||||||
|
await bot.say('{}, you do not have a location called **{}**.'.format(
|
||||||
|
ctx.message.author.mention, current_name))
|
||||||
|
|
||||||
|
|
||||||
# Helper Functions ************************************************************
|
# Helper Functions ************************************************************
|
||||||
|
|
||||||
def get_name(args):
|
def get_name(args):
|
||||||
|
@ -344,7 +398,7 @@ def get_nickname(discord_user):
|
||||||
|
|
||||||
def get_args_dict(args):
|
def get_args_dict(args):
|
||||||
if len(args) != 0:
|
if len(args) != 0:
|
||||||
return dict(zip_longest(*[iter(args)] * 2, fillvalue=""))
|
return dict(zip_longest(*[iter(args)] * 2, fillvalue=" "))
|
||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
def test_addbase(self):
|
def test_addbase(self):
|
||||||
player_name = self.commands.register('ZeroHD', '143072699567177728')
|
player_name = self.commands.register('ZeroHD', '143072699567177728')
|
||||||
base = self.commands.addbase(0, 0, discord_uuid='143072699567177728')
|
base = self.commands.add_base(0, 0, discord_uuid='143072699567177728')
|
||||||
|
|
||||||
if player_name not in base:
|
if player_name not in base:
|
||||||
self.fail()
|
self.fail()
|
||||||
|
@ -42,7 +42,7 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
def test_addshop(self):
|
def test_addshop(self):
|
||||||
player_name = self.commands.register('ZeroHD', '143072699567177728')
|
player_name = self.commands.register('ZeroHD', '143072699567177728')
|
||||||
shop = self.commands.addshop(0, 0, discord_uuid='143072699567177728')
|
shop = self.commands.add_shop(0, 0, discord_uuid='143072699567177728')
|
||||||
|
|
||||||
if player_name not in shop:
|
if player_name not in shop:
|
||||||
self.fail()
|
self.fail()
|
||||||
|
@ -51,24 +51,24 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
def test_addtunnel(self):
|
def test_addtunnel(self):
|
||||||
self.commands.register('ZeroHD', '143072699567177728')
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
self.commands.addshop(0, 0, shop_str='test shop', discord_uuid='143072699567177728')
|
self.commands.add_shop(0, 0, shop_str='test shop', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
tunnel1 = self.commands.addtunnel('green', 50, None, discord_uuid='143072699567177728')
|
tunnel1 = self.commands.add_tunnel('green', 50, None, discord_uuid='143072699567177728')
|
||||||
|
|
||||||
self.assertGreater(len(tunnel1), 0)
|
self.assertGreater(len(tunnel1), 0)
|
||||||
|
|
||||||
tunnel2 = self.commands.addtunnel('Green', 50, location_name='test_shop', discord_uuid='143072699567177728')
|
tunnel2 = self.commands.add_tunnel('Green', 50, location_name='test_shop', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
if 'Green' not in tunnel2:
|
if 'Green' not in tunnel2:
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
self.assertRaises(LocationHasTunnelError, self.commands.addtunnel, 'Blue', 50, location_name='test_shop',
|
self.assertRaises(LocationHasTunnelError, self.commands.add_tunnel, 'Blue', 50, location_name='test_shop',
|
||||||
discord_uuid='143072699567177728')
|
discord_uuid='143072699567177728')
|
||||||
|
|
||||||
def test_find(self):
|
def test_find(self):
|
||||||
self.commands.register('ZeroHD', '143072699567177728')
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
self.commands.addshop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
self.commands.add_shop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
||||||
self.commands.addbase(0, 0, 'heck', discord_uuid='143072699567177728')
|
self.commands.add_base(0, 0, 'heck', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
result = self.commands.find('zerohd')
|
result = self.commands.find('zerohd')
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
self.commands.register('ZeroHD', '143072699567177728')
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
self.commands.addshop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
self.commands.add_shop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
self.commands.delete('frick', discord_uuid='143072699567177728')
|
self.commands.delete('frick', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
|
@ -87,9 +87,9 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
def test_findaround(self):
|
def test_findaround(self):
|
||||||
self.commands.register('ZeroHD', '143072699567177728')
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
self.commands.addshop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
self.commands.add_shop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
result = self.commands.findaround(0, 0)
|
result = self.commands.find_around(0, 0)
|
||||||
|
|
||||||
if 'frick' in result:
|
if 'frick' in result:
|
||||||
pass
|
pass
|
||||||
|
@ -98,18 +98,18 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
def test_additem(self):
|
def test_additem(self):
|
||||||
self.commands.register('ZeroHD', '143072699567177728')
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
self.commands.addshop(0, 0, discord_uuid='143072699567177728')
|
self.commands.add_shop(0, 0, discord_uuid='143072699567177728')
|
||||||
|
|
||||||
result = self.commands.additem('dirt', 5, 5, None, discord_uuid='143072699567177728')
|
result = self.commands.add_item('dirt', 5, 5, None, discord_uuid='143072699567177728')
|
||||||
|
|
||||||
if 'dirt' in result:
|
if 'dirt' in result:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
self.commands.addshop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
self.commands.add_shop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
result = self.commands.additem('cool', 5, 5, shop_name='frick', discord_uuid='143072699567177728')
|
result = self.commands.add_item('cool', 5, 5, shop_name='frick', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
if 'cool' in result:
|
if 'cool' in result:
|
||||||
pass
|
pass
|
||||||
|
@ -118,9 +118,9 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
def test_selling(self):
|
def test_selling(self):
|
||||||
self.commands.register('ZeroHD', '143072699567177728')
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
self.commands.addshop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
self.commands.add_shop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
self.commands.additem('cool', 5, 5, shop_name='frick', discord_uuid='143072699567177728')
|
self.commands.add_item('cool', 5, 5, shop_name='frick', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
result = self.commands.selling('cool')
|
result = self.commands.selling('cool')
|
||||||
|
|
||||||
|
@ -131,9 +131,9 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
def test_info(self):
|
def test_info(self):
|
||||||
self.commands.register('ZeroHD', '143072699567177728')
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
self.commands.addshop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
self.commands.add_shop(0, 0, shop_str='frick', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
self.commands.addtunnel('Green', 50, location_name='frick', discord_uuid='143072699567177728')
|
self.commands.add_tunnel('Green', 50, location_name='frick', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
result = self.commands.info('frick')
|
result = self.commands.info('frick')
|
||||||
|
|
||||||
|
@ -144,9 +144,9 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
def test_tunnel(self):
|
def test_tunnel(self):
|
||||||
self.commands.register('ZeroHD', '143072699567177728')
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
self.commands.addshop(0, 0, shop_str='test shop', discord_uuid='143072699567177728')
|
self.commands.add_shop(0, 0, shop_str='test shop', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
tunnel = self.commands.addtunnel('green', 50, None, discord_uuid='143072699567177728')
|
tunnel = self.commands.add_tunnel('green', 50, None, discord_uuid='143072699567177728')
|
||||||
|
|
||||||
result = self.commands.tunnel('ZeroHD')
|
result = self.commands.tunnel('ZeroHD')
|
||||||
|
|
||||||
|
@ -155,4 +155,43 @@ class TestCommands(TestCase):
|
||||||
else:
|
else:
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
|
def test_edit_name(self):
|
||||||
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
|
self.commands.add_shop(0, 0, shop_str='test shop', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
|
self.commands.edit_name('cool shop', 'test shop', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
|
result = self.commands.info('cool shop')
|
||||||
|
|
||||||
|
if 'cool' in result:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.fail()
|
||||||
|
|
||||||
|
def test_edit_pos(self):
|
||||||
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
|
self.commands.add_shop(0, 0, shop_str='test shop', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
|
self.commands.edit_pos(500, 500, 'test shop', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
|
result = self.commands.info('test shop')
|
||||||
|
|
||||||
|
if '500' in result:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.fail()
|
||||||
|
|
||||||
|
def test_edit_tunnel(self):
|
||||||
|
self.commands.register('ZeroHD', '143072699567177728')
|
||||||
|
self.commands.add_shop(0, 0, shop_str='test shop', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
|
self.commands.edit_tunnel('green', 500, 'test shop', discord_uuid='143072699567177728')
|
||||||
|
|
||||||
|
result = self.commands.info('test shop')
|
||||||
|
|
||||||
|
if 'Green' in result:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.fail()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TestGeoffreyDatabase(TestCase):
|
||||||
return player
|
return player
|
||||||
|
|
||||||
def add_loc(self, player):
|
def add_loc(self, player):
|
||||||
loc = self.commands.interface.add_location(self.session, player, 'test', 0, 0)
|
loc = self.commands.interface.add_base(self.session, player, 'test', 0, 0)
|
||||||
return loc
|
return loc
|
||||||
|
|
||||||
def test_add_object(self):
|
def test_add_object(self):
|
||||||
|
@ -205,7 +205,7 @@ class TestGeoffreyDatabase(TestCase):
|
||||||
def test_big_input(self):
|
def test_big_input(self):
|
||||||
owner = self.add_player()
|
owner = self.add_player()
|
||||||
|
|
||||||
self.assertRaises(DatabaseValueError, self.commands.interface.add_location, self.session, owner,
|
self.assertRaises(DatabaseValueError, self.commands.interface.add_base, self.session, owner,
|
||||||
'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT'
|
'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT'
|
||||||
'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT'
|
'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT'
|
||||||
'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT', 0, 0,)
|
'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT', 0, 0,)
|
||||||
|
@ -214,7 +214,7 @@ class TestGeoffreyDatabase(TestCase):
|
||||||
owner = self.add_player()
|
owner = self.add_player()
|
||||||
self.add_loc(owner)
|
self.add_loc(owner)
|
||||||
|
|
||||||
self.assertRaises(EntryNameNotUniqueError, self.commands.interface.add_location, self.session,
|
self.assertRaises(EntryNameNotUniqueError, self.commands.interface.add_base, self.session,
|
||||||
owner, 'test', 0, 0, 0)
|
owner, 'test', 0, 0, 0)
|
||||||
|
|
||||||
def test_delete_parent(self):
|
def test_delete_parent(self):
|
||||||
|
|
Loading…
Reference in New Issue