-
Notifications
You must be signed in to change notification settings - Fork 0
/
Character.py
67 lines (63 loc) · 2.59 KB
/
Character.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
class Character:
def __init__(self, name, id, relationships, companions, consumables, equipments, equipments_in_use, background,
personality, race, gender, status="Normal"):
self.name = name
self.id = id
self.relationships = relationships
self.companions = companions
self.consumables = consumables
self.equipments = equipments
self.equipments_in_use = equipments_in_use
self.background = background
self.personality = personality
self.race = race
# "male" for male , "female" for female, "none" for None
self.gender = gender
self.status = status
self.description = None
self.changed = False
def describe(self):
if (not self.changed) and (self.description is not None):
return self.description
summary = """
Information about {}
gender: {}
race: {}
personality: {}
background: {}
equipments_in_use: {}
companions: {}
relationships: {}
status: {}
""".format(self.name, self.gender, self.race, self.personality, self.background
, [self.equipments_in_use[key] for key in self.equipments_in_use], self.companions,
self.relationships, self.status)
return summary
def to_dict(self):
character_dict = {
"race": self.race,
"name": self.name,
"gender": self.gender,
"personality": self.personality,
"status": self.status,
"relationships": self.relationships,
"companions": self.companions,
"consumables": self.consumables,
"equipments": self.equipments,
"equipments_in_use": self.equipments_in_use,
"background": self.background
}
return character_dict
def describe_relationship(self, target_character):
target_name = target_character.name
to_target_relationship = self.relationships.get(target_name)
if to_target_relationship is None:
self.relationships[target_name] = "first encounter"
from_target_relationship = target_character.relationships.get(self.name)
if from_target_relationship is None:
target_character.relationships[self.name] = "first encounter"
description = "\nRelationship:" \
"\nFrom {} to {}: {}" \
"\nFrom {} to {}: {}".format(self.name, target_name, self.relationships[target_name],
target_name, self.name, target_character.relationships[self.name])
return description