-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy.py
31 lines (25 loc) · 1.15 KB
/
enemy.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
from datetime import datetime, timedelta
class Enemy:
def __init__(self, max_health=5000, experience_drop=5000, name='Ghost', damage=100, damage_time=5000):
self.max_health = max_health
self.health = self.max_health
self.experience_drop = experience_drop
self.name = name
self.damage = damage
self.damage_time = damage_time # ms
self.channeling_start = datetime.now()
def delay_channeling(self, player):
self.channeling_start += timedelta(milliseconds=player.recovery_time)
if self.channeling_start > datetime.now():
self.channeling_start = datetime.now()
def process_channeling(self, player):
if self.channeling_start <= datetime.now() - timedelta(milliseconds=self.damage_time):
player.hit(self.damage)
self.channeling_start = datetime.now()
def timer(self):
return (self.channeling_start - (datetime.now() - timedelta(milliseconds=self.damage_time))).total_seconds()
def hit(self, amount, player):
self.health -= amount
if self.health < 0:
self.health = 0
self.delay_channeling(player)