txt/terra/models/weapon/abstract_weapon.py

33 lines
740 B
Python
Raw Normal View History

2023-02-09 22:56:17 +00:00
from abc import ABC
import random
class AbstractWeapon(ABC):
"""
Abstract weapon
"""
name: str
damage: int
health: int
difficult_handling: int # -20 - +20
def get_hit_chance(self, weapon: "AbstractWeapon") -> bool:
hit_chance = weapon.difficult_handling * self.scale
if random.randint(1, hit_chance) >= 10:
return True
else:
return False
def punch(self, weapon: "AbstractWeapon"):
"""Punch"""
print("Вы ударили ничем, ни о что")
def show_stats(weapon: "AbstractWeapon") -> str:
health_percentage = "{0:.0f}%".format(weapon.health, 100)
return f"[D:{weapon.damage}, H:{health_percentage}]"