hazelmud/typeclasses/characters.py

39 lines
1.2 KiB
Python

from evennia.contrib.game_systems.clothing import ClothedCharacter
from evennia.contrib.rpg.traits import TraitHandler
from commands.encounter_cmdset import SetEncounterSpecial
from world.species import SPECIES_CMDSET
CURRENT_VERSION = 1
class Character(ClothedCharacter):
def at_object_creation(self):
self.db.version = 1
self.db.species = 0
def apply_encounter_cmdset(self):
self.cmdset.add(SetEncounterSpecial)
self.cmdset.add(SPECIES_CMDSET[self.db.species])
def revoke_encounter_cmdset(self):
self.cmdset.remove(SPECIES_CMDSET[self.db.species])
self.cmdset.remove(SetEncounterSpecial)
pass
def at_pre_move(self, destination, **kwargs):
if self.ndb.encounter_handler:
self.msg("You would need to leave the encounter first")
return False
return True
def at_pre_say(self, speech):
if self.ndb.encounter_handler:
if self.ndb.encounter_handler.is_turn(self):
self.ndb.encounter_handler.msg_all(f"{self} says, \"{speech}\"")
else:
self.ndb.encounter_handler.pre_say(self)
return None
else:
return speech