Handle '@spawn/edit ' (no prototype key given) brings OLC menu. Handle '@spawn/edit testball' brings OLC menu. Handle '@spawn/edit NO_EXISTS' that returns error
This commit is contained in:
parent
414f72c3b0
commit
931290a7a0
2 changed files with 20 additions and 13 deletions
|
|
@ -2913,7 +2913,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||||
prototype = None
|
prototype = None
|
||||||
if self.lhs:
|
if self.lhs:
|
||||||
key = self.lhs
|
key = self.lhs
|
||||||
prototype = spawner.search_prototype(key=key, return_meta=True)
|
prototype = protlib.search_prototype(key=key)
|
||||||
if len(prototype) > 1:
|
if len(prototype) > 1:
|
||||||
caller.msg("More than one match for {}:\n{}".format(
|
caller.msg("More than one match for {}:\n{}".format(
|
||||||
key, "\n".join(proto.get('prototype_key', '') for proto in prototype)))
|
key, "\n".join(proto.get('prototype_key', '') for proto in prototype)))
|
||||||
|
|
@ -2921,6 +2921,10 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||||
elif prototype:
|
elif prototype:
|
||||||
# one match
|
# one match
|
||||||
prototype = prototype[0]
|
prototype = prototype[0]
|
||||||
|
else:
|
||||||
|
# no match
|
||||||
|
caller.msg("No prototype '{}' was found.".format(key))
|
||||||
|
return
|
||||||
olc_menus.start_olc(caller, session=self.session, prototype=prototype)
|
olc_menus.start_olc(caller, session=self.session, prototype=prototype)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -479,25 +479,28 @@ class TestBuilding(CommandTest):
|
||||||
self.call(building.CmdSpawn(), "/list", "Key ")
|
self.call(building.CmdSpawn(), "/list", "Key ")
|
||||||
|
|
||||||
# @span/edit (missing prototype)
|
# @span/edit (missing prototype)
|
||||||
|
# brings up olc menu
|
||||||
msg = self.call(
|
msg = self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
'/edit')
|
'/edit')
|
||||||
# '@spawn: Extra switch "/edit" ignored.|Usage: @spawn <prototype-key> or {key: value, ...}\n (2 existing prototypes. Use /list to inspect)')
|
assert msg.startswith('______________________________________________________________________________\n\n --- Prototype wizard --- \n\n')
|
||||||
assert 'Prototype wizard' in msg
|
|
||||||
|
|
||||||
# @spawn/edit with valid prototype
|
# @spawn/edit with valid prototype
|
||||||
with self.assertRaises(AttributeError):
|
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
'/edit BALL',
|
'/edit testball')
|
||||||
'@spawn: Extra switch "/edit" ignored.|Spawned Ball(#13).')
|
# TODO: OLC menu comes up but it gives no
|
||||||
|
# indication of testball prototype being
|
||||||
|
# edited ... Is this correct?
|
||||||
|
# On top of OCL being shown, msg is preceded
|
||||||
|
# by Room(#1)...
|
||||||
|
assert 'Prototype wizard' in msg
|
||||||
|
|
||||||
# @spawn/edit with invalid prototype
|
# @spawn/edit with invalid prototype
|
||||||
with self.assertRaises(AttributeError):
|
msg = self.call(
|
||||||
self.call(
|
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
'/edit NO_EXISTS',
|
'/edit NO_EXISTS',
|
||||||
'@spawn: Extra switch "/edit" ignored.|No prototype named \'NO_EXISTS\'.')
|
"No prototype 'NO_EXISTS' was found.")
|
||||||
|
|
||||||
# @spawn/examine (missing prototype)
|
# @spawn/examine (missing prototype)
|
||||||
self.call(
|
self.call(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue