Testing a new variation on cmdset merging, as per #1087.
This commit is contained in:
parent
c7b689c1d8
commit
300758b2dd
1 changed files with 25 additions and 25 deletions
|
|
@ -199,22 +199,22 @@ def get_and_merge_cmdsets(caller, session, player, obj, callertype):
|
||||||
local_obj_cmdsets = [None]
|
local_obj_cmdsets = [None]
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def _get_channel_cmdsets(player, player_cmdset):
|
def _get_channel_cmdset(player):#, player_cmdset):
|
||||||
"""
|
"""
|
||||||
Helper-method; Get channel-cmdsets
|
Helper-method; Get channel-cmdsets
|
||||||
"""
|
"""
|
||||||
# Create cmdset for all player's available channels
|
# Create cmdset for all player's available channels
|
||||||
try:
|
try:
|
||||||
channel_cmdset = None
|
channel_cmdset = None
|
||||||
if not player_cmdset.no_channels:
|
#if not player_cmdset.no_channels: #TODO
|
||||||
channel_cmdset = yield CHANNELHANDLER.get_cmdset(player)
|
channel_cmdset = yield CHANNELHANDLER.get_cmdset(player)
|
||||||
returnValue(channel_cmdset)
|
returnValue([channel_cmdset])
|
||||||
except Exception:
|
except Exception:
|
||||||
_msg_err(caller, _ERROR_CMDSETS)
|
_msg_err(caller, _ERROR_CMDSETS)
|
||||||
raise ErrorReported
|
raise ErrorReported
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def _get_local_obj_cmdsets(obj, obj_cmdset):
|
def _get_local_obj_cmdsets(obj):
|
||||||
"""
|
"""
|
||||||
Helper-method; Get Object-level cmdsets
|
Helper-method; Get Object-level cmdsets
|
||||||
"""
|
"""
|
||||||
|
|
@ -225,7 +225,7 @@ def get_and_merge_cmdsets(caller, session, player, obj, callertype):
|
||||||
location = obj.location
|
location = obj.location
|
||||||
except Exception:
|
except Exception:
|
||||||
location = None
|
location = None
|
||||||
if location and not obj_cmdset.no_objs:
|
if location:# and not obj_cmdset.no_objs: #TODO
|
||||||
# Gather all cmdsets stored on objects in the room and
|
# Gather all cmdsets stored on objects in the room and
|
||||||
# also in the caller's inventory and the location itself
|
# also in the caller's inventory and the location itself
|
||||||
local_objlist = yield (location.contents_get(exclude=obj) +
|
local_objlist = yield (location.contents_get(exclude=obj) +
|
||||||
|
|
@ -258,7 +258,7 @@ def get_and_merge_cmdsets(caller, session, player, obj, callertype):
|
||||||
|
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def _get_cmdset(obj):
|
def _get_cmdsets(obj):
|
||||||
"""
|
"""
|
||||||
Helper method; Get cmdset while making sure to trigger all
|
Helper method; Get cmdset while making sure to trigger all
|
||||||
hooks safely.
|
hooks safely.
|
||||||
|
|
@ -269,39 +269,39 @@ def get_and_merge_cmdsets(caller, session, player, obj, callertype):
|
||||||
_msg_err(caller, _ERROR_CMDSETS)
|
_msg_err(caller, _ERROR_CMDSETS)
|
||||||
raise ErrorReported
|
raise ErrorReported
|
||||||
try:
|
try:
|
||||||
returnValue(obj.cmdset.current)
|
#returnValue(obj.cmdset.current)
|
||||||
|
returnValue(obj.cmdset.cmdset_stack)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
returnValue(None)
|
returnValue(None)
|
||||||
|
|
||||||
if callertype == "session":
|
if callertype == "session":
|
||||||
# we are calling the command from the session level
|
# we are calling the command from the session level
|
||||||
report_to = session
|
report_to = session
|
||||||
session_cmdset = yield _get_cmdset(session)
|
cmdsets = yield _get_cmdsets(session)
|
||||||
cmdsets = [session_cmdset]
|
|
||||||
if player: # this automatically implies logged-in
|
if player: # this automatically implies logged-in
|
||||||
player_cmdset = yield _get_cmdset(player)
|
player_cmdsets = yield _get_cmdsets(player)
|
||||||
channel_cmdset = yield _get_channel_cmdsets(player, player_cmdset)
|
channel_cmdset = yield _get_channel_cmdset(player)
|
||||||
cmdsets.extend([player_cmdset, channel_cmdset])
|
cmdsets += player_cmdsets + channel_cmdset
|
||||||
if obj:
|
if obj:
|
||||||
obj_cmdset = yield _get_cmdset(obj)
|
obj_cmdset = yield _get_cmdsets(obj)
|
||||||
local_obj_cmdsets = yield _get_local_obj_cmdsets(obj, obj_cmdset)
|
local_obj_cmdsets = yield _get_local_obj_cmdsets(obj)
|
||||||
cmdsets.extend([obj_cmdset] + local_obj_cmdsets)
|
cmdsets.extend(obj_cmdset + local_obj_cmdsets)
|
||||||
elif callertype == "player":
|
elif callertype == "player":
|
||||||
# we are calling the command from the player level
|
# we are calling the command from the player level
|
||||||
report_to = player
|
report_to = player
|
||||||
player_cmdset = yield _get_cmdset(player)
|
player_cmdset = yield _get_cmdsets(player)
|
||||||
channel_cmdset = yield _get_channel_cmdsets(player, player_cmdset)
|
channel_cmdset = yield _get_channel_cmdset(player, player_cmdset)
|
||||||
cmdsets = [player_cmdset, channel_cmdset]
|
cmdsets = player_cmdset + channel_cmdset
|
||||||
if obj:
|
if obj:
|
||||||
obj_cmdset = yield _get_cmdset(obj)
|
obj_cmdset = yield _get_cmdsets(obj)
|
||||||
local_obj_cmdsets = yield _get_local_obj_cmdsets(obj, obj_cmdset)
|
local_obj_cmdsets = yield _get_local_obj_cmdsets(obj)
|
||||||
cmdsets.extend([obj_cmdset] + local_obj_cmdsets)
|
cmdsets.extend(obj_cmdset + local_obj_cmdsets)
|
||||||
elif callertype == "object":
|
elif callertype == "object":
|
||||||
# we are calling the command from the object level
|
# we are calling the command from the object level
|
||||||
report_to = obj
|
report_to = obj
|
||||||
obj_cmdset = yield _get_cmdset(obj)
|
obj_cmdset = yield _get_cmdsets(obj)
|
||||||
local_obj_cmdsets = yield _get_local_obj_cmdsets(obj, obj_cmdset)
|
local_obj_cmdsets = yield _get_local_obj_cmdsets(obj)
|
||||||
cmdsets = [obj_cmdset] + local_obj_cmdsets
|
cmdsets = obj_cmdset + local_obj_cmdsets
|
||||||
else:
|
else:
|
||||||
raise Exception("get_and_merge_cmdsets: callertype %s is not valid." % callertype)
|
raise Exception("get_and_merge_cmdsets: callertype %s is not valid." % callertype)
|
||||||
#cmdsets = yield [caller_cmdset] + [player_cmdset] +
|
#cmdsets = yield [caller_cmdset] + [player_cmdset] +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue