This repository has been archived on 2022-12-03. You can view files and clone it, but cannot push or open issues or pull requests.
texty/lib/fight.py
2022-04-17 20:03:52 +02:00

22 lines
604 B
Python

import math
from .ascii import *
class FightHandler:
def __init__(self,name:str,hp:int,attacks:list,img:str="") -> None:
self.name = name
self.max = hp # starting HP
self.hp = self.max # current HP
self.attacks = attacks
self.img = img
def show(self):
p = math.trunc(self.hp/self.max*10)
h = "🟥"*p
if str(p).endswith(".5"):
h += ""
print(f"{self.name} {h} {self.hp}/{self.max}")
if self.img != "":
anim = AsciiAnimation()
anim.load_ascii(self.img)
anim.play()