-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity.py
175 lines (154 loc) · 4.52 KB
/
entity.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
from utils import *
class Entity():
pass
# CLASSES FOR ENTITIES
class NPC(Entity):
def __init__(self):
Entity.__init__(self)
self.character_name = ""
self.description = ""
self.character_class = [""]
self.character_level = [0]
self.character_experience = 0
self.character_alignment = "TN"
self.character_race = [""]
self.character_gender = ""
self.combat_actions = ["MOVE","INTERACT","EVADE","ASSIST"]
# TODO - POSSIBLY add taunt in the future
self.character_attributes = {
"STR": 8,
"DEX": 8,
"CON": 8,
"INT": 8,
"WIS": 8,
"CHA": 8
}
self.character_totalHP = 10
self.character_currentHP = 10
self.character_skills = {
"athletics": 0,
"acrobatics": 0,
"endurance": 0,
"knowledge": 0,
"nature": 0,
"social": 0
}
self.character_gear = {
"ATTR": [],
"SKILL": [],
"ARMOR": [],
"TRINKET": [],
"COMBAT": []
}
self.gold = 0
self.attack_count = 1
self.action_count = 1
def getAttributeModifier(self, attribute):
return (self.character_attributes[attribute] - 10) // 2
def getArmorClass(self):
modifiers = 0
for armor in self.character_gear["ARMOR"]:
modifiers += armor.gear_modifier
if armor.gear_sub_type == "LIGHT":
modifiers += self.getAttributeModifier('DEX')
elif armor.gear_sub_type == "MEDIUM":
dex = modifiers + self.getAttributeModifier('DEX')
modifiers += dex if dex < 3 else 2
for trinket in self.character_gear["TRINKET"]:
if trinket.gear_sub_type == "AC":
modifiers += trinket.gear_modifier
return 8 + modifiers
def getInitiative(self):
modifiers = 0
# TODO = update according to the current character_gear dictionary labels; "trinkets"
for trinket in self.character_gear["TRINKET"]:
if trinket.gear_sub_type == "initiative":
modifiers += trinket.gear_modifier
return modifiers + rollSum(1, 20)
def change_attribute(self, attribute, value):
self.character_attributes[attribute] += value
def change_skill(self, skill, value):
self.character_skills[skill] += value
def change_HP(self, value):
self.character_currentHP += value
def change_XP(self, value):
self.character_experience += value
class Player(NPC):
def __init__(self):
NPC.__init__(self)
#TODO - Add armor class to handle them specificaly
class Gear(Entity):
def __init__(self):
Entity.__init__(self)
self.description = ""
self.actions = []
self.value = 0
self.gear_modifier = 0
self.gear_type = ""
self.gear_sub_type = ""
class Weapon(Gear):
def __init__(self):
super().__init__()
self.damage = ""
self.actions.append('ATTACK')
RACES = {
'human': {
'name': 'Human',
'attributes': [1, 1, 1, 1, 1, 1],
'features': 0
},
'elf': {
'name': 'Elf',
'attributes': [0, 2, 0, 1, 0, 0],
'features': 0
},
'dwarf': {
'name': 'Dwarf',
'attributes': [2, 0, 2, 0, 0, 0],
'features': 0
},
'halfling': {
'name': 'Halfling',
'attributes': [0, 2, 1, 0, 0, 0],
'features': 0
}
}
CLASSES = {
'fighter': {
'name': 'Fighter',
'features': {
"1" : ["Second Wind"],
"3" : ["Extra Attack"],
"5" : ["Extra Attack"],
"7" : [],
"9" : ["Indomitable"],
"11" : ["Extra Attack"],
"13" : [],
"15" : [],
"17" : [],
"19" : ["Extra Attack"]
},
'hitdie': '1d10',
'equipment': [
(Weapon,'shortsword',10,0,'COMBAT','MELEE','1d6'),
(Gear,'chainmail',75,6,'ARMOR','HEAVY','')
]
},
'wizard': {
'name': 'Wizard',
'features': {
"1" : ["Magic Missile","Acid Splash"],
"3" : ["Invisibility"],
"5" : ["Fireball"],
"7" : [],
"9" : [],
"11" : [],
"13" : [],
"15" : [],
"17" : [],
"19" : ["Greater Wish"]
},
'hitdie': '1d6'
}
}
# subtypes: AC, initiative