A basic fighting mechanic and a few entities

This commit is contained in:
Nicolas Margulies 2020-10-16 17:58:00 +02:00
parent f3e42ae295
commit 63660707d1
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

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