characters.py
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
Characters
Characters are (by default) Objects setup to be puppeted by Players.
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 random import randint
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(player) - when Player 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 "Player has disconnected"
to the room.
at_pre_puppet - Just before Player re-connects, retrieves the character's
pre_logout_location Attribute and move it back on the grid.
at_post_puppet - Echoes "PlayerName has entered the game" to the room.
"""
def at_object_creation(self):
self.db.level = 1
self.db.HP = 100
self.db.EXP = 0
#Set all default attributes
self.db.strength = randint(3,18)
self.db.constitution = randint(3,18)
self.db.dexterity = randint(3,18)
self.db.intelligence = randint(3,18)
self.db.charisma = randint(3,18)
self.db.wisdom = randint(3,18)
def get_attributes(self):
return self.db.strength, self.db.constitution, self.db.dexterity, self.db.intelligence, self.db.charisma, self.db.wisdom
pass