mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Merge pull request #3554 from InspectorCaracal/chargen-bugfix
Fix character creator contrib commands
This commit is contained in:
commit
9a92c20204
2 changed files with 28 additions and 6 deletions
|
|
@ -7,17 +7,17 @@ Commands for managing and initiating an in-game character-creation menu.
|
|||
## Installation
|
||||
|
||||
In your game folder `commands/default_cmdsets.py`, import and add
|
||||
`ContribCmdCharCreate` to your `AccountCmdSet`.
|
||||
`ContribChargenCmdSet` to your `AccountCmdSet`.
|
||||
|
||||
Example:
|
||||
```python
|
||||
from evennia.contrib.rpg.character_creator.character_creator import ContribCmdCharCreate
|
||||
from evennia.contrib.rpg.character_creator.character_creator import ContribChargenCmdSet
|
||||
|
||||
class AccountCmdSet(default_cmds.AccountCmdSet):
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
super().at_cmdset_creation()
|
||||
self.add(ContribCmdCharCreate)
|
||||
self.add(ContribChargenCmdSet)
|
||||
```
|
||||
|
||||
In your game folder `typeclasses/accounts.py`, import and inherit from `ContribChargenAccount`
|
||||
|
|
|
|||
|
|
@ -23,9 +23,11 @@ from django.conf import settings
|
|||
|
||||
from evennia import DefaultAccount
|
||||
from evennia.commands.default.muxcommand import MuxAccountCommand
|
||||
from evennia.commands.default.account import CmdIC
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.objects.models import ObjectDB
|
||||
from evennia.utils.evmenu import EvMenu
|
||||
from evennia.utils.utils import is_iter
|
||||
from evennia.utils.utils import is_iter, string_partial_matching
|
||||
|
||||
_MAX_NR_CHARACTERS = settings.MAX_NR_CHARACTERS
|
||||
|
||||
|
|
@ -35,6 +37,17 @@ except AttributeError:
|
|||
_CHARGEN_MENU = "evennia.contrib.rpg.character_creator.example_menu"
|
||||
|
||||
|
||||
class ContribCmdIC(CmdIC):
|
||||
def func(self):
|
||||
if self.args:
|
||||
# check if the args match an in-progress character
|
||||
wips = [chara for chara in self.account.characters if chara.db.chargen_step]
|
||||
if matches := string_partial_matching([c.key for c in wips], self.args):
|
||||
# the character is in progress, resume creation
|
||||
return self.execute_cmd("charcreate")
|
||||
super().func()
|
||||
|
||||
|
||||
class ContribCmdCharCreate(MuxAccountCommand):
|
||||
"""
|
||||
create a new character
|
||||
|
|
@ -87,15 +100,24 @@ class ContribCmdCharCreate(MuxAccountCommand):
|
|||
char = session.new_char
|
||||
if char.db.chargen_step:
|
||||
# this means the character creation process was exited in the middle
|
||||
account.execute_cmd("look")
|
||||
account.execute_cmd("look", session=session)
|
||||
else:
|
||||
# this means character creation was completed - start playing!
|
||||
# execute the ic command to start puppeting the character
|
||||
account.execute_cmd("ic {}".format(char.key))
|
||||
account.execute_cmd("ic {}".format(char.key), session=session)
|
||||
|
||||
EvMenu(session, _CHARGEN_MENU, startnode=startnode, cmd_on_exit=finish_char_callback)
|
||||
|
||||
|
||||
class ContribChargenCmdSet(CmdSet):
|
||||
key = "Contrib Chargen CmdSet"
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
super().at_cmdset_creation()
|
||||
self.add(ContribCmdIC)
|
||||
self.add(ContribCmdCharCreate)
|
||||
|
||||
|
||||
class ContribChargenAccount(DefaultAccount):
|
||||
"""
|
||||
A modified Account class that changes the OOC look output to better match the contrib and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue