species-specific command framework

This commit is contained in:
Amber 2024-01-12 22:37:49 -06:00
parent 151db69595
commit e3cc6674f3
5 changed files with 55 additions and 3 deletions

View File

@ -9,7 +9,6 @@ from evennia.commands.command import Command as BaseCommand
# from evennia import default_cmds # from evennia import default_cmds
class Command(BaseCommand): class Command(BaseCommand):
""" """
Base command (you may see this if a child command had no help text defined) Base command (you may see this if a child command had no help text defined)
@ -32,6 +31,22 @@ class Command(BaseCommand):
# #
pass pass
class CmdMeow(Command):
key = 'meow'
def func(self):
args = self.args.strip()
if not args:
self.caller.msg("Who or what would you like to meow at?")
return
target = self.caller.search(args)
if not target:
return
self.caller.msg(f"You meowed at {target.key}!")
target.msg(f"You got meowed at by {self.caller.key}!")
# ------------------------------------------------------------- # -------------------------------------------------------------
# #

15
commands/custom_cmdset.py Normal file
View File

@ -0,0 +1,15 @@
from evennia import CmdSet
#from commands import encounter_cmdset as encounter
from commands import command as cmd
class SetSpeciesHuman(CmdSet):
def at_cmdset_creation(self):
self.add(cmd.CmdMeow())
class SetSpeciesCatkin(CmdSet):
def at_cmdset_creation(self):
self.add(cmd.CmdMeow())
class SetSpeciesDogkin(CmdSet):
def at_cmdset_creation(self):
self.add(cmd.CmdMeow())

View File

@ -77,14 +77,23 @@ class CmdKiss(EncounterCommand):
self.caller.msg(f"You kiss {self.target}{self.adverb}") self.caller.msg(f"You kiss {self.target}{self.adverb}")
self.target.msg(f"{self.caller} kisses you{self.adverb}") self.target.msg(f"{self.caller} kisses you{self.adverb}")
class SetSpeciesHuman(CmdSet): class SetSpeciesHuman(CmdSet):
def at_cmdset_creation(self): def at_cmdset_creation(self):
self.add(CmdBite) self.add(CmdBite)
self.add(CmdKiss) self.add(CmdKiss)
class SetSpeciesPlaceholder(CmdSet):
class SetSpeciesCatkin(CmdSet):
def at_cmdset_creation(self): def at_cmdset_creation(self):
pass self.add(CmdBite)
self.add(CmdKiss)
class SetSpeciesDogkin(CmdSet):
def at_cmdset_creation(self):
self.add(CmdBite)
self.add(CmdKiss)
# Special encounter commands # Special encounter commands

View File

@ -29,6 +29,9 @@ class Character(ClothedCharacter):
self.cmdset.remove(SetEncounterSpecial) self.cmdset.remove(SetEncounterSpecial)
pass pass
def apply_basic_cmdset(self):
self.cmdset.add(SPECIES_CMDSET[self.db.species])
def at_pre_move(self, destination, **kwargs): def at_pre_move(self, destination, **kwargs):
if self.ndb.encounter_handler: if self.ndb.encounter_handler:
self.msg("You would need to leave the encounter first") self.msg("You would need to leave the encounter first")

View File

@ -1,9 +1,19 @@
from commands.encounter_cmdset import SetSpeciesHuman from commands.encounter_cmdset import SetSpeciesHuman
from commands.encounter_cmdset import SetSpeciesCatkin
from commands.encounter_cmdset import SetSpeciesDogkin
from commands.custom_cmdset import SetSpeciesHuman
from commands.custom_cmdset import SetSpeciesCatkin
from commands.custom_cmdset import SetSpeciesDogkin
SPECIES_LIST = [ SPECIES_LIST = [
"Human", "Human",
"Catkin",
"Dogkin"
] ]
SPECIES_CMDSET = [ SPECIES_CMDSET = [
SetSpeciesHuman, SetSpeciesHuman,
SetSpeciesCatkin,
SetSpeciesDogkin
] ]