Fix merge conflicts
This commit is contained in:
commit
90b42ca6fb
47 changed files with 1682 additions and 201 deletions
|
|
@ -1040,6 +1040,11 @@ class CmdLink(COMMAND_DEFAULT_CLASS):
|
|||
if not target:
|
||||
return
|
||||
|
||||
if target == obj:
|
||||
self.caller.msg("Cannot link an object to itself.")
|
||||
return
|
||||
|
||||
|
||||
string = ""
|
||||
note = "Note: %s(%s) did not have a destination set before. Make sure you linked the right thing."
|
||||
if not obj.destination:
|
||||
|
|
@ -1123,6 +1128,7 @@ class CmdSetHome(CmdLink):
|
|||
|
||||
Usage:
|
||||
@sethome <obj> [= <home_location>]
|
||||
@sethom <obj>
|
||||
|
||||
The "home" location is a "safety" location for objects; they
|
||||
will be moved there if their current location ceases to exist. All
|
||||
|
|
@ -1162,10 +1168,10 @@ class CmdSetHome(CmdLink):
|
|||
old_home = obj.home
|
||||
obj.home = new_home
|
||||
if old_home:
|
||||
string = "%s's home location was changed from %s(%s) to %s(%s)." % (
|
||||
string = "Home location of %s was changed from %s(%s) to %s(%s)." % (
|
||||
obj, old_home, old_home.dbref, new_home, new_home.dbref)
|
||||
else:
|
||||
string = "%s' home location was set to %s(%s)." % (obj, new_home, new_home.dbref)
|
||||
string = "Home location of %s was set to %s(%s)." % (obj, new_home, new_home.dbref)
|
||||
self.caller.msg(string)
|
||||
|
||||
|
||||
|
|
@ -1430,37 +1436,6 @@ def _convert_from_string(cmd, strobj):
|
|||
string this will always fail).
|
||||
"""
|
||||
|
||||
def rec_convert(obj):
|
||||
"""
|
||||
Helper function of recursive conversion calls. This is only
|
||||
used for Python <=2.5. After that literal_eval is available.
|
||||
"""
|
||||
# simple types
|
||||
try:
|
||||
return int(obj)
|
||||
except ValueError:
|
||||
# obj cannot be converted to int - that's fine
|
||||
pass
|
||||
try:
|
||||
return float(obj)
|
||||
except ValueError:
|
||||
# obj cannot be converted to float - that's fine
|
||||
pass
|
||||
# iterables
|
||||
if obj.startswith('[') and obj.endswith(']'):
|
||||
"A list. Traverse recursively."
|
||||
return [rec_convert(val) for val in obj[1:-1].split(',')]
|
||||
if obj.startswith('(') and obj.endswith(')'):
|
||||
"A tuple. Traverse recursively."
|
||||
return tuple([rec_convert(val) for val in obj[1:-1].split(',')])
|
||||
if obj.startswith('{') and obj.endswith('}') and ':' in obj:
|
||||
"A dict. Traverse recursively."
|
||||
return dict([(rec_convert(pair.split(":", 1)[0]),
|
||||
rec_convert(pair.split(":", 1)[1]))
|
||||
for pair in obj[1:-1].split(',') if ":" in pair])
|
||||
# if nothing matches, return as-is
|
||||
return obj
|
||||
|
||||
# Use literal_eval to parse python structure exactly.
|
||||
try:
|
||||
return _LITERAL_EVAL(strobj)
|
||||
|
|
@ -1471,10 +1446,9 @@ def _convert_from_string(cmd, strobj):
|
|||
"Make sure this is acceptable." % strobj
|
||||
cmd.caller.msg(string)
|
||||
return strobj
|
||||
else:
|
||||
# fall back to old recursive solution (does not support
|
||||
# nested lists/dicts)
|
||||
return rec_convert(strobj.strip())
|
||||
except Exception as err:
|
||||
string = "|RUnknown error in evaluating Attribute: {}".format(err)
|
||||
return string
|
||||
|
||||
|
||||
class CmdSetAttribute(ObjManipCommand):
|
||||
|
|
@ -1957,7 +1931,7 @@ class CmdLock(ObjManipCommand):
|
|||
|
||||
caller = self.caller
|
||||
if not self.args:
|
||||
string = "@lock <object>[ = <lockstring>] or @lock[/switch] " \
|
||||
string = "Usage: @lock <object>[ = <lockstring>] or @lock[/switch] " \
|
||||
"<object>/<access_type>"
|
||||
caller.msg(string)
|
||||
return
|
||||
|
|
@ -1978,8 +1952,8 @@ class CmdLock(ObjManipCommand):
|
|||
caller.msg("You need 'control' access to change this type of lock.")
|
||||
return
|
||||
|
||||
if not has_control_access or obj.access(caller, "edit"):
|
||||
caller.msg("You are not allowed to do that.")
|
||||
if not has_control_access or not obj.access(caller, "edit"):
|
||||
caller.msg("You need 'edit' access to view or delete lock on this object.")
|
||||
return
|
||||
|
||||
lockdef = obj.locks.get(access_type)
|
||||
|
|
@ -2753,11 +2727,11 @@ class CmdTag(COMMAND_DEFAULT_CLASS):
|
|||
obj)
|
||||
else:
|
||||
# no tag specified, clear all tags
|
||||
old_tags = ["%s%s" % (tag, " (category: %s" % category if category else "")
|
||||
old_tags = ["%s%s" % (tag, " (category: %s)" % category if category else "")
|
||||
for tag, category in obj.tags.all(return_key_and_category=True)]
|
||||
if old_tags:
|
||||
obj.tags.clear()
|
||||
string = "Cleared all tags from %s: %s" % (obj, ", ".join(old_tags))
|
||||
string = "Cleared all tags from %s: %s" % (obj, ", ".join(sorted(old_tags)))
|
||||
else:
|
||||
string = "No Tags to clear on %s." % obj
|
||||
self.caller.msg(string)
|
||||
|
|
@ -2788,8 +2762,9 @@ class CmdTag(COMMAND_DEFAULT_CLASS):
|
|||
tags = [tup[0] for tup in tagtuples]
|
||||
categories = [" (category: %s)" % tup[1] if tup[1] else "" for tup in tagtuples]
|
||||
if ntags:
|
||||
string = "Tag%s on %s: %s" % ("s" if ntags > 1 else "", obj,
|
||||
", ".join("'%s'%s" % (tags[i], categories[i]) for i in range(ntags)))
|
||||
string = "Tag%s on %s: %s" % (
|
||||
"s" if ntags > 1 else "", obj,
|
||||
", ".join(sorted("'%s'%s" % (tags[i], categories[i]) for i in range(ntags))))
|
||||
else:
|
||||
string = "No tags attached to %s." % obj
|
||||
self.caller.msg(string)
|
||||
|
|
@ -3002,7 +2977,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
# all seems ok. Try to save.
|
||||
try:
|
||||
prot = protlib.save_prototype(**prototype)
|
||||
prot = protlib.save_prototype(prototype)
|
||||
if not prot:
|
||||
caller.msg("|rError saving:|R {}.|n".format(prototype_key))
|
||||
return
|
||||
|
|
@ -3091,7 +3066,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
return
|
||||
elif nprots > 1:
|
||||
caller.msg("Found {} prototypes matching '{}':\n {}".format(
|
||||
nprots, prototype, ", ".join(prot.get('prototype_key', '')
|
||||
nprots, prototype, ", ".join(proto.get('prototype_key', '')
|
||||
for proto in prototypes)))
|
||||
return
|
||||
# we have a prototype, check access
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ System commands
|
|||
|
||||
import traceback
|
||||
import os
|
||||
import io
|
||||
import datetime
|
||||
import sys
|
||||
import django
|
||||
|
|
@ -21,7 +22,7 @@ from evennia.accounts.models import AccountDB
|
|||
from evennia.utils import logger, utils, gametime, create, search
|
||||
from evennia.utils.eveditor import EvEditor
|
||||
from evennia.utils.evtable import EvTable
|
||||
from evennia.utils.utils import crop, class_from_module
|
||||
from evennia.utils.utils import crop, class_from_module, to_unicode
|
||||
|
||||
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
|
||||
|
||||
|
|
@ -197,6 +198,7 @@ def _run_code_snippet(caller, pycode, mode="eval", measure_time=False,
|
|||
duration = " (runtime ~ %.4f ms)" % ((t1 - t0) * 1000)
|
||||
else:
|
||||
ret = eval(pycode_compiled, {}, available_vars)
|
||||
|
||||
if mode == "eval":
|
||||
ret = "%s%s" % (str(ret), duration)
|
||||
else:
|
||||
|
|
@ -238,7 +240,9 @@ class CmdPy(COMMAND_DEFAULT_CLASS):
|
|||
inherits_from(obj, parent) : check object inheritance
|
||||
|
||||
You can explore The evennia API from inside the game by calling
|
||||
evennia.help(), evennia.managers.help() etc.
|
||||
the `__doc__` property on entities:
|
||||
@py evennia.__doc__
|
||||
@py evennia.managers.__doc__
|
||||
|
||||
|rNote: In the wrong hands this command is a severe security risk.
|
||||
It should only be accessible by trusted server admins/superusers.|n
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ main test suite started with
|
|||
> python game/manage.py test.
|
||||
|
||||
"""
|
||||
|
||||
import re
|
||||
import types
|
||||
import datetime
|
||||
from anything import Anything
|
||||
|
||||
from django.conf import settings
|
||||
from mock import Mock, mock
|
||||
|
|
@ -49,7 +49,7 @@ class CommandTest(EvenniaTest):
|
|||
Tests a command
|
||||
"""
|
||||
def call(self, cmdobj, args, msg=None, cmdset=None, noansi=True, caller=None,
|
||||
receiver=None, cmdstring=None, obj=None, inputs=None):
|
||||
receiver=None, cmdstring=None, obj=None, inputs=None, raw_string=None):
|
||||
"""
|
||||
Test a command by assigning all the needed
|
||||
properties to cmdobj and running
|
||||
|
|
@ -74,7 +74,7 @@ class CommandTest(EvenniaTest):
|
|||
cmdobj.cmdset = cmdset
|
||||
cmdobj.session = SESSIONS.session_from_sessid(1)
|
||||
cmdobj.account = self.account
|
||||
cmdobj.raw_string = cmdobj.key + " " + args
|
||||
cmdobj.raw_string = raw_string if raw_string is not None else cmdobj.key + " " + args
|
||||
cmdobj.obj = obj or (caller if caller else self.char1)
|
||||
# test
|
||||
old_msg = receiver.msg
|
||||
|
|
@ -322,30 +322,90 @@ class TestBuilding(CommandTest):
|
|||
name = settings.BASE_OBJECT_TYPECLASS.rsplit('.', 1)[1]
|
||||
self.call(building.CmdCreate(), "/d TestObj1", # /d switch is abbreviated form of /drop
|
||||
"You create a new %s: TestObj1." % name)
|
||||
self.call(building.CmdCreate(), "", "Usage: ")
|
||||
self.call(building.CmdCreate(), "TestObj1;foo;bar",
|
||||
"You create a new %s: TestObj1 (aliases: foo, bar)." % name)
|
||||
|
||||
def test_examine(self):
|
||||
self.call(building.CmdExamine(), "", "Name/key: Room")
|
||||
self.call(building.CmdExamine(), "Obj", "Name/key: Obj")
|
||||
self.call(building.CmdExamine(), "Obj", "Name/key: Obj")
|
||||
self.call(building.CmdExamine(), "*TestAccount", "Name/key: TestAccount")
|
||||
|
||||
self.char1.db.test = "testval"
|
||||
self.call(building.CmdExamine(), "self/test", "Persistent attributes:\n test = testval")
|
||||
self.call(building.CmdExamine(), "NotFound", "Could not find 'NotFound'.")
|
||||
self.call(building.CmdExamine(), "out", "Name/key: out")
|
||||
|
||||
self.room1.scripts.add(self.script.__class__)
|
||||
self.call(building.CmdExamine(), "")
|
||||
self.account.scripts.add(self.script.__class__)
|
||||
self.call(building.CmdExamine(), "*TestAccount")
|
||||
|
||||
def test_set_obj_alias(self):
|
||||
self.call(building.CmdSetObjAlias(), "Obj =", "Cleared aliases from Obj(#4)")
|
||||
self.call(building.CmdSetObjAlias(), "Obj =", "Cleared aliases from Obj")
|
||||
self.call(building.CmdSetObjAlias(), "Obj = TestObj1b", "Alias(es) for 'Obj(#4)' set to 'testobj1b'.")
|
||||
self.call(building.CmdSetObjAlias(), "", "Usage: ")
|
||||
self.call(building.CmdSetObjAlias(), "NotFound =", "Could not find 'NotFound'.")
|
||||
self.call(building.CmdSetObjAlias(), "Obj", "Aliases for Obj(#4): 'testobj1b'")
|
||||
self.call(building.CmdSetObjAlias(), "Obj2 =", "Cleared aliases from Obj2")
|
||||
self.call(building.CmdSetObjAlias(), "Obj2 =", "No aliases to clear.")
|
||||
|
||||
def test_copy(self):
|
||||
self.call(building.CmdCopy(), "Obj = TestObj2;TestObj2b, TestObj3;TestObj3b",
|
||||
"Copied Obj to 'TestObj3' (aliases: ['TestObj3b']")
|
||||
self.call(building.CmdCopy(), "", "Usage: ")
|
||||
self.call(building.CmdCopy(), "Obj", "Identical copy of Obj, named 'Obj_copy' was created.")
|
||||
self.call(building.CmdCopy(), "NotFound = Foo", "Could not find 'NotFound'.")
|
||||
|
||||
def test_attribute_commands(self):
|
||||
self.call(building.CmdSetAttribute(), "", "Usage: ")
|
||||
self.call(building.CmdSetAttribute(), "Obj/test1=\"value1\"", "Created attribute Obj/test1 = 'value1'")
|
||||
self.call(building.CmdSetAttribute(), "Obj2/test2=\"value2\"", "Created attribute Obj2/test2 = 'value2'")
|
||||
self.call(building.CmdSetAttribute(), "Obj2/test2", "Attribute Obj2/test2 = value2")
|
||||
self.call(building.CmdSetAttribute(), "Obj2/NotFound", "Obj2 has no attribute 'notfound'.")
|
||||
|
||||
with mock.patch("evennia.commands.default.building.EvEditor") as mock_ed:
|
||||
self.call(building.CmdSetAttribute(), "/edit Obj2/test3")
|
||||
mock_ed.assert_called_with(self.char1, Anything, Anything, key='Obj2/test3')
|
||||
|
||||
self.call(building.CmdSetAttribute(), "Obj2/test3=\"value3\"", "Created attribute Obj2/test3 = 'value3'")
|
||||
self.call(building.CmdSetAttribute(), "Obj2/test3 = ", "Deleted attribute 'test3' (= True) from Obj2.")
|
||||
|
||||
self.call(building.CmdCpAttr(), "/copy Obj2/test2 = Obj2/test3",
|
||||
"@cpattr: Extra switch \"/copy\" ignored.|\nCopied Obj2.test2 -> Obj2.test3. "
|
||||
"(value: 'value2')")
|
||||
self.call(building.CmdMvAttr(), "", "Usage: ")
|
||||
self.call(building.CmdMvAttr(), "Obj2/test2 = Obj/test3", "Moved Obj2.test2 -> Obj.test3")
|
||||
self.call(building.CmdCpAttr(), "", "Usage: ")
|
||||
self.call(building.CmdCpAttr(), "Obj/test1 = Obj2/test3", "Copied Obj.test1 -> Obj2.test3")
|
||||
|
||||
self.call(building.CmdWipe(), "", "Usage: ")
|
||||
self.call(building.CmdWipe(), "Obj2/test2/test3", "Wiped attributes test2,test3 on Obj2.")
|
||||
self.call(building.CmdWipe(), "Obj2", "Wiped all attributes on Obj2.")
|
||||
|
||||
def test_name(self):
|
||||
self.call(building.CmdName(), "", "Usage: ")
|
||||
self.call(building.CmdName(), "Obj2=Obj3", "Object's name changed to 'Obj3'.")
|
||||
self.call(building.CmdName(), "*TestAccount=TestAccountRenamed",
|
||||
"Account's name changed to 'TestAccountRenamed'.")
|
||||
self.call(building.CmdName(), "*NotFound=TestAccountRenamed",
|
||||
"Could not find '*NotFound'")
|
||||
self.call(building.CmdName(), "Obj3=Obj4;foo;bar",
|
||||
"Object's name changed to 'Obj4' (foo, bar).")
|
||||
self.call(building.CmdName(), "Obj4=", "No names or aliases defined!")
|
||||
|
||||
def test_desc(self):
|
||||
self.call(building.CmdDesc(), "Obj2=TestDesc", "The description was set on Obj2(#5).")
|
||||
self.call(building.CmdDesc(), "", "Usage: ")
|
||||
|
||||
with mock.patch("evennia.commands.default.building.EvEditor") as mock_ed:
|
||||
self.call(building.CmdDesc(), "/edit")
|
||||
mock_ed.assert_called_with(self.char1, key='desc',
|
||||
loadfunc=building._desc_load,
|
||||
quitfunc=building._desc_quit,
|
||||
savefunc=building._desc_save,
|
||||
persistent=True)
|
||||
|
||||
def test_empty_desc(self):
|
||||
"""
|
||||
|
|
@ -365,50 +425,128 @@ class TestBuilding(CommandTest):
|
|||
assert self.obj2.db.desc == o2d
|
||||
assert self.room1.db.desc == 'Obj2' and self.room1.db.desc != r1d
|
||||
|
||||
def test_wipe(self):
|
||||
def test_destroy(self):
|
||||
confirm = building.CmdDestroy.confirm
|
||||
building.CmdDestroy.confirm = False
|
||||
self.call(building.CmdDestroy(), "", "Usage: ")
|
||||
self.call(building.CmdDestroy(), "Obj", "Obj was destroyed.")
|
||||
self.call(building.CmdDestroy(), "Obj", "Obj2 was destroyed.")
|
||||
self.call(building.CmdDestroy(), "Obj", "Could not find 'Obj'.| (Objects to destroy "
|
||||
"must either be local or specified with a unique #dbref.)")
|
||||
self.call(building.CmdDestroy(), "#1", "You are trying to delete") # DEFAULT_HOME
|
||||
self.char2.location = self.room2
|
||||
self.call(building.CmdDestroy(), self.room2.dbref,
|
||||
"Char2(#7) arrives to Room(#1) from Room2(#2).|Room2 was destroyed.")
|
||||
building.CmdDestroy.confirm = confirm
|
||||
|
||||
def test_destroy_sequence(self):
|
||||
confirm = building.CmdDestroy.confirm
|
||||
building.CmdDestroy.confirm = False
|
||||
self.call(building.CmdDestroy(),
|
||||
"{}-{}".format(self.obj1.dbref, self.obj2.dbref),
|
||||
"Obj was destroyed.\nObj2 was destroyed.")
|
||||
|
||||
def test_dig(self):
|
||||
self.call(building.CmdDig(), "TestRoom1=testroom;tr,back;b", "Created room TestRoom1")
|
||||
self.call(building.CmdDig(), "", "Usage: ")
|
||||
|
||||
def test_tunnel(self):
|
||||
self.call(building.CmdTunnel(), "n = TestRoom2;test2", "Created room TestRoom2")
|
||||
self.call(building.CmdTunnel(), "", "Usage: ")
|
||||
self.call(building.CmdTunnel(), "foo = TestRoom2;test2", "@tunnel can only understand the")
|
||||
self.call(building.CmdTunnel(), "/tel e = TestRoom3;test3",
|
||||
"Created room TestRoom3(#11) (test3) of type typeclasses.rooms.Room.\n"
|
||||
"Created Exit from Room to TestRoom3: east(#12) (e).\n"
|
||||
"Created Exit back from TestRoom3 to Room: west(#13) (w).|TestRoom3(#11)")
|
||||
|
||||
def test_tunnel_exit_typeclass(self):
|
||||
self.call(building.CmdTunnel(), "n:evennia.objects.objects.DefaultExit = TestRoom3", "Created room TestRoom3")
|
||||
self.call(building.CmdTunnel(), "n:evennia.objects.objects.DefaultExit = TestRoom3",
|
||||
"Created room TestRoom3")
|
||||
|
||||
def test_exit_commands(self):
|
||||
self.call(building.CmdOpen(), "TestExit1=Room2", "Created new Exit 'TestExit1' from Room to Room2")
|
||||
self.call(building.CmdLink(), "TestExit1=Room", "Link created TestExit1 -> Room (one way).")
|
||||
self.call(building.CmdUnLink(), "", "Usage: ")
|
||||
self.call(building.CmdLink(), "NotFound", "Could not find 'NotFound'.")
|
||||
self.call(building.CmdLink(), "TestExit", "TestExit1 is an exit to Room.")
|
||||
self.call(building.CmdLink(), "Obj", "Obj is not an exit. Its home location is Room.")
|
||||
self.call(building.CmdUnLink(), "TestExit1", "Former exit TestExit1 no longer links anywhere.")
|
||||
|
||||
self.char1.location = self.room2
|
||||
self.call(building.CmdOpen(), "TestExit2=Room", "Created new Exit 'TestExit2' from Room2 to Room.")
|
||||
self.call(building.CmdOpen(), "TestExit2=Room", "Exit TestExit2 already exists. It already points to the correct place.")
|
||||
|
||||
|
||||
# ensure it matches locally first
|
||||
self.call(building.CmdLink(), "TestExit=Room2", "Link created TestExit2 -> Room2 (one way).")
|
||||
self.call(building.CmdLink(), "/twoway TestExit={}".format(self.exit.dbref),
|
||||
"Link created TestExit2 (in Room2) <-> out (in Room) (two-way).")
|
||||
self.call(building.CmdLink(), "/twoway TestExit={}".format(self.room1.dbref),
|
||||
"To create a two-way link, TestExit2 and Room must both have a location ")
|
||||
self.call(building.CmdLink(), "/twoway {}={}".format(self.exit.dbref, self.exit.dbref),
|
||||
"Cannot link an object to itself.")
|
||||
self.call(building.CmdLink(), "", "Usage: ")
|
||||
# ensure can still match globally when not a local name
|
||||
self.call(building.CmdLink(), "TestExit1=Room2", "Note: TestExit1(#8) did not have a destination set before. "
|
||||
"Make sure you linked the right thing.\n"
|
||||
"Link created TestExit1 -> Room2 (one way).")
|
||||
self.call(building.CmdLink(), "TestExit1=", "Former exit TestExit1 no longer links anywhere.")
|
||||
|
||||
def test_set_home(self):
|
||||
self.call(building.CmdSetHome(), "Obj = Room2", "Obj's home location was changed from Room")
|
||||
self.call(building.CmdSetHome(), "Obj = Room2", "Home location of Obj was changed from Room")
|
||||
self.call(building.CmdSetHome(), "", "Usage: ")
|
||||
self.call(building.CmdSetHome(), "self", "Char's current home is Room")
|
||||
self.call(building.CmdSetHome(), "Obj", "Obj's current home is Room2")
|
||||
self.obj1.home = None
|
||||
self.call(building.CmdSetHome(), "Obj = Room2", "Home location of Obj was set to Room")
|
||||
|
||||
def test_list_cmdsets(self):
|
||||
self.call(building.CmdListCmdSets(), "", "<DefaultCharacter (Union, prio 0, perm)>:")
|
||||
self.call(building.CmdListCmdSets(), "NotFound", "Could not find 'NotFound'")
|
||||
|
||||
def test_typeclass(self):
|
||||
self.call(building.CmdTypeclass(), "", "Usage: ")
|
||||
self.call(building.CmdTypeclass(), "Obj = evennia.objects.objects.DefaultExit",
|
||||
"Obj changed typeclass from evennia.objects.objects.DefaultObject "
|
||||
"to evennia.objects.objects.DefaultExit.")
|
||||
self.call(building.CmdTypeclass(), "Obj2 = evennia.objects.objects.DefaultExit",
|
||||
"Obj2 changed typeclass from evennia.objects.objects.DefaultObject "
|
||||
"to evennia.objects.objects.DefaultExit.", cmdstring="@swap")
|
||||
self.call(building.CmdTypeclass(), "/list Obj", "Core typeclasses")
|
||||
self.call(building.CmdTypeclass(), "/show Obj", "Obj's current typeclass is 'evennia.objects.objects.DefaultExit'")
|
||||
self.call(building.CmdTypeclass(), "Obj = evennia.objects.objects.DefaultExit",
|
||||
"Obj already has the typeclass 'evennia.objects.objects.DefaultExit'. Use /force to override.")
|
||||
self.call(building.CmdTypeclass(), "/force Obj = evennia.objects.objects.DefaultExit",
|
||||
"Obj updated its existing typeclass ")
|
||||
self.call(building.CmdTypeclass(), "Obj = evennia.objects.objects.DefaultObject")
|
||||
self.call(building.CmdTypeclass(), "/show Obj", "Obj's current typeclass is 'evennia.objects.objects.DefaultObject'")
|
||||
self.call(building.CmdTypeclass(), "Obj",
|
||||
"Obj updated its existing typeclass (evennia.objects.objects.DefaultObject).\n"
|
||||
"Only the at_object_creation hook was run (update mode). Attributes set before swap were not removed.",
|
||||
cmdstring="@update")
|
||||
self.call(building.CmdTypeclass(), "/reset/force Obj=evennia.objects.objects.DefaultObject",
|
||||
"Obj updated its existing typeclass (evennia.objects.objects.DefaultObject).\n"
|
||||
"All object creation hooks were run. All old attributes where deleted before the swap.")
|
||||
|
||||
def test_lock(self):
|
||||
self.call(building.CmdLock(), "Obj = test:perm(Developer)", "Added lock 'test:perm(Developer)' to Obj.")
|
||||
self.call(building.CmdLock(), "", "Usage: ")
|
||||
self.call(building.CmdLock(), "Obj = test:all()", "Added lock 'test:all()' to Obj.")
|
||||
self.call(building.CmdLock(), "*TestAccount = test:all()", "Added lock 'test:all()' to TestAccount")
|
||||
self.call(building.CmdLock(), "Obj/notfound", "Obj has no lock of access type 'notfound'.")
|
||||
self.call(building.CmdLock(), "Obj/test", "test:all()")
|
||||
self.call(building.CmdLock(), "/view Obj = edit:false()",
|
||||
"Switch(es) view can not be used with a lock assignment. "
|
||||
"Use e.g. @lock/del objname/locktype instead.")
|
||||
self.call(building.CmdLock(), "Obj = edit:false()")
|
||||
self.call(building.CmdLock(), "Obj/test", "You need 'edit' access to view or delete lock on this object.")
|
||||
self.call(building.CmdLock(), "Obj", "call:true()") # etc
|
||||
self.call(building.CmdLock(), "*TestAccount", "boot:perm(Admin)") # etc
|
||||
|
||||
def test_find(self):
|
||||
self.call(building.CmdFind(), "", "Usage: ")
|
||||
self.call(building.CmdFind(), "oom2", "One Match")
|
||||
self.call(building.CmdFind(), "oom2 = 1-100", "One Match")
|
||||
self.call(building.CmdFind(), "oom2 = 1 100", "One Match") # space works too
|
||||
expect = "One Match(#1-#7, loc):\n " +\
|
||||
"Char2(#7) - evennia.objects.objects.DefaultCharacter (location: Room(#1))"
|
||||
self.call(building.CmdFind(), "Char2", expect, cmdstring="locate")
|
||||
|
|
@ -420,11 +558,43 @@ class TestBuilding(CommandTest):
|
|||
self.call(building.CmdFind(), "Char2", "One Match", cmdstring="@find")
|
||||
self.call(building.CmdFind(), "/startswith Room2", "One Match")
|
||||
|
||||
self.call(building.CmdFind(), self.char1.dbref,
|
||||
"Exact dbref match(#1-#7):\n "
|
||||
" Char(#6) - evennia.objects.objects.DefaultCharacter")
|
||||
self.call(building.CmdFind(), "*TestAccount",
|
||||
"Match(#1-#7):\n"
|
||||
" TestAccount - evennia.accounts.accounts.DefaultAccount")
|
||||
|
||||
self.call(building.CmdFind(), "/char Obj")
|
||||
self.call(building.CmdFind(), "/room Obj")
|
||||
self.call(building.CmdFind(), "/exit Obj")
|
||||
self.call(building.CmdFind(), "/exact Obj", "One Match")
|
||||
|
||||
def test_script(self):
|
||||
self.call(building.CmdScript(), "Obj = ", "No scripts defined on Obj")
|
||||
self.call(building.CmdScript(), "Obj = scripts.Script", "Script scripts.Script successfully added")
|
||||
self.call(building.CmdScript(), "", "Usage: ")
|
||||
self.call(building.CmdScript(), "= Obj", "To create a global script you need @scripts/add <typeclass>.")
|
||||
self.call(building.CmdScript(), "Obj = ", "dbref obj")
|
||||
|
||||
self.call(building.CmdScript(), "/start Obj", "0 scripts started on Obj") # because it's already started
|
||||
self.call(building.CmdScript(), "/stop Obj", "Stopping script")
|
||||
|
||||
self.call(building.CmdScript(), "Obj = scripts.Script", "Script scripts.Script successfully added")
|
||||
self.call(building.CmdScript(), "/start Obj = scripts.Script", "Script scripts.Script could not be (re)started.")
|
||||
self.call(building.CmdScript(), "/stop Obj = scripts.Script", "Script stopped and removed from object.")
|
||||
|
||||
def test_teleport(self):
|
||||
self.call(building.CmdTeleport(), "/quiet Room2", "Room2(#2)\n|Teleported to Room2.")
|
||||
self.call(building.CmdTeleport(), "", "Usage: ")
|
||||
self.call(building.CmdTeleport(), "Obj = Room", "Obj is already at Room.")
|
||||
self.call(building.CmdTeleport(), "Obj = NotFound", "Could not find 'NotFound'.|Destination not found.")
|
||||
self.call(building.CmdTeleport(),
|
||||
"Obj = Room2", "Obj(#4) is leaving Room(#1), heading for Room2(#2).|Teleported Obj -> Room2.")
|
||||
self.call(building.CmdTeleport(), "NotFound = Room", "Could not find 'NotFound'.")
|
||||
self.call(building.CmdTeleport(), "Obj = Obj", "You can't teleport an object inside of itself!")
|
||||
|
||||
self.call(building.CmdTeleport(), "/tonone Obj2", "Teleported Obj2 -> None-location.")
|
||||
self.call(building.CmdTeleport(), "/quiet Room2", "Room2(#2)")
|
||||
self.call(building.CmdTeleport(), "/t", # /t switch is abbreviated form of /tonone
|
||||
"Cannot teleport a puppeted object (Char, puppeted by TestAccount(account 1)) to a None-location.")
|
||||
self.call(building.CmdTeleport(), "/l Room2", # /l switch is abbreviated form of /loc
|
||||
|
|
@ -432,6 +602,28 @@ class TestBuilding(CommandTest):
|
|||
self.call(building.CmdTeleport(), "/q me to Room2", # /q switch is abbreviated form of /quiet
|
||||
"Char is already at Room2.")
|
||||
|
||||
def test_tag(self):
|
||||
self.call(building.CmdTag(), "", "Usage: ")
|
||||
|
||||
self.call(building.CmdTag(), "Obj = testtag")
|
||||
self.call(building.CmdTag(), "Obj = testtag2")
|
||||
self.call(building.CmdTag(), "Obj = testtag2:category1")
|
||||
self.call(building.CmdTag(), "Obj = testtag3")
|
||||
|
||||
self.call(building.CmdTag(), "Obj", "Tags on Obj: 'testtag', 'testtag2', "
|
||||
"'testtag2' (category: category1), 'testtag3'")
|
||||
|
||||
self.call(building.CmdTag(), "/search NotFound", "No objects found with tag 'NotFound'.")
|
||||
self.call(building.CmdTag(), "/search testtag", "Found 1 object with tag 'testtag':")
|
||||
self.call(building.CmdTag(), "/search testtag2", "Found 1 object with tag 'testtag2':")
|
||||
self.call(building.CmdTag(), "/search testtag2:category1",
|
||||
"Found 1 object with tag 'testtag2' (category: 'category1'):")
|
||||
|
||||
|
||||
self.call(building.CmdTag(), "/del Obj = testtag3", "Removed tag 'testtag3' from Obj.")
|
||||
self.call(building.CmdTag(), "/del Obj",
|
||||
"Cleared all tags from Obj: testtag, testtag2, testtag2 (category: category1)")
|
||||
|
||||
def test_spawn(self):
|
||||
def getObject(commandTest, objKeyStr):
|
||||
# A helper function to get a spawned object and
|
||||
|
|
@ -453,6 +645,14 @@ class TestBuilding(CommandTest):
|
|||
"'typeclass':'evennia.objects.objects.DefaultCharacter'}",
|
||||
"Saved prototype: testprot", inputs=['y'])
|
||||
|
||||
self.call(building.CmdSpawn(), "/search ", "Key ")
|
||||
self.call(building.CmdSpawn(), "/search test;test2", "")
|
||||
|
||||
self.call(building.CmdSpawn(),
|
||||
"/save {'key':'Test Char', "
|
||||
"'typeclass':'evennia.objects.objects.DefaultCharacter'}",
|
||||
"To save a prototype it must have the 'prototype_key' set.")
|
||||
|
||||
self.call(building.CmdSpawn(), "/list", "Key ")
|
||||
|
||||
self.call(building.CmdSpawn(), 'testprot', "Spawned Test Char")
|
||||
|
|
@ -480,9 +680,9 @@ class TestBuilding(CommandTest):
|
|||
goblin.delete()
|
||||
|
||||
# create prototype
|
||||
protlib.create_prototype(**{'key': 'Ball',
|
||||
'typeclass': 'evennia.objects.objects.DefaultCharacter',
|
||||
'prototype_key': 'testball'})
|
||||
protlib.create_prototype({'key': 'Ball',
|
||||
'typeclass': 'evennia.objects.objects.DefaultCharacter',
|
||||
'prototype_key': 'testball'})
|
||||
|
||||
# Tests "@spawn <prototype_name>"
|
||||
self.call(building.CmdSpawn(), "testball", "Spawned Ball")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue