txt/terra/models/weapon/abstract_weapon.py

33 lines
740 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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}]"