Removing direct access to Account.db._playable_characters in favor of Account.add_character(char) and Account.remove_character(char). Account.characters already handles all filtering so am cleaning up lots of repeated list comprehensions which remove/filter deleted characters.
This commit is contained in:
parent
a8cf8e166a
commit
f782cd8fc8
10 changed files with 124 additions and 60 deletions
|
|
@ -310,7 +310,7 @@ class ObjectAdmin(admin.ModelAdmin):
|
|||
This will:
|
||||
|
||||
- Set account.db._last_puppet to this object
|
||||
- Add object to account.db._playable_characters
|
||||
- Add object to account.characters
|
||||
- Change object locks to allow puppeting by account
|
||||
|
||||
"""
|
||||
|
|
@ -319,10 +319,7 @@ class ObjectAdmin(admin.ModelAdmin):
|
|||
|
||||
if account:
|
||||
account.db._last_puppet = obj
|
||||
if not account.db._playable_characters:
|
||||
account.db._playable_characters = []
|
||||
if obj not in account.db._playable_characters:
|
||||
account.db._playable_characters.append(obj)
|
||||
account.add_character(obj)
|
||||
if not obj.access(account, "puppet"):
|
||||
lock = obj.locks.get("puppet")
|
||||
lock += f" or pid({account.id})"
|
||||
|
|
@ -331,7 +328,7 @@ class ObjectAdmin(admin.ModelAdmin):
|
|||
request,
|
||||
"Did the following (where possible): "
|
||||
f"Set Account.db._last_puppet = {obj}, "
|
||||
f"Added {obj} to Account.db._playable_characters list, "
|
||||
f"Added {obj} to Account.characters list, "
|
||||
f"Added 'puppet:pid({account.id})' lock to {obj}.",
|
||||
)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ def collect_topics(account):
|
|||
cmd_help_topics = []
|
||||
if not str(account) == "AnonymousUser":
|
||||
# create list of account and account's puppets
|
||||
puppets = account.db._playable_characters + [account]
|
||||
puppets = account.characters + [account]
|
||||
# add the account's and puppets' commands to cmd_help_topics list
|
||||
for puppet in puppets:
|
||||
for cmdset in puppet.cmdset.get():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue