Various fixes from game jam
This commit is contained in:
parent
e6aec78cce
commit
ed187ad05f
12 changed files with 45 additions and 28 deletions
|
|
@ -647,6 +647,7 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess
|
||||||
args = raw_string
|
args = raw_string
|
||||||
unformatted_raw_string = "%s%s" % (cmdname, args)
|
unformatted_raw_string = "%s%s" % (cmdname, args)
|
||||||
cmdset = None
|
cmdset = None
|
||||||
|
raw_cmdname = cmdname
|
||||||
# session = session
|
# session = session
|
||||||
# account = account
|
# account = account
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -483,7 +483,6 @@ class Command(with_metaclass(CommandMeta, object)):
|
||||||
|
|
||||||
h_line_char = kwargs.pop('header_line_char', '~')
|
h_line_char = kwargs.pop('header_line_char', '~')
|
||||||
header_line_char = ANSIString(f'|{border_color}{h_line_char}|n')
|
header_line_char = ANSIString(f'|{border_color}{h_line_char}|n')
|
||||||
|
|
||||||
c_char = kwargs.pop('corner_char', '+')
|
c_char = kwargs.pop('corner_char', '+')
|
||||||
corner_char = ANSIString(f'|{border_color}{c_char}|n')
|
corner_char = ANSIString(f'|{border_color}{c_char}|n')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ class CmdWho(COMMAND_DEFAULT_CLASS):
|
||||||
else:
|
else:
|
||||||
show_session_data = account.check_permstring("Developer") or account.check_permstring("Admins")
|
show_session_data = account.check_permstring("Developer") or account.check_permstring("Admins")
|
||||||
|
|
||||||
naccounts = (SESSIONS.account_count())
|
naccounts = SESSIONS.account_count()
|
||||||
if show_session_data:
|
if show_session_data:
|
||||||
# privileged info
|
# privileged info
|
||||||
table = self.style_table("|wAccount Name",
|
table = self.style_table("|wAccount Name",
|
||||||
|
|
|
||||||
|
|
@ -618,7 +618,7 @@ class _ObjDummy:
|
||||||
lock_storage = ''
|
lock_storage = ''
|
||||||
|
|
||||||
|
|
||||||
def check_lockstring(self, accessing_obj, lockstring, no_superuser_bypass=False,
|
def check_lockstring(accessing_obj, lockstring, no_superuser_bypass=False,
|
||||||
default=False, access_type=None):
|
default=False, access_type=None):
|
||||||
"""
|
"""
|
||||||
Do a direct check against a lockstring ('atype:func()..'),
|
Do a direct check against a lockstring ('atype:func()..'),
|
||||||
|
|
@ -643,9 +643,9 @@ def check_lockstring(self, accessing_obj, lockstring, no_superuser_bypass=False,
|
||||||
access (bool): If check is passed or not.
|
access (bool): If check is passed or not.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
global _LOCKHANDLER
|
global _LOCK_HANDLER
|
||||||
if not _LOCKHANDLER:
|
if not _LOCK_HANDLER:
|
||||||
_LOCKHANDLER = LockHandler(_ObjDummy())
|
_LOCK_HANDLER = LockHandler(_ObjDummy())
|
||||||
return _LOCK_HANDLER.check_lockstring(
|
return _LOCK_HANDLER.check_lockstring(
|
||||||
accessing_obj, lockstring, no_superuser_bypass=no_superuser_bypass,
|
accessing_obj, lockstring, no_superuser_bypass=no_superuser_bypass,
|
||||||
default=default, access_type=access_type)
|
default=default, access_type=access_type)
|
||||||
|
|
|
||||||
|
|
@ -1623,7 +1623,9 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
commonly an object or the current location. It will
|
commonly an object or the current location. It will
|
||||||
be checked for the "view" type access.
|
be checked for the "view" type access.
|
||||||
**kwargs (dict): Arbitrary, optional arguments for users
|
**kwargs (dict): Arbitrary, optional arguments for users
|
||||||
overriding the call (unused by default).
|
overriding the call. This will be passed into
|
||||||
|
return_appearance, get_display_name and at_desc but is not used
|
||||||
|
by default.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
lookstring (str): A ready-processed look string
|
lookstring (str): A ready-processed look string
|
||||||
|
|
@ -1632,15 +1634,15 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
"""
|
"""
|
||||||
if not target.access(self, "view"):
|
if not target.access(self, "view"):
|
||||||
try:
|
try:
|
||||||
return "Could not view '%s'." % target.get_display_name(self)
|
return "Could not view '%s'." % target.get_display_name(self, **kwargs)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return "Could not view '%s'." % target.key
|
return "Could not view '%s'." % target.key
|
||||||
|
|
||||||
description = target.return_appearance(self)
|
description = target.return_appearance(self, **kwargs)
|
||||||
|
|
||||||
# the target's at_desc() method.
|
# the target's at_desc() method.
|
||||||
# this must be the last reference to target so it may delete itself when acted on.
|
# this must be the last reference to target so it may delete itself when acted on.
|
||||||
target.at_desc(looker=self)
|
target.at_desc(looker=self, **kwargs)
|
||||||
|
|
||||||
return description
|
return description
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -493,7 +493,7 @@ TYPECLASS_AGGRESSIVE_CACHE = True
|
||||||
# Options and validators
|
# Options and validators
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
# Options available on Accounts. Each such option is described by a
|
# Options available on Accounts. Each such option is described by a
|
||||||
# class available from evennia.OPTION_CLASSES, in turn making use
|
# class available from evennia.OPTION_CLASSES, in turn making use
|
||||||
# of validators from evennia.VALIDATOR_FUNCS to validate input when
|
# of validators from evennia.VALIDATOR_FUNCS to validate input when
|
||||||
# the user changes an option. The options are accessed through the
|
# the user changes an option. The options are accessed through the
|
||||||
|
|
|
||||||
|
|
@ -677,11 +677,18 @@ class AttributeHandler(object):
|
||||||
|
|
||||||
if not self._cache_complete:
|
if not self._cache_complete:
|
||||||
self._fullcache()
|
self._fullcache()
|
||||||
if accessing_obj:
|
|
||||||
[attr.delete() for attr in self._cache.values()
|
if category is not None:
|
||||||
if attr and attr.access(accessing_obj, self._attredit, default=default_access)]
|
attrs = [attr for attr in self._cache.values() if attr.category == category]
|
||||||
else:
|
else:
|
||||||
[attr.delete() for attr in self._cache.values() if attr and attr.pk]
|
attrs = self._cache.values()
|
||||||
|
|
||||||
|
if accessing_obj:
|
||||||
|
[attr.delete() for attr in attrs
|
||||||
|
if attr and
|
||||||
|
attr.access(accessing_obj, self._attredit, default=default_access)]
|
||||||
|
else:
|
||||||
|
[attr.delete() for attr in attrs if attr and attr.pk]
|
||||||
self._cache = {}
|
self._cache = {}
|
||||||
self._catcache = {}
|
self._catcache = {}
|
||||||
self._cache_complete = False
|
self._cache_complete = False
|
||||||
|
|
|
||||||
|
|
@ -348,7 +348,9 @@ class TagHandler(object):
|
||||||
"""
|
"""
|
||||||
if not self._cache_complete:
|
if not self._cache_complete:
|
||||||
self._fullcache()
|
self._fullcache()
|
||||||
query = {"%s__id" % self._model: self._objid, "tag__db_model": self._model, "tag__db_tagtype": self._tagtype}
|
query = {"%s__id" % self._model: self._objid,
|
||||||
|
"tag__db_model": self._model,
|
||||||
|
"tag__db_tagtype": self._tagtype}
|
||||||
if category:
|
if category:
|
||||||
query["tag__db_category"] = category.strip().lower()
|
query["tag__db_category"] = category.strip().lower()
|
||||||
getattr(self.obj, self._m2m_fieldname).through.objects.filter(**query).delete()
|
getattr(self.obj, self._m2m_fieldname).through.objects.filter(**query).delete()
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,6 @@ def create_object(typeclass=None, key=None, location=None, home=None,
|
||||||
tags = make_iter(tags) if tags is not None else None
|
tags = make_iter(tags) if tags is not None else None
|
||||||
attributes = make_iter(attributes) if attributes is not None else None
|
attributes = make_iter(attributes) if attributes is not None else None
|
||||||
|
|
||||||
|
|
||||||
if isinstance(typeclass, str):
|
if isinstance(typeclass, str):
|
||||||
# a path is given. Load the actual typeclass
|
# a path is given. Load the actual typeclass
|
||||||
typeclass = class_from_module(typeclass, settings.TYPECLASS_PATHS)
|
typeclass = class_from_module(typeclass, settings.TYPECLASS_PATHS)
|
||||||
|
|
@ -119,8 +118,9 @@ def create_object(typeclass=None, key=None, location=None, home=None,
|
||||||
try:
|
try:
|
||||||
home = dbid_to_obj(settings.DEFAULT_HOME, _ObjectDB) if not nohome else None
|
home = dbid_to_obj(settings.DEFAULT_HOME, _ObjectDB) if not nohome else None
|
||||||
except _ObjectDB.DoesNotExist:
|
except _ObjectDB.DoesNotExist:
|
||||||
raise _ObjectDB.DoesNotExist("settings.DEFAULT_HOME (= '%s') does not exist, or the setting is malformed." %
|
raise _ObjectDB.DoesNotExist(
|
||||||
settings.DEFAULT_HOME)
|
"settings.DEFAULT_HOME (= '%s') does not exist, or the setting is malformed." %
|
||||||
|
settings.DEFAULT_HOME)
|
||||||
|
|
||||||
# create new instance
|
# create new instance
|
||||||
new_object = typeclass(db_key=key, db_location=location,
|
new_object = typeclass(db_key=key, db_location=location,
|
||||||
|
|
|
||||||
|
|
@ -318,6 +318,9 @@ class EvMenu(object):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# convenient helpers for easy overloading
|
||||||
|
node_border_char = "_"
|
||||||
|
|
||||||
def __init__(self, caller, menudata, startnode="start",
|
def __init__(self, caller, menudata, startnode="start",
|
||||||
cmdset_mergetype="Replace", cmdset_priority=1,
|
cmdset_mergetype="Replace", cmdset_priority=1,
|
||||||
auto_quit=True, auto_look=True, auto_help=True,
|
auto_quit=True, auto_look=True, auto_help=True,
|
||||||
|
|
@ -1047,6 +1050,7 @@ class EvMenu(object):
|
||||||
node (str): The formatted node to display.
|
node (str): The formatted node to display.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
sep = self.node_border_char
|
||||||
|
|
||||||
if self._session:
|
if self._session:
|
||||||
screen_width = self._session.protocol_flags.get(
|
screen_width = self._session.protocol_flags.get(
|
||||||
|
|
@ -1057,8 +1061,8 @@ class EvMenu(object):
|
||||||
nodetext_width_max = max(m_len(line) for line in nodetext.split("\n"))
|
nodetext_width_max = max(m_len(line) for line in nodetext.split("\n"))
|
||||||
options_width_max = max(m_len(line) for line in optionstext.split("\n"))
|
options_width_max = max(m_len(line) for line in optionstext.split("\n"))
|
||||||
total_width = min(screen_width, max(options_width_max, nodetext_width_max))
|
total_width = min(screen_width, max(options_width_max, nodetext_width_max))
|
||||||
separator1 = "_" * total_width + "\n\n" if nodetext_width_max else ""
|
separator1 = sep * total_width + "\n\n" if nodetext_width_max else ""
|
||||||
separator2 = "\n" + "_" * total_width + "\n\n" if total_width else ""
|
separator2 = "\n" + sep * total_width + "\n\n" if total_width else ""
|
||||||
return separator1 + "|n" + nodetext + "|n" + separator2 + "|n" + optionstext
|
return separator1 + "|n" + nodetext + "|n" + separator2 + "|n" + optionstext
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1079,10 +1083,12 @@ def list_node(option_generator, select=None, pagesize=10):
|
||||||
that is called as option_generator(caller) to produce such a list.
|
that is called as option_generator(caller) to produce such a list.
|
||||||
select (callable or str, optional): Node to redirect a selection to. Its `**kwargs` will
|
select (callable or str, optional): Node to redirect a selection to. Its `**kwargs` will
|
||||||
contain the `available_choices` list and `selection` will hold one of the elements in
|
contain the `available_choices` list and `selection` will hold one of the elements in
|
||||||
that list. If a callable, it will be called as select(caller, menuchoice) where
|
that list. If a callable, it will be called as
|
||||||
menuchoice is the chosen option as a string. Should return the target node to goto after
|
select(caller, menuchoice, **kwargs) where menuchoice is the chosen option as a
|
||||||
this selection (or None to repeat the list-node). Note that if this is not given, the
|
string and `available_choices` is a kwarg mapping the option keys to the choices
|
||||||
decorated node must itself provide a way to continue from the node!
|
offered by the option_generator. The callable whould return the name of the target node
|
||||||
|
to goto after this selection (or None to repeat the list-node). Note that if this is not
|
||||||
|
given, the decorated node must itself provide a way to continue from the node!
|
||||||
pagesize (int): How many options to show per page.
|
pagesize (int): How many options to show per page.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ def justify(text, width=None, align="f", indent=0):
|
||||||
words = []
|
words = []
|
||||||
for ip, paragraph in enumerate(paragraphs):
|
for ip, paragraph in enumerate(paragraphs):
|
||||||
if ip > 0:
|
if ip > 0:
|
||||||
words.append(("\n\n", 0))
|
words.append(("\n", 0))
|
||||||
words.extend((word, len(word)) for word in paragraph.split())
|
words.extend((word, len(word)) for word in paragraph.split())
|
||||||
ngaps, wlen, line = 0, 0, []
|
ngaps, wlen, line = 0, 0, []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ let defaultin_plugin = (function () {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 13: // Enter key
|
case 13: // Enter key
|
||||||
var outtext = inputfield.val(); // Grab the text from which-ever inputfield is focused
|
var outtext = inputfield.val() || ""; // Grab the text from which-ever inputfield is focused
|
||||||
if ( outtext && !event.shiftKey ) { // Enter Key without shift --> send Mesg
|
if ( !event.shiftKey ) { // Enter Key without shift --> send Mesg
|
||||||
var lines = outtext.trim().replace(/[\r]+/,"\n").replace(/[\n]+/, "\n").split("\n");
|
var lines = outtext.trim().replace(/[\r]+/,"\n").replace(/[\n]+/, "\n").split("\n");
|
||||||
for (var i = 0; i < lines.length; i++) {
|
for (var i = 0; i < lines.length; i++) {
|
||||||
plugin_handler.onSend( lines[i].trim() );
|
plugin_handler.onSend( lines[i].trim() );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue