33 lines
740 B
Python
33 lines
740 B
Python
|
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}]"
|