Various fixes from game jam

This commit is contained in:
Griatch 2019-05-14 10:33:31 +02:00
parent e6aec78cce
commit ed187ad05f
12 changed files with 45 additions and 28 deletions

View file

@ -647,6 +647,7 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess
args = raw_string
unformatted_raw_string = "%s%s" % (cmdname, args)
cmdset = None
raw_cmdname = cmdname
# session = session
# account = account

View file

@ -483,7 +483,6 @@ class Command(with_metaclass(CommandMeta, object)):
h_line_char = kwargs.pop('header_line_char', '~')
header_line_char = ANSIString(f'|{border_color}{h_line_char}|n')
c_char = kwargs.pop('corner_char', '+')
corner_char = ANSIString(f'|{border_color}{c_char}|n')

View file

@ -415,7 +415,7 @@ class CmdWho(COMMAND_DEFAULT_CLASS):
else:
show_session_data = account.check_permstring("Developer") or account.check_permstring("Admins")
naccounts = (SESSIONS.account_count())
naccounts = SESSIONS.account_count()
if show_session_data:
# privileged info
table = self.style_table("|wAccount Name",

View file

@ -618,7 +618,7 @@ class _ObjDummy:
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):
"""
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.
"""
global _LOCKHANDLER
if not _LOCKHANDLER:
_LOCKHANDLER = LockHandler(_ObjDummy())
global _LOCK_HANDLER
if not _LOCK_HANDLER:
_LOCK_HANDLER = LockHandler(_ObjDummy())
return _LOCK_HANDLER.check_lockstring(
accessing_obj, lockstring, no_superuser_bypass=no_superuser_bypass,
default=default, access_type=access_type)

View file

@ -1623,7 +1623,9 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
commonly an object or the current location. It will
be checked for the "view" type access.
**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:
lookstring (str): A ready-processed look string
@ -1632,15 +1634,15 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
"""
if not target.access(self, "view"):
try:
return "Could not view '%s'." % target.get_display_name(self)
return "Could not view '%s'." % target.get_display_name(self, **kwargs)
except AttributeError:
return "Could not view '%s'." % target.key
description = target.return_appearance(self)
description = target.return_appearance(self, **kwargs)
# the target's at_desc() method.
# 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

View file

@ -493,7 +493,7 @@ TYPECLASS_AGGRESSIVE_CACHE = True
# 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
# of validators from evennia.VALIDATOR_FUNCS to validate input when
# the user changes an option. The options are accessed through the

View file

@ -677,11 +677,18 @@ class AttributeHandler(object):
if not self._cache_complete:
self._fullcache()
if accessing_obj:
[attr.delete() for attr in self._cache.values()
if attr and attr.access(accessing_obj, self._attredit, default=default_access)]
if category is not None:
attrs = [attr for attr in self._cache.values() if attr.category == category]
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._catcache = {}
self._cache_complete = False

View file

@ -348,7 +348,9 @@ class TagHandler(object):
"""
if not self._cache_complete:
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:
query["tag__db_category"] = category.strip().lower()
getattr(self.obj, self._m2m_fieldname).through.objects.filter(**query).delete()

View file

@ -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
attributes = make_iter(attributes) if attributes is not None else None
if isinstance(typeclass, str):
# a path is given. Load the actual typeclass
typeclass = class_from_module(typeclass, settings.TYPECLASS_PATHS)
@ -119,8 +118,9 @@ def create_object(typeclass=None, key=None, location=None, home=None,
try:
home = dbid_to_obj(settings.DEFAULT_HOME, _ObjectDB) if not nohome else None
except _ObjectDB.DoesNotExist:
raise _ObjectDB.DoesNotExist("settings.DEFAULT_HOME (= '%s') does not exist, or the setting is malformed." %
settings.DEFAULT_HOME)
raise _ObjectDB.DoesNotExist(
"settings.DEFAULT_HOME (= '%s') does not exist, or the setting is malformed." %
settings.DEFAULT_HOME)
# create new instance
new_object = typeclass(db_key=key, db_location=location,

View file

@ -318,6 +318,9 @@ class EvMenu(object):
"""
# convenient helpers for easy overloading
node_border_char = "_"
def __init__(self, caller, menudata, startnode="start",
cmdset_mergetype="Replace", cmdset_priority=1,
auto_quit=True, auto_look=True, auto_help=True,
@ -1047,6 +1050,7 @@ class EvMenu(object):
node (str): The formatted node to display.
"""
sep = self.node_border_char
if self._session:
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"))
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))
separator1 = "_" * total_width + "\n\n" if nodetext_width_max else ""
separator2 = "\n" + "_" * total_width + "\n\n" if total_width else ""
separator1 = sep * total_width + "\n\n" if nodetext_width_max else ""
separator2 = "\n" + sep * total_width + "\n\n" if total_width else ""
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.
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
that list. If a callable, it will be called as select(caller, menuchoice) where
menuchoice is the chosen option as a string. Should return 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!
that list. If a callable, it will be called as
select(caller, menuchoice, **kwargs) where menuchoice is the chosen option as a
string and `available_choices` is a kwarg mapping the option keys to the choices
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.
Example:

View file

@ -256,7 +256,7 @@ def justify(text, width=None, align="f", indent=0):
words = []
for ip, paragraph in enumerate(paragraphs):
if ip > 0:
words.append(("\n\n", 0))
words.append(("\n", 0))
words.extend((word, len(word)) for word in paragraph.split())
ngaps, wlen, line = 0, 0, []

View file

@ -26,8 +26,8 @@ let defaultin_plugin = (function () {
break;
case 13: // Enter key
var outtext = inputfield.val(); // Grab the text from which-ever inputfield is focused
if ( outtext && !event.shiftKey ) { // Enter Key without shift --> send Mesg
var outtext = inputfield.val() || ""; // Grab the text from which-ever inputfield is focused
if ( !event.shiftKey ) { // Enter Key without shift --> send Mesg
var lines = outtext.trim().replace(/[\r]+/,"\n").replace(/[\n]+/, "\n").split("\n");
for (var i = 0; i < lines.length; i++) {
plugin_handler.onSend( lines[i].trim() );