ready to try it

This commit is contained in:
InspectorCaracal 2022-08-19 23:11:28 -06:00
parent cb2cb94082
commit f3589e5f03
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.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

View file

@ -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) )