A basic fighting mechanic and a few entities
This commit is contained in:
@ -40,3 +40,22 @@ class Entity:
|
||||
def move(self, x: int, y: int) -> None:
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
class FightingEntity(Entity):
|
||||
maxhealth: int
|
||||
health: int
|
||||
strength: int
|
||||
|
||||
def __init__(self):
|
||||
self.health = self.maxhealth
|
||||
|
||||
def hit(self, opponent) -> None:
|
||||
opponent.take_damage(self, self.strength)
|
||||
|
||||
def take_damage(self, attacker, amount:int) -> None:
|
||||
self.health -= amount
|
||||
if self.health <= 0:
|
||||
self.die()
|
||||
|
||||
def die(self) -> None:
|
||||
pass
|
||||
|
Reference in New Issue
Block a user