Harden test '@spawn/edit <valid-prototype>' by asserting that olc_menu has been loaded with valid-prototype.UX Enhancement to OLC menu. Underneath the title, display 'Editing: key(prototype_key)' of the prototype being edited. If none, show blank line
This commit is contained in:
parent
f70fa467f5
commit
1cbbdf5410
2 changed files with 25 additions and 7 deletions
|
|
@ -478,29 +478,33 @@ class TestBuilding(CommandTest):
|
||||||
# Test listing commands
|
# Test listing commands
|
||||||
self.call(building.CmdSpawn(), "/list", "Key ")
|
self.call(building.CmdSpawn(), "/list", "Key ")
|
||||||
|
|
||||||
# @span/edit (missing prototype)
|
# @spawn/edit (missing prototype)
|
||||||
# brings up olc menu
|
# brings up olc menu
|
||||||
msg = self.call(
|
msg = self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
'/edit')
|
'/edit')
|
||||||
assert msg.startswith('______________________________________________________________________________\n\n --- Prototype wizard --- \n\n')
|
assert 'Prototype wizard' in msg
|
||||||
|
|
||||||
# @spawn/edit with valid prototype
|
# @spawn/edit with valid prototype
|
||||||
|
# brings up olc menu loaded with prototype
|
||||||
msg = self.call(
|
msg = self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
'/edit testball')
|
'/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
|
assert 'Prototype wizard' in msg
|
||||||
|
assert hasattr(self.char1.ndb._menutree, "olc_prototype")
|
||||||
|
assert dict == type(self.char1.ndb._menutree.olc_prototype) \
|
||||||
|
and 'prototype_key' in self.char1.ndb._menutree.olc_prototype \
|
||||||
|
and 'key' in self.char1.ndb._menutree.olc_prototype \
|
||||||
|
and 'testball' == self.char1.ndb._menutree.olc_prototype['prototype_key'] \
|
||||||
|
and 'Ball' == self.char1.ndb._menutree.olc_prototype['key']
|
||||||
|
assert 'Ball' in msg and 'testball' in msg
|
||||||
|
|
||||||
# @spawn/edit with valid prototype (synomym)
|
# @spawn/edit with valid prototype (synomym)
|
||||||
msg = self.call(
|
msg = self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
'/edit BALL')
|
'/edit BALL')
|
||||||
assert 'Prototype wizard' in msg
|
assert 'Prototype wizard' in msg
|
||||||
|
assert 'Ball' in msg and 'testball' in msg
|
||||||
|
|
||||||
# @spawn/edit with invalid prototype
|
# @spawn/edit with invalid prototype
|
||||||
msg = self.call(
|
msg = self.call(
|
||||||
|
|
@ -518,6 +522,8 @@ class TestBuilding(CommandTest):
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
'/examine BALL',
|
'/examine BALL',
|
||||||
|
# FIXME: should this print the existing prototype
|
||||||
|
# instead of spawning it?
|
||||||
'@spawn: Extra switch "/examine" ignored.|Spawned Ball(#13).')
|
'@spawn: Extra switch "/examine" ignored.|Spawned Ball(#13).')
|
||||||
|
|
||||||
# @spawn/examine with invalid prototype
|
# @spawn/examine with invalid prototype
|
||||||
|
|
|
||||||
|
|
@ -562,6 +562,7 @@ def node_index(caller):
|
||||||
|
|
||||||
text = """
|
text = """
|
||||||
|c --- Prototype wizard --- |n
|
|c --- Prototype wizard --- |n
|
||||||
|
%s
|
||||||
|
|
||||||
A |cprototype|n is a 'template' for |wspawning|n an in-game entity. A field of the prototype
|
A |cprototype|n is a 'template' for |wspawning|n an in-game entity. A field of the prototype
|
||||||
can either be hard-coded, left empty or scripted using |w$protfuncs|n - for example to
|
can either be hard-coded, left empty or scripted using |w$protfuncs|n - for example to
|
||||||
|
|
@ -599,6 +600,17 @@ def node_index(caller):
|
||||||
{pfuncs}
|
{pfuncs}
|
||||||
""".format(pfuncs=_format_protfuncs())
|
""".format(pfuncs=_format_protfuncs())
|
||||||
|
|
||||||
|
# If a prototype is being edited, show its key and
|
||||||
|
# prototype_key under the title
|
||||||
|
loaded_prototype = ''
|
||||||
|
if 'prototype_key' in prototype \
|
||||||
|
or 'key' in prototype:
|
||||||
|
loaded_prototype = ' --- Editing: |y{}({})|n --- '.format(
|
||||||
|
prototype.get('key', ''),
|
||||||
|
prototype.get('prototype_key', '')
|
||||||
|
)
|
||||||
|
text = text % (loaded_prototype)
|
||||||
|
|
||||||
text = (text, helptxt)
|
text = (text, helptxt)
|
||||||
|
|
||||||
options = []
|
options = []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue