A basic fighting mechanic and a few entities

This commit is contained in:
Nicolas Margulies 2020-10-16 17:58:00 +02:00
parent 6f64646a7a
commit e65a486b78
4 changed files with 29 additions and 0 deletions

View File

View File

@ -0,0 +1,5 @@
from ..interfaces import FightingEntity
class Squirrel(FightingEntity):
maxhealth = 10
strength = 3

View File

@ -0,0 +1,5 @@
from ..interfaces import FightingEntity
class Player(FightingEntity):
maxhealth = 20
strength = 5

View File

@ -40,3 +40,22 @@ class Entity:
def move(self, x: int, y: int) -> None: def move(self, x: int, y: int) -> None:
self.x = x self.x = x
self.y = y 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