mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Make DefaultObject/Room/Exit's argument optional. Also resolves #2162.
This commit is contained in:
parent
929c16bb14
commit
050b050d24
3 changed files with 30 additions and 13 deletions
|
|
@ -65,6 +65,8 @@ without arguments starts a full interactive Python console.
|
|||
- Add `$random` inlinefunc, supports minval,maxval arguments that can be ints and floats.
|
||||
- Add `evennia.utils.inlinefuncs.raw(<str>)` as a helper to escape inlinefuncs in a string.
|
||||
- Make CmdGet/Drop/Give give proper error if `obj.move_to` returns `False`.
|
||||
- Make `Object/Room/Exit.create`'s `account` argument optional. If not given, will set perms
|
||||
to that of the object itself (along with normal Admin/Dev permission).
|
||||
|
||||
|
||||
## Evennia 0.9 (2018-2019)
|
||||
|
|
|
|||
|
|
@ -2029,10 +2029,11 @@ class DefaultCharacter(DefaultObject):
|
|||
|
||||
# lockstring of newly created rooms, for easy overloading.
|
||||
# Will be formatted with the appropriate attributes.
|
||||
lockstring = "puppet:id({character_id}) or pid({account_id}) or perm(Developer) or pperm(Developer);delete:id({account_id}) or perm(Admin)"
|
||||
lockstring = ("puppet:id({character_id}) or pid({account_id}) or perm(Developer) or pperm(Developer);"
|
||||
"delete:id({account_id}) or perm(Admin)")
|
||||
|
||||
@classmethod
|
||||
def create(cls, key, account, **kwargs):
|
||||
def create(cls, key, account=None, **kwargs):
|
||||
"""
|
||||
Creates a basic Character with default parameters, unless otherwise
|
||||
specified or extended.
|
||||
|
|
@ -2041,8 +2042,8 @@ class DefaultCharacter(DefaultObject):
|
|||
|
||||
Args:
|
||||
key (str): Name of the new Character.
|
||||
account (obj): Account to associate this Character with. Required as
|
||||
an argument, but one can fake it out by supplying None-- it will
|
||||
account (obj, optional): Account to associate this Character with.
|
||||
If unset supplying None-- it will
|
||||
change the default lockset and skip creator attribution.
|
||||
|
||||
Kwargs:
|
||||
|
|
@ -2249,7 +2250,7 @@ class DefaultRoom(DefaultObject):
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def create(cls, key, account, **kwargs):
|
||||
def create(cls, key, account=None, **kwargs):
|
||||
"""
|
||||
Creates a basic Room with default parameters, unless otherwise
|
||||
specified or extended.
|
||||
|
|
@ -2258,7 +2259,9 @@ class DefaultRoom(DefaultObject):
|
|||
|
||||
Args:
|
||||
key (str): Name of the new Room.
|
||||
account (obj): Account to associate this Room with.
|
||||
account (obj, optional): Account to associate this Room with. If
|
||||
given, it will be given specific control/edit permissions to this
|
||||
object (along with normal Admin perms). If not given, default
|
||||
|
||||
Kwargs:
|
||||
description (str): Brief description for this object.
|
||||
|
|
@ -2287,13 +2290,20 @@ class DefaultRoom(DefaultObject):
|
|||
# Get description, if provided
|
||||
description = kwargs.pop("description", "")
|
||||
|
||||
# get locks if provided
|
||||
locks = kwargs.pop("locks", "")
|
||||
|
||||
try:
|
||||
# Create the Room
|
||||
obj = create.create_object(**kwargs)
|
||||
|
||||
# Set appropriate locks
|
||||
lockstring = kwargs.get("locks", cls.lockstring.format(id=account.id))
|
||||
obj.locks.add(lockstring)
|
||||
# Add locks
|
||||
if not locks and account:
|
||||
locks = cls.lockstring.format(**{"id": account.id})
|
||||
elif not locks and not account:
|
||||
locks = cls.lockstring(**{"id": obj.id})
|
||||
|
||||
obj.locks.add(locks)
|
||||
|
||||
# Record creator id and creation IP
|
||||
if ip:
|
||||
|
|
@ -2442,7 +2452,7 @@ class DefaultExit(DefaultObject):
|
|||
# Command hooks
|
||||
|
||||
@classmethod
|
||||
def create(cls, key, account, source, dest, **kwargs):
|
||||
def create(cls, key, source, dest, account=None, **kwargs):
|
||||
"""
|
||||
Creates a basic Exit with default parameters, unless otherwise
|
||||
specified or extended.
|
||||
|
|
@ -2486,13 +2496,18 @@ class DefaultExit(DefaultObject):
|
|||
|
||||
description = kwargs.pop("description", "")
|
||||
|
||||
locks = kwargs.get("locks", "")
|
||||
|
||||
try:
|
||||
# Create the Exit
|
||||
obj = create.create_object(**kwargs)
|
||||
|
||||
# Set appropriate locks
|
||||
lockstring = kwargs.get("locks", cls.lockstring.format(id=account.id))
|
||||
obj.locks.add(lockstring)
|
||||
if not locks and account:
|
||||
locks = cls.lockstring.format(**{"id": account.id})
|
||||
elif not locks and not account:
|
||||
locks = cls.lockstring.format(**{"id": obj.id})
|
||||
obj.locks.add(locks)
|
||||
|
||||
# Record creator id and creation IP
|
||||
if ip:
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class DefaultObjectTest(EvenniaTest):
|
|||
def test_exit_create(self):
|
||||
description = "The steaming depths of the dumpster, ripe with refuse in various states of decomposition."
|
||||
obj, errors = DefaultExit.create(
|
||||
"in", self.account, self.room1, self.room2, description=description, ip=self.ip
|
||||
"in", self.room1, self.room2, account=self.account, description=description, ip=self.ip
|
||||
)
|
||||
self.assertTrue(obj, errors)
|
||||
self.assertFalse(errors, errors)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue