You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.2 KiB
33 lines
1.2 KiB
'taoshengshi'
|
|
|
|
#HEADER
|
|
|
|
from evennia import create_object, search_object
|
|
from typeclasses import exits, objects, rooms
|
|
from typeclasses.mech import Mech
|
|
|
|
def move_or_create(typeclass, key, aliases=[], location=None, destination=None):
|
|
objects = search_object(key)
|
|
# TODO: This only errors if typeclass is different...it should error if 2 objects have the same key or aliases
|
|
matching_objects = list(filter(lambda x: type(x) == typeclass, objects))
|
|
if len(matching_objects) > 1:
|
|
caller.msg(f"ERROR: More than one object found for '{key}'")
|
|
raise
|
|
if not matching_objects:
|
|
caller.msg(f"Creating '{key}'")
|
|
return create_object(typeclass, key=key, aliases=aliases, location=location, destination=destination)
|
|
current_object = matching_objects[0]
|
|
if location != current_object.location:
|
|
caller.msg(f"Moving '{key}' to '{destination}'")
|
|
current_object.move_to(destination)
|
|
return current_object
|
|
|
|
caller.msg(f'Leaving {key} alone')
|
|
return current_object
|
|
|
|
# Rooms (defined here to be available to all files)
|
|
limbo = search_object('Limbo')[0]
|
|
cave = move_or_create(rooms.Room, key='cave')
|
|
lobby = move_or_create(rooms.Room, key='lobby')
|
|
|
|
#INSERT taoshengshi.cave
|
|
|