From f3589e5f0378ebdda0ba9b83e8cbaf484ab572a5 Mon Sep 17 00:00:00 2001 From: InspectorCaracal Date: Fri, 19 Aug 2022 23:11:28 -0600 Subject: [PATCH] ready to try it --- .../character_creator/character_creator.py | 20 +++++-------- .../base_systems/character_creator/tests.py | 29 ++++++++++--------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/evennia/contrib/base_systems/character_creator/character_creator.py b/evennia/contrib/base_systems/character_creator/character_creator.py index 2749d5dfe7..aa20cb87cd 100644 --- a/evennia/contrib/base_systems/character_creator/character_creator.py +++ b/evennia/contrib/base_systems/character_creator/character_creator.py @@ -27,6 +27,7 @@ from evennia.objects.models import ObjectDB from evennia.utils import create, search from evennia.utils.evmenu import EvMenu +_CHARACTER_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS class ContribCmdCharCreate(MuxAccountCommand): """ @@ -48,7 +49,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.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): # we're continuing chargen for a WIP character @@ -70,7 +71,7 @@ class ContribCmdCharCreate(MuxAccountCommand): permissions = settings.PERMISSION_ACCOUNT_DEFAULT # generate a randomized key so the player can choose a character name later 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, home=home, permissions=permissions) @@ -92,18 +93,13 @@ class ContribCmdCharCreate(MuxAccountCommand): char = session.new_char if not char.db.chargen_step: # this means character creation was completed - start playing! - # any additional first-time-playing code can go here as well - # e.g. creating generic default gear, - # 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)) + # execute the ic command to start puppeting the character + account.execute_cmd("ic {}".format(char.key)) EvMenu(session, - settings.CHARGEN_MENU, - startnode=startnode, - cmd_on_exit=finish_char_callback) + settings.CHARGEN_MENU, + startnode=startnode, + cmd_on_exit=finish_char_callback) from django.conf import settings diff --git a/evennia/contrib/base_systems/character_creator/tests.py b/evennia/contrib/base_systems/character_creator/tests.py index 8e8bf4fba2..45076d7162 100644 --- a/evennia/contrib/base_systems/character_creator/tests.py +++ b/evennia/contrib/base_systems/character_creator/tests.py @@ -1,8 +1,6 @@ -from evennia.utils.test_resources import ( - BaseEvenniaTest, - BaseEvenniaCommandTest, - EvenniaCommandTest, -) # noqa +from django.test import override_settings +from evennia.utils import inherits_from +from evennia.utils.test_resources import BaseEvenniaCommandTest from . import character_creator class TestAccount(BaseEvenniaCommandTest): @@ -12,21 +10,26 @@ class TestAccount(BaseEvenniaCommandTest): account.CmdOOCLook(), "", "You are out-of-character (OOC).", caller=self.account ) if settings.MULTISESSION_MODE == 2: - # with no playable characters - self.call( + # test both normal output and also inclusion of in-progress character + account.db._playable_characters = [self.char1] + self.char1.db.chargen_step = "start" + output = self.call( account.CmdOOCLook(), "", "Account TestAccount (you are Out-of-Character)", 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): + account = self.account + session = self.session self.call( character_creator.ContribCmdCharCreate(), - "Test1=Test char", - "Created new character Test1. Use ic Test1 to enter the game", - caller=self.account, + "", + caller=account, ) - + menu = session.ndb._menutree + self.assertNotNone(menu) + self.assertTrue(inherits_from(session.new_char, DefaultCharacter) )