forked from Leemoose/Roguelike-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
effect.py
209 lines (165 loc) · 6.31 KB
/
effect.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import dice as R
class StatusEffect():
def __init__(self, id_tag, name, message, duration):
self.id_tag = id_tag
self.name = name
self.duration = duration
self.active = True
self.message = message
self.positive = False
def apply_effect(self, target):
pass
def description(self):
if self.duration == -100:
return self.name + " (permanent)"
return self.name + " (" + str(self.duration) + ")"
def tick(self, target):
if self.duration == -100: # -100 is a special value that means the effect lasts forever, -1 probably works too but made it larger just in case
return
self.duration -= 1
if self.duration <= 0:
self.active = False
class Burn(StatusEffect):
def __init__(self, duration, damage, inflictor):
super().__init__(801, "Burn", "is Burning", duration)
self.damage = damage
self.inflictor = inflictor
def apply_effect(self, target):
pass
def tick(self, target):
if self.duration == -100: # -100 is a special value that means the effect lasts forever, -1 probably works too but made it larger just in case
return
self.duration -= 1
if self.duration <= 0:
self.active = False
else:
target.take_damage(self.inflictor, self.damage)
self.duration -= 1
def remove(self, target):
pass
class Petrify(StatusEffect):
def __init__(self, duration):
super().__init__(802, "Petrify", "is Petrified", duration)
def apply_effect(self, target):
target.movable = False
def remove(self, target):
target.movable = True
class Might(StatusEffect):
def __init__(self, duration, strength):
super().__init__(803, "Might", "feels strong", duration)
self.strength = strength
self.positive = True
def apply_effect(self, target):
target.strength += self.strength
def remove(self, target):
target.strength -= self.strength
class Weak(StatusEffect):
def __init__(self, duration, strength):
super().__init__(803, "Weak", "feels weak", duration)
self.strength = strength
self.positive = False
def apply_effect(self, target):
target.strength -= self.strength
def remove(self, target):
target.strength += self.strength
class Dumb(StatusEffect):
def __init__(self, duration, intelligence):
super().__init__(803, "Dumb", "feels dumb", duration)
self.intelligence = intelligence
self.positive = False
def apply_effect(self, target):
target.intelligence -= self.intelligence
def remove(self, target):
target.intelligence += self.intelligence
class Haste(StatusEffect):
def __init__(self, duration, dexterity):
super().__init__(804, "Dexterity", "feels fast", duration)
self.dexterity = dexterity
self.positive = True
def apply_effect(self, target):
target.dexterity += self.dexterity
def remove(self, target):
target.dexterity -= self.dexterity
class Slow(StatusEffect):
def __init__(self, duration, dexterity):
super().__init__(805, "Slow", "feels slow", duration)
self.dexterity = dexterity
def apply_effect(self, target):
target.dexterity -= self.dexterity
def remove(self, target):
target.dexterity += self.dexterity
class Escaping(StatusEffect):
def __init__(self, duration, dex_buff, str_debuff, int_debuff):
super().__init__(806, "Escaping", "is trying to escape", duration)
self.dex_buff = dex_buff
self.str_debuff = str_debuff
self.int_debuff = int_debuff
def apply_effect(self, target):
target.dexterity += self.dex_buff
target.strength -= self.str_debuff
target.intelligence -= self.int_debuff
def remove(self, target):
target.dexterity -= self.dex_buff
target.strength += self.str_debuff
target.intelligence += self.int_debuff
class Fear(StatusEffect):
def __init__(self, duration, inflictor):
super().__init__(806, "Fear", "is scared", duration)
self.inflictor = inflictor
def apply_effect(self, target):
target.flee = True
def remove(self, target):
target.flee = False
class Invincible(StatusEffect):
def __init__(self, duration, inflictor = None):
super().__init__(806, "Invincible", "can't be killed", duration)
self.positive = True
def apply_effect(self, target):
target.invincible = True
def remove(self, target):
target.invincible = False
target.health = max(1, target.health)
class Asleep(StatusEffect):
def __init__(self, duration, inflictor = None):
super().__init__(806, "Asleep", "...", duration)
def apply_effect(self, target):
actual = target.parent
actual.asleep = True
def remove(self, target):
actual = target.parent
actual.asleep = False
class Tormented(StatusEffect):
def __init__(self, duration, inflictor = None):
super().__init__(806, "Tormented", "is tormented", duration)
def apply_effect(self, target):
target.health //= 2
def remove(self, target):
pass
class ArmorShredding(StatusEffect):
def __init__(self, duration, inflictor = None):
super().__init__(806, "Shredded", "armor is shredded", duration)
self.armor_shredded = 0
def apply_effect(self, target):
target.armor -= 5
self.armor_shredded += 5
def remove(self, target):
target.armor += self.armor_shredded
self.armor_shredded = 0
class Bleed(StatusEffect):
def __init__(self, duration, damage, inflictor):
super().__init__(801, "Bleed", "is Bleeding", duration)
self.damage = damage
self.inflictor = inflictor
def apply_effect(self, target):
pass
def tick(self, target):
if self.duration == -100: # -100 is a special value that means the effect lasts forever, -1 probably works too but made it larger just in case
return
self.duration -= 1
if self.duration <= 0:
self.active = False
else:
target.take_damage(self.inflictor, self.damage)
self.duration -= 1
def remove(self, target):
pass