make pronounsub more resillient

This commit is contained in:
lunacb 2023-01-14 11:37:50 -05:00
parent 7e34080666
commit 88ba451426
1 changed files with 13 additions and 4 deletions

View File

@ -33,7 +33,6 @@ default cmdset before it becomes available.
"""
import random
import re
from evennia import Command, DefaultCharacter
from evennia import InterruptCommand
@ -221,8 +220,8 @@ class PronounsCommand(Command):
key = "pronouns"
def parse(self):
caller = self.caller
caller.pronoun_object_init()
args = self.args.strip().lower().split()
if len(args) == 1:
@ -255,6 +254,7 @@ class PronounsCommand(Command):
def func(self):
caller = self.caller
caller.pronoun_object_init()
command = self.args[0]
@ -306,13 +306,20 @@ class PronounCharacter(DefaultCharacter):
"""
# This should be called before every use of a Character to make sure it's
# initialized right.
def pronoun_object_init(self):
if self.db.pronouns == None:
self.db.pronouns = DEFAULT_CHARACTER_PRONOUNS[:]
if self.db.pronoun_specs == None:
self.db.pronoun_specs = []
def at_object_creation(self):
"""
Called once when the object is created.
"""
super().at_object_creation()
self.db.pronouns = DEFAULT_CHARACTER_PRONOUNS[:]
self.db.pronoun_specs = []
self.pronoun_object_init()
def _stringify_pronouns(self):
pronouns = self.attributes.get("pronouns", default=DEFAULT_CHARACTER_PRONOUNS[:])
@ -354,6 +361,8 @@ class PronounCharacter(DefaultCharacter):
return pronoun.capitalize() if typ.isupper() else pronoun
def msg(self, text=None, from_obj=None, session=None, **kwargs):
self.pronoun_object_init()
"""
Emits something to a session attached to the object.
Overloads the default msg() implementation to include