A basic fighting mechanic and a few entities
This commit is contained in:
parent
6f64646a7a
commit
e65a486b78
|
@ -0,0 +1,5 @@
|
||||||
|
from ..interfaces import FightingEntity
|
||||||
|
|
||||||
|
class Squirrel(FightingEntity):
|
||||||
|
maxhealth = 10
|
||||||
|
strength = 3
|
|
@ -0,0 +1,5 @@
|
||||||
|
from ..interfaces import FightingEntity
|
||||||
|
|
||||||
|
class Player(FightingEntity):
|
||||||
|
maxhealth = 20
|
||||||
|
strength = 5
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue