Added support for setting the dimension of a location

+ This is internal information at the moment, but may be visible later.
doc_update
Joey Hines 2020-01-08 14:24:17 -06:00
parent 76714a7736
commit cb8a1586a2
2 changed files with 24 additions and 16 deletions

View File

@ -116,7 +116,7 @@ def get_location(owner, name=None, loc_type=Location):
return loc return loc
def add_location(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None, loc_type=Location): def add_location(x_pos, z_pos, dimension, name=None, discord_uuid=None, mc_uuid=None, loc_type=Location):
player = get_player(discord_uuid, mc_uuid) player = get_player(discord_uuid, mc_uuid)
name_was_none = False name_was_none = False
@ -130,7 +130,7 @@ def add_location(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None, loc_t
else: else:
raise EntryNameNotUniqueError raise EntryNameNotUniqueError
else: else:
location = loc_type.objects.create(name=name, x_coord=x_pos, z_coord=z_pos) location = loc_type.objects.create(name=name, x_coord=x_pos, z_coord=z_pos, dimension=dimension)
location.owner.add(player) location.owner.add(player)
location.save() location.save()
@ -166,11 +166,12 @@ def register(player_name, discord_uuid=None):
@command(RequestTypes.POST) @command(RequestTypes.POST)
def add_base(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None): def add_base(x_pos, z_pos, dimension="O", 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 dimension: MC Dimension
:param name: Base Name (If None, Defaults to Player's Base) :param name: Base Name (If None, Defaults to Player's Base)
:param discord_uuid: Discord UUID :param discord_uuid: Discord UUID
:param mc_uuid: Minecraft UUID :param mc_uuid: Minecraft UUID
@ -179,15 +180,16 @@ def add_base(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
:help: Adds your base to the database. :help: Adds your base to the database.
""" """
return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Base) return add_location(x_pos, z_pos, dimension, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Base)
@command(RequestTypes.POST) @command(RequestTypes.POST)
def add_shop(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None): def add_shop(x_pos, z_pos, dimension="O", 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 dimension: MC Dimension
:param name: Shop Name (If None, Defaults to Player's Shop) :param name: Shop Name (If None, Defaults to Player's Shop)
:param discord_uuid: Discord UUID :param discord_uuid: Discord UUID
:param mc_uuid: Minecraft UUID :param mc_uuid: Minecraft UUID
@ -196,15 +198,16 @@ def add_shop(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
:help: Adds your shop to the database. :help: Adds your shop to the database.
""" """
return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Shop) return add_location(x_pos, z_pos, dimension, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Shop)
@command(RequestTypes.POST) @command(RequestTypes.POST)
def add_town(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None): def add_town(x_pos, z_pos, dimension="O", 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 dimension: MC Dimension
:param name: Town Name (If None, Defaults to Player's Town) :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
@ -213,15 +216,16 @@ def add_town(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
:help: Adds your town to the database. :help: Adds your town to the database.
""" """
return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Town) return add_location(x_pos, z_pos, dimension, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Town)
@command(RequestTypes.POST) @command(RequestTypes.POST)
def add_farm(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None): def add_farm(x_pos, z_pos, dimension="O", 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 dimension: MC Dimension
:param name: Farm Name (If None, Defaults to Player's Farm) :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
@ -234,11 +238,12 @@ def add_farm(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
@command(RequestTypes.POST) @command(RequestTypes.POST)
def add_market(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None): def add_market(x_pos, z_pos, dimension="O", 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 dimension: MC Dimension
:param name: Market Name (If None, Defaults to Player's Market) :param name: Market Name (If None, Defaults to Player's Market)
:param discord_uuid: Discord UUID :param discord_uuid: Discord UUID
:param mc_uuid: Minecraft UUID :param mc_uuid: Minecraft UUID
@ -247,15 +252,16 @@ def add_market(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
:help: Adds your market to the database. :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) return add_location(x_pos, z_pos, dimension, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Market)
@command(RequestTypes.POST) @command(RequestTypes.POST)
def add_attraction(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None): def add_attraction(x_pos, z_pos, dimension="O", 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 dimension: MC Dimension
:param name: Market Name (If None, Defaults to Player's Attraction) :param name: Market Name (If None, Defaults to Player's Attraction)
:param discord_uuid: Discord UUID :param discord_uuid: Discord UUID
:param mc_uuid: Minecraft UUID :param mc_uuid: Minecraft UUID
@ -264,7 +270,7 @@ def add_attraction(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
:help: Adds your attraction to the database. :help: Adds your attraction to the database.
""" """
return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Attraction) return add_location(x_pos, z_pos, dimension, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Attraction)
@command(RequestTypes.POST) @command(RequestTypes.POST)
@ -543,11 +549,12 @@ def tunnel(player_name):
@command(RequestTypes.POST) @command(RequestTypes.POST)
def edit_pos(x, z, loc_name, discord_uuid=None, mc_uuid=None): def edit_pos(x, z, loc_name, dimension="O", discord_uuid=None, mc_uuid=None):
""" """
:request: POST :request: POST
:param x: New MC X coordinate :param x: New MC X coordinate
:param z: New MC Z Coordinate :param z: New MC Z Coordinate
:param dimension: MC Dimension
:param loc_name: Location Name to edit :param loc_name: Location Name to edit
:param discord_uuid: Discord UUID :param discord_uuid: Discord UUID
:param mc_uuid: MC UUID :param mc_uuid: MC UUID
@ -562,6 +569,7 @@ def edit_pos(x, z, loc_name, discord_uuid=None, mc_uuid=None):
location.x_coord = x location.x_coord = x
location.z_coord = z location.z_coord = z
location.dimension = dimension
location.save() location.save()
return location.json return location.json

View File

@ -52,7 +52,7 @@ class CommandsAPITestCase(TestCase):
self.assertRaises(PlayerInDBError, register, player_name="Notch", discord_uuid="229423434256351233") self.assertRaises(PlayerInDBError, register, player_name="Notch", discord_uuid="229423434256351233")
def test_add_base(self): def test_add_base(self):
add_base(x_pos=0, z_pos=0, name=None, discord_uuid=DISCORD_UUID) add_base(x_pos=0, z_pos=0, dimension="O", name=None, discord_uuid=DISCORD_UUID)
base = Base.objects.filter(name__icontains=USERNAME).all().first() base = Base.objects.filter(name__icontains=USERNAME).all().first()
@ -234,7 +234,7 @@ class CommandsAPITestCase(TestCase):
resource = add_resource(resource_name="sed", farm_name="test farm", discord_uuid=DISCORD_UUID) resource = add_resource(resource_name="sed", farm_name="test farm", discord_uuid=DISCORD_UUID)
delete_resource(resource_name="sed", farm_name="test farm", discord_uuid=DISCORD_UUID) delete_resource(resource="sed", farm_name="test farm", discord_uuid=DISCORD_UUID)
farm = PublicFarm.objects.filter(resource__resource_name__icontains="sed").all() farm = PublicFarm.objects.filter(resource__resource_name__icontains="sed").all()