From dbf476699093c895d34bb90930ce0019f82b6ab8 Mon Sep 17 00:00:00 2001 From: John Steensen <2449496+jrsteensen@users.noreply.github.com> Date: Sat, 7 Jan 2023 18:08:22 -0700 Subject: [PATCH 1/3] Update README.md Added section at bottom addressing adding additional TraitHandlers. Shows example based on first example, but instead using a stats, skills and the original TraitHandler. --- evennia/contrib/rpg/traits/README.md | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/evennia/contrib/rpg/traits/README.md b/evennia/contrib/rpg/traits/README.md index 48aa10cd4e..86254b350e 100644 --- a/evennia/contrib/rpg/traits/README.md +++ b/evennia/contrib/rpg/traits/README.md @@ -439,3 +439,42 @@ class Character(DefaultCharacter): rage = TraitProperty("A dark mood", rage=30, trait_type='rage') ``` + +## Adding additional TraitHandlers + +Sometimes, it is easier to top-level classify traits, such as stats, skills, or other categories of traits you want to handle independantly of each other. Here is an example showing an example on the object typeclass, expanding on the first installation example: + +```python +# mygame/typeclasses/objects.py + +from evennia import DefaultCharacter +from evennia.utils import lazy_property +from evennia.contrib.rpg.traits import TraitHandler + +# ... + +class Character(DefaultCharacter): + ... + @lazy_property + def traits(self): + # this adds the handler as .traits + return TraitHandler(self) + + @lazy_property + def stats(self): + # this adds the handler as .stats + return TraitHandler(self, db_attribute_key="stats") + + @lazy_property + def skills(self): + # this adds the handler as .skills + return TraitHandler(self, db_attribute_key="skills") + + + def at_object_creation(self): + # (or wherever you want) + self.stats.add("str", "Strength", trait_type="static", base=10, mod=2) + self.traits.add("hp", "Health", trait_type="gauge", min=0, max=100) + self.skills.add("hunting", "Hunting Skill", trait_type="counter", + base=10, mod=1, min=0, max=100) +``` From 7172d1a39fe4c20ee79b97b874633c8e30b06030 Mon Sep 17 00:00:00 2001 From: Xinefus/Braska <64438452+Xinefus-Braska@users.noreply.github.com> Date: Fri, 13 Jan 2023 23:14:59 -0500 Subject: [PATCH 2/3] Update Contrib-XYZGrid.md install method changed to `pip install evennia[extra]` --- docs/source/Contribs/Contrib-XYZGrid.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/Contribs/Contrib-XYZGrid.md b/docs/source/Contribs/Contrib-XYZGrid.md index 879b146336..2c2ab55b1d 100644 --- a/docs/source/Contribs/Contrib-XYZGrid.md +++ b/docs/source/Contribs/Contrib-XYZGrid.md @@ -49,7 +49,7 @@ Exits: northeast and east doing (cd to evennia/ folder) - pip install -r requirements_extra.txt + pip install evennia[extra] (then go back to your mygame/ folder) This will install all optional requirements of Evennia. @@ -1352,7 +1352,7 @@ rooms without editing the map files outside of the game. ## Installation 1. If you haven't before, install the extra contrib requirements. - You can do so by doing `pip install -r requirements_extra.txt` from the + You can do so by doing `pip install evennia[extra]` from the `evennia/` folder. 2. Import and add the `evennia.contrib.grid.xyzgrid.commands.XYZGridCmdSet` to the `CharacterCmdset` cmdset in `mygame/commands.default_cmds.py`. Reload From 54f21bd6652b5b5955b8d18a7a280f04ad397f3b Mon Sep 17 00:00:00 2001 From: Wendy Wang Date: Sat, 14 Jan 2023 17:18:02 +0100 Subject: [PATCH 3/3] Adding notification when discord bot session begins, fixing caller -> self.caller --- evennia/commands/default/comms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/evennia/commands/default/comms.py b/evennia/commands/default/comms.py index 32a0a40b8d..e15804b57f 100644 --- a/evennia/commands/default/comms.py +++ b/evennia/commands/default/comms.py @@ -312,7 +312,7 @@ class CmdChannel(COMMAND_DEFAULT_CLASS): """ if not channel.access(self.caller, "send"): - caller.msg(f"You are not allowed to send messages to channel {channel}") + self.caller.msg(f"You are not allowed to send messages to channel {channel}") return # avoid unsafe tokens in message @@ -1980,6 +1980,7 @@ class CmdDiscord2Chan(COMMAND_DEFAULT_CLASS): self.msg("The Discord bot is already running.") else: discord_bot.start() + self.msg("Starting the Discord bot session.") return if "guild" in self.switches: