catch WIP characters in IC command
This commit is contained in:
parent
ff3ae5ccfc
commit
ee92c3fd86
2 changed files with 26 additions and 4 deletions
|
|
@ -7,17 +7,17 @@ Commands for managing and initiating an in-game character-creation menu.
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
In your game folder `commands/default_cmdsets.py`, import and add
|
In your game folder `commands/default_cmdsets.py`, import and add
|
||||||
`ContribCmdCharCreate` to your `AccountCmdSet`.
|
`ContribChargenCmdSet` to your `AccountCmdSet`.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```python
|
```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):
|
class AccountCmdSet(default_cmds.AccountCmdSet):
|
||||||
|
|
||||||
def at_cmdset_creation(self):
|
def at_cmdset_creation(self):
|
||||||
super().at_cmdset_creation()
|
super().at_cmdset_creation()
|
||||||
self.add(ContribCmdCharCreate)
|
self.add(ContribChargenCmdSet)
|
||||||
```
|
```
|
||||||
|
|
||||||
In your game folder `typeclasses/accounts.py`, import and inherit from `ContribChargenAccount`
|
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 import DefaultAccount
|
||||||
from evennia.commands.default.muxcommand import MuxAccountCommand
|
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.objects.models import ObjectDB
|
||||||
from evennia.utils.evmenu import EvMenu
|
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
|
_MAX_NR_CHARACTERS = settings.MAX_NR_CHARACTERS
|
||||||
|
|
||||||
|
|
@ -35,6 +37,17 @@ except AttributeError:
|
||||||
_CHARGEN_MENU = "evennia.contrib.rpg.character_creator.example_menu"
|
_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):
|
class ContribCmdCharCreate(MuxAccountCommand):
|
||||||
"""
|
"""
|
||||||
create a new character
|
create a new character
|
||||||
|
|
@ -96,6 +109,15 @@ class ContribCmdCharCreate(MuxAccountCommand):
|
||||||
EvMenu(session, _CHARGEN_MENU, startnode=startnode, cmd_on_exit=finish_char_callback)
|
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):
|
class ContribChargenAccount(DefaultAccount):
|
||||||
"""
|
"""
|
||||||
A modified Account class that makes minor changes to the OOC look
|
A modified Account class that makes minor changes to the OOC look
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue