Fix merge conflict

This commit is contained in:
Griatch 2023-01-15 13:48:56 +01:00
commit e5abef74c6
3 changed files with 46 additions and 1 deletions

View file

@ -1354,9 +1354,14 @@ rooms without editing the map files outside of the game.
## Installation
1. If you haven't before, install the extra contrib requirements.
<<<<<<< HEAD
You can do so by doing `pip install evennia[extra]`, or if you used `git` to
install, do `pip install --upgrade -e .[extra]` from the `evennia/` repo
folder.
=======
You can do so by doing `pip install evennia[extra]` from the
`evennia/` folder.
>>>>>>> f4253e600eac5c55445e8cb599e49d5cf060494a
2. Import and add the `evennia.contrib.grid.xyzgrid.commands.XYZGridCmdSet` to the
`CharacterCmdset` cmdset in `mygame/commands.default_cmds.py`. Reload
the server. This makes the `map`, `goto/path` and modified `teleport` and

View file

@ -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:

View file

@ -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)
```