ready to try it

This commit is contained in:
InspectorCaracal 2022-08-19 23:11:28 -06:00
parent bbfaa3f543
commit 615809ce05
2 changed files with 24 additions and 25 deletions

View file

@ -27,6 +27,7 @@ from evennia.objects.models import ObjectDB
from evennia.utils import create, search from evennia.utils import create, search
from evennia.utils.evmenu import EvMenu from evennia.utils.evmenu import EvMenu
_CHARACTER_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS
class ContribCmdCharCreate(MuxAccountCommand): class ContribCmdCharCreate(MuxAccountCommand):
""" """
@ -48,7 +49,7 @@ class ContribCmdCharCreate(MuxAccountCommand):
session = self.session session = self.session
# only one character should be in progress at a time, so we check for WIPs first # only one character should be in progress at a time, so we check for WIPs first
in_progress = [chara for chara in account.playable if chara.db.chargen_step] in_progress = [chara for chara in account.db._playable_characters if chara.db.chargen_step]
if len(in_progress): if len(in_progress):
# we're continuing chargen for a WIP character # we're continuing chargen for a WIP character
@ -70,7 +71,7 @@ class ContribCmdCharCreate(MuxAccountCommand):
permissions = settings.PERMISSION_ACCOUNT_DEFAULT permissions = settings.PERMISSION_ACCOUNT_DEFAULT
# generate a randomized key so the player can choose a character name later # generate a randomized key so the player can choose a character name later
key = ''.join(choices(string.ascii_letters + string.digits, k=10) key = ''.join(choices(string.ascii_letters + string.digits, k=10)
new_character = create.create_object(Character, key=key, new_character = create.create_object(_CHARACTER_TYPECLASS, key=key,
location=None, location=None,
home=home, home=home,
permissions=permissions) permissions=permissions)
@ -92,13 +93,8 @@ class ContribCmdCharCreate(MuxAccountCommand):
char = session.new_char char = session.new_char
if not char.db.chargen_step: if not char.db.chargen_step:
# this means character creation was completed - start playing! # this means character creation was completed - start playing!
# any additional first-time-playing code can go here as well # execute the ic command to start puppeting the character
# e.g. creating generic default gear, account.execute_cmd("ic {}".format(char.key))
# changing the pre-logout location of the character so they log in to a specific spot,
# notifying admins of a new player, etc.
# execute the ic command as the session to start puppeting the character
session.execute_cmd("ic {}".format(char.key))
EvMenu(session, EvMenu(session,
settings.CHARGEN_MENU, settings.CHARGEN_MENU,

View file

@ -1,8 +1,6 @@
from evennia.utils.test_resources import ( from django.test import override_settings
BaseEvenniaTest, from evennia.utils import inherits_from
BaseEvenniaCommandTest, from evennia.utils.test_resources import BaseEvenniaCommandTest
EvenniaCommandTest,
) # noqa
from . import character_creator from . import character_creator
class TestAccount(BaseEvenniaCommandTest): class TestAccount(BaseEvenniaCommandTest):
@ -12,21 +10,26 @@ class TestAccount(BaseEvenniaCommandTest):
account.CmdOOCLook(), "", "You are out-of-character (OOC).", caller=self.account account.CmdOOCLook(), "", "You are out-of-character (OOC).", caller=self.account
) )
if settings.MULTISESSION_MODE == 2: if settings.MULTISESSION_MODE == 2:
# with no playable characters # test both normal output and also inclusion of in-progress character
self.call( account.db._playable_characters = [self.char1]
self.char1.db.chargen_step = "start"
output = self.call(
account.CmdOOCLook(), account.CmdOOCLook(),
"", "",
"Account TestAccount (you are Out-of-Character)", "Account TestAccount (you are Out-of-Character)",
caller=self.account, caller=self.account,
) )
# with in-progress character self.assertIn("|Yin progress|n", output)
@override_settings(CHARGEN_MENU="evennia.contrib.base_systems.example_menu")
def test_char_create(self): def test_char_create(self):
account = self.account
session = self.session
self.call( self.call(
character_creator.ContribCmdCharCreate(), character_creator.ContribCmdCharCreate(),
"Test1=Test char", "",
"Created new character Test1. Use ic Test1 to enter the game", caller=account,
caller=self.account,
) )
menu = session.ndb._menutree
self.assertNotNone(menu)
self.assertTrue(inherits_from(session.new_char, DefaultCharacter) )