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
|
|
@ -54,7 +54,7 @@ class ContribCmdCharCreate(MuxAccountCommand):
|
|||
session = self.session
|
||||
|
||||
# only one character should be in progress at a time, so we check for WIPs first
|
||||
in_progress = [chara for chara in account.db._playable_characters if chara.db.chargen_step]
|
||||
in_progress = [chara for chara in account.characters if chara.db.chargen_step]
|
||||
|
||||
if len(in_progress):
|
||||
# we're continuing chargen for a WIP character
|
||||
|
|
@ -64,7 +64,7 @@ class ContribCmdCharCreate(MuxAccountCommand):
|
|||
charmax = settings.MAX_NR_CHARACTERS
|
||||
|
||||
if not account.is_superuser and (
|
||||
account.db._playable_characters and len(account.db._playable_characters) >= charmax
|
||||
account.characters and len(account.characters) >= charmax
|
||||
):
|
||||
plural = "" if charmax == 1 else "s"
|
||||
self.msg(f"You may only create a maximum of {charmax} character{plural}.")
|
||||
|
|
@ -90,7 +90,7 @@ class ContribCmdCharCreate(MuxAccountCommand):
|
|||
)
|
||||
# initalize the new character to the beginning of the chargen menu
|
||||
new_character.db.chargen_step = "menunode_welcome"
|
||||
account.db._playable_characters.append(new_character)
|
||||
account.add_character(new_character)
|
||||
|
||||
# set the menu node to start at to the character's last saved step
|
||||
startnode = new_character.db.chargen_step
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ def node_apply_character(caller, raw_string, **kwargs):
|
|||
"""
|
||||
tmp_character = kwargs["tmp_character"]
|
||||
new_character = tmp_character.apply(caller)
|
||||
caller.db._playable_characters.append(new_character)
|
||||
caller.add_character(new_character)
|
||||
|
||||
text = "Character created!"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue