mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 09:46:32 +01:00
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
4268e3e142
commit
15c940fba4
2 changed files with 20 additions and 13 deletions
|
|
@ -2913,7 +2913,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
prototype = None
|
||||
if self.lhs:
|
||||
key = self.lhs
|
||||
prototype = spawner.search_prototype(key=key, return_meta=True)
|
||||
prototype = protlib.search_prototype(key=key)
|
||||
if len(prototype) > 1:
|
||||
caller.msg("More than one match for {}:\n{}".format(
|
||||
key, "\n".join(proto.get('prototype_key', '') for proto in prototype)))
|
||||
|
|
@ -2921,6 +2921,10 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
elif prototype:
|
||||
# one match
|
||||
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)
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -479,25 +479,28 @@ class TestBuilding(CommandTest):
|
|||
self.call(building.CmdSpawn(), "/list", "Key ")
|
||||
|
||||
# @span/edit (missing prototype)
|
||||
# brings up olc menu
|
||||
msg = self.call(
|
||||
building.CmdSpawn(),
|
||||
'/edit')
|
||||
# '@spawn: Extra switch "/edit" ignored.|Usage: @spawn <prototype-key> or {key: value, ...}\n (2 existing prototypes. Use /list to inspect)')
|
||||
assert 'Prototype wizard' in msg
|
||||
assert msg.startswith('______________________________________________________________________________\n\n --- Prototype wizard --- \n\n')
|
||||
|
||||
# @spawn/edit with valid prototype
|
||||
with self.assertRaises(AttributeError):
|
||||
self.call(
|
||||
building.CmdSpawn(),
|
||||
'/edit BALL',
|
||||
'@spawn: Extra switch "/edit" ignored.|Spawned Ball(#13).')
|
||||
self.call(
|
||||
building.CmdSpawn(),
|
||||
'/edit testball')
|
||||
# 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
|
||||
with self.assertRaises(AttributeError):
|
||||
self.call(
|
||||
building.CmdSpawn(),
|
||||
'/edit NO_EXISTS',
|
||||
'@spawn: Extra switch "/edit" ignored.|No prototype named \'NO_EXISTS\'.')
|
||||
msg = self.call(
|
||||
building.CmdSpawn(),
|
||||
'/edit NO_EXISTS',
|
||||
"No prototype 'NO_EXISTS' was found.")
|
||||
|
||||
# @spawn/examine (missing prototype)
|
||||
self.call(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue