81 lines
2.8 KiB
Python
81 lines
2.8 KiB
Python
"""
|
|
Characters
|
|
|
|
Characters are (by default) Objects setup to be puppeted by Accounts.
|
|
They are what you "see" in game. The Character class in this module
|
|
is setup to be the "default" character type created by the default
|
|
creation commands.
|
|
|
|
"""
|
|
from evennia import DefaultCharacter
|
|
from evennia.utils import inherits_from
|
|
|
|
from typeclasses import rooms
|
|
from typeclasses.exits import Exit
|
|
from utils.utils import has_tag, has_effect, has_effect_in
|
|
|
|
|
|
class Character(DefaultCharacter):
|
|
"""
|
|
The Character defaults to reimplementing some of base Object's hook methods with the
|
|
following functionality:
|
|
|
|
at_basetype_setup - always assigns the DefaultCmdSet to this object type
|
|
(important!)sets locks so character cannot be picked up
|
|
and its commands only be called by itself, not anyone else.
|
|
(to change things, use at_object_creation() instead).
|
|
at_after_move(source_location) - Launches the "look" command after every move.
|
|
at_post_unpuppet(account) - when Account disconnects from the Character, we
|
|
store the current location in the pre_logout_location Attribute and
|
|
move it to a None-location so the "unpuppeted" character
|
|
object does not need to stay on grid. Echoes "Account has disconnected"
|
|
to the room.
|
|
at_pre_puppet - Just before Account re-connects, retrieves the character's
|
|
pre_logout_location Attribute and move it back on the grid.
|
|
at_post_puppet - Echoes "AccountName has entered the game" to the room.
|
|
|
|
"""
|
|
|
|
def at_object_creation(self):
|
|
self.db.desc = "A human being."
|
|
|
|
self.db.health = 1
|
|
self.db.mana = 1
|
|
|
|
self.db.strength = 1
|
|
self.db.agility = 1
|
|
self.db.intellect = 1
|
|
|
|
self.db.equipment = {
|
|
'head': None,
|
|
'torso': None,
|
|
'legs': None,
|
|
'right hand': None,
|
|
'left hand': None,
|
|
'foot': None
|
|
}
|
|
|
|
self.db.spells = []
|
|
self.db.recipes = []
|
|
self.db.current_action = None
|
|
|
|
def get_health(self):
|
|
return self.db.health
|
|
|
|
def get_mana(self):
|
|
return self.db.mana
|
|
|
|
def get_abilities(self):
|
|
return self.db.strength, self.db.agility, self.db.intellect
|
|
|
|
def at_look(self, target, **kwargs):
|
|
description = super().at_look(target, **kwargs)
|
|
|
|
# You can't see things in room if it's dark.
|
|
if inherits_from(self.location, rooms.IndoorRoom):
|
|
if not self.is_superuser and not self.location.db.is_lit and \
|
|
not (inherits_from(target, rooms.Room) or inherits_from(target, Exit)):
|
|
description = "Could not find '{}'.".format(target.name)
|
|
|
|
return description
|
|
|