1
0
python-roguelike/components/fighter.py

18 lines
417 B
Python
Raw Normal View History

2022-01-07 16:39:37 -05:00
from components.base_component import BaseComponent
class Fighter(BaseComponent):
def __init__(self, hp: int, defense: int, power: int):
self.max_hp = hp
self._hp = hp
self.defense = defense
self.power = power
@property
def hp(self) -> int:
return self._hp
@hp.setter
def hp(self, value: int) -> None:
self._hp = max(0, min(value, self.max_hp))