mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Merge pull request #1 from evennia/master
Updating before submitting PR.
This commit is contained in:
commit
2818b90f89
9 changed files with 40 additions and 22 deletions
|
|
@ -70,6 +70,8 @@ without arguments starts a full interactive Python console.
|
|||
- Make `INLINEFUNC_STACK_MAXSIZE` default visible in `settings_default.py`.
|
||||
- Change how `ic` finds puppets; non-priveleged users will use `_playable_characters` list as
|
||||
candidates, Builders+ will use list, local search and only global search if no match found.
|
||||
- Make `cmd.at_post_cmd()` always run after `cmd.func()`, even when the latter uses delays
|
||||
with yield.
|
||||
|
||||
|
||||
## Evennia 0.9 (2018-2019)
|
||||
|
|
|
|||
|
|
@ -1262,7 +1262,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
|||
]
|
||||
except Exception:
|
||||
logger.log_trace()
|
||||
now = timezone.now()
|
||||
now = timezone.localtime()
|
||||
now = "%02i-%02i-%02i(%02i:%02i)" % (now.year, now.month, now.day, now.hour, now.minute)
|
||||
if _MUDINFO_CHANNEL:
|
||||
_MUDINFO_CHANNEL.tempmsg(f"[{_MUDINFO_CHANNEL.key}, {now}]: {message}")
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ def _progressive_cmd_run(cmd, generator, response=None):
|
|||
else:
|
||||
value = generator.send(response)
|
||||
except StopIteration:
|
||||
pass
|
||||
raise
|
||||
else:
|
||||
if isinstance(value, (int, float)):
|
||||
utils.delay(value, _progressive_cmd_run, cmd, generator)
|
||||
|
|
@ -631,20 +631,31 @@ def cmdhandler(
|
|||
ret = cmd.func()
|
||||
if isinstance(ret, types.GeneratorType):
|
||||
# cmd.func() is a generator, execute progressively
|
||||
_progressive_cmd_run(cmd, ret)
|
||||
in_generator = True
|
||||
try:
|
||||
_progressive_cmd_run(cmd, ret)
|
||||
except StopIteration:
|
||||
# this means func() has run its course
|
||||
in_generator = False
|
||||
yield None
|
||||
else:
|
||||
in_generator = False
|
||||
ret = yield ret
|
||||
|
||||
# post-command hook
|
||||
yield cmd.at_post_cmd()
|
||||
if not in_generator:
|
||||
# this will only run if we are out of the generator for this
|
||||
# cmd, otherwise we would have at_post_cmd run before a delayed
|
||||
# func() finished
|
||||
|
||||
if cmd.save_for_next:
|
||||
# store a reference to this command, possibly
|
||||
# accessible by the next command.
|
||||
caller.ndb.last_cmd = yield copy(cmd)
|
||||
else:
|
||||
caller.ndb.last_cmd = None
|
||||
# post-command hook
|
||||
yield cmd.at_post_cmd()
|
||||
|
||||
if cmd.save_for_next:
|
||||
# store a reference to this command, possibly
|
||||
# accessible by the next command.
|
||||
caller.ndb.last_cmd = yield copy(cmd)
|
||||
else:
|
||||
caller.ndb.last_cmd = None
|
||||
|
||||
# return result to the deferred
|
||||
returnValue(ret)
|
||||
|
|
|
|||
|
|
@ -1146,7 +1146,7 @@ class TestBuilding(CommandTest):
|
|||
"= Obj",
|
||||
"To create a global script you need scripts/add <typeclass>.",
|
||||
)
|
||||
self.call(building.CmdScript(), "Obj = ", "dbref obj")
|
||||
self.call(building.CmdScript(), "Obj ", "dbref ")
|
||||
|
||||
self.call(
|
||||
building.CmdScript(), "/start Obj", "0 scripts started on Obj"
|
||||
|
|
|
|||
|
|
@ -339,22 +339,23 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
|||
singular (str): The singular form to display.
|
||||
plural (str): The determined plural form of the key, including the count.
|
||||
"""
|
||||
plural_category = "plural_key"
|
||||
key = kwargs.get("key", self.key)
|
||||
key = ansi.ANSIString(key) # this is needed to allow inflection of colored names
|
||||
try:
|
||||
plural = _INFLECT.plural(key, 2)
|
||||
plural = "%s %s" % (_INFLECT.number_to_words(count, threshold=12), plural)
|
||||
plural = _INFLECT.plural(key, count)
|
||||
plural = "{} {}".format(_INFLECT.number_to_words(count, threshold=12), plural)
|
||||
except IndexError:
|
||||
# this is raised by inflect if the input is not a proper noun
|
||||
plural = key
|
||||
singular = _INFLECT.an(key)
|
||||
if not self.aliases.get(plural, category="plural_key"):
|
||||
if not self.aliases.get(plural, category=plural_category):
|
||||
# we need to wipe any old plurals/an/a in case key changed in the interrim
|
||||
self.aliases.clear(category="plural_key")
|
||||
self.aliases.add(plural, category="plural_key")
|
||||
self.aliases.clear(category=plural_category)
|
||||
self.aliases.add(plural, category=plural_category)
|
||||
# save the singular form as an alias here too so we can display "an egg" and also
|
||||
# look at 'an egg'.
|
||||
self.aliases.add(singular, category="plural_key")
|
||||
self.aliases.add(singular, category=plural_category)
|
||||
return singular, plural
|
||||
|
||||
def search(
|
||||
|
|
|
|||
|
|
@ -1368,10 +1368,10 @@ def create_settings_file(init=True, secret_settings=False):
|
|||
if not init:
|
||||
# if not --init mode, settings file may already exist from before
|
||||
if os.path.exists(settings_path):
|
||||
inp = eval(input("%s already exists. Do you want to reset it? y/[N]> " % settings_path))
|
||||
inp = input("%s already exists. Do you want to reset it? y/[N]> " % settings_path)
|
||||
if not inp.lower() == "y":
|
||||
print("Aborted.")
|
||||
return
|
||||
sys.exit()
|
||||
else:
|
||||
print("Reset the settings file.")
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ class Attribute(SharedMemoryModel):
|
|||
def __repr__(self):
|
||||
return "%s(%s)" % (self.db_key, self.id)
|
||||
|
||||
def access(self, accessing_obj, access_type="read", default=False, **kwargs):
|
||||
def access(self, accessing_obj, access_type="attrread", default=False, **kwargs):
|
||||
"""
|
||||
Determines if another object has permission to access.
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class TestCreateMessage(EvenniaTest):
|
|||
locks=locks,
|
||||
tags=tags,
|
||||
)
|
||||
self.assertEqual(msg.receivers, [self.char1, self.char2])
|
||||
self.assertEqual(set(msg.receivers), set([self.char1, self.char2]))
|
||||
self.assertTrue(all(lock in msg.locks.all() for lock in locks.split(";")))
|
||||
self.assertEqual(msg.tags.all(), tags)
|
||||
|
||||
|
|
|
|||
|
|
@ -1917,6 +1917,10 @@ def at_search_result(matches, caller, query="", quiet=False, **kwargs):
|
|||
for num, result in enumerate(matches):
|
||||
# we need to consider Commands, where .aliases is a list
|
||||
aliases = result.aliases.all() if hasattr(result.aliases, "all") else result.aliases
|
||||
# remove any pluralization aliases
|
||||
aliases = [alias for alias in aliases if
|
||||
hasattr(alias, "category")
|
||||
and alias.category not in ("plural_key", )]
|
||||
error += _MULTIMATCH_TEMPLATE.format(
|
||||
number=num + 1,
|
||||
name=result.get_display_name(caller)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue