75 lines
2.6 KiB
Python
75 lines
2.6 KiB
Python
from dataclasses import dataclass
|
|
from materials.abstract_material import AbstractMaterial
|
|
from models.weapon.abstract_weapon import AbstractWeapon
|
|
from models.user_body.hand import Hand
|
|
|
|
from text.comments import print_irony
|
|
|
|
|
|
@dataclass
|
|
class Item:
|
|
name: type[str] = "Обьект"
|
|
description: type[str] = "Обьект как обьект, че бубнить то?"
|
|
|
|
rares: type[dict] = None
|
|
material: type[AbstractMaterial] = AbstractMaterial # Материал обьекта
|
|
health: type[int] = 1 # Здоровье: базовое значение * material.health_multiplier
|
|
scale: type[int] = 1 # Размер: от 1 до 100
|
|
|
|
def show_stats(self) -> str:
|
|
health_percentage = "{0:.0f}%".format(100 * self.health / 100)
|
|
|
|
return f"[H:{health_percentage}]"
|
|
|
|
def look(self) -> None:
|
|
|
|
if self.scale <= 5:
|
|
scale_description = "Крохотное размером"
|
|
elif self.scale <= 15:
|
|
scale_description = "Уместится на ладони."
|
|
elif self.scale >= 100:
|
|
scale_description = "Огромное по размеру"
|
|
|
|
print(f"Вы рассматриваете обьект {self.name}. {self.description}.")
|
|
print(scale_description, end="")
|
|
print(
|
|
f". Явно сделана из {self.material.name}. Кажется вам {self.material.description.lower()}",
|
|
end="",
|
|
)
|
|
|
|
if self.rares is not None:
|
|
for rare in self.rares:
|
|
print(",", rare.adjective.lower(), end="")
|
|
print(".")
|
|
|
|
def take(self, success: type[bool] = True):
|
|
if success:
|
|
print(f"Вы положили {self.name} в инвентарь.")
|
|
else:
|
|
print(f"Предмет: '{self.name}' нельзя взять.")
|
|
|
|
def touch(self):
|
|
print(f"Вы дотронулись до {self.name}" + ".")
|
|
self.material.touch(self)
|
|
|
|
def leak(self, irony: type[bool] = True) -> None:
|
|
print(
|
|
f"Вы лизнули {self.name}, но зачем? По ощущениям",
|
|
self.material.description.lower() + ".",
|
|
)
|
|
self.material.leak(self)
|
|
|
|
if irony:
|
|
print_irony()
|
|
|
|
def punch(self, weapon: type[AbstractWeapon] = Hand):
|
|
print(
|
|
f"Вы ударили {self.name + self.show_stats()}, оружием {weapon.name + weapon.show_stats(weapon)}"
|
|
)
|
|
|
|
weapon.punch(self, weapon=weapon)
|
|
|
|
def iron(self):
|
|
print(f"Вы гладите {self.name}, вроде не мяукает.")
|
|
self.material.touch(self)
|