Untitled
Never
from time import sleep import random class Hero(): def __init__(self, name, health, armor): self.name = name self.health = health self.armor = armor def print_info(self): print("Рівень здоров'я:", self.health) print("Клас броні:", self.armor) def fight(self, opponent): print(f"{self.name} атакує {opponent.name}!") damage = random.randint(1, 10) # Згенерувати випадковий пошкодження opponent.take_damage(damage) def take_damage(self, damage): if self.armor > 0: # Перевірити, чи є броня damage -= self.armor # Зменшити пошкодження на броню if damage < 0: # Перевірити, чи пошкодження було відхилене бронею damage = 0 self.health -= damage print(f"{self.name} отримує {damage} пошкодження.") def is_alive(self): return self.health > 0 class Warrior(Hero): def __init__(self, name, health, armor, ecip): super().__init__(name, health, armor) self.ecip = ecip def fight(self, opponent): print(f"Воїн {self.name} атакує {opponent.name} зі своєю {self.ecip}!") damage = random.randint(5, 15) # Вибір випадкового пошкодження для воїна opponent.take_damage(damage) class Archer(Hero): def __init__(self, name, health, armor, bag): super().__init__(name, health, armor) self.bag = bag def fight(self, opponent): print(f"Лучник {self.name} випускає стрілу на {opponent.name} зі своєї {self.bag}!") damage = random.randint(3, 12) # Вибір випадкового пошкодження для лучника opponent.take_damage(damage) def battle(hero1, hero2): while hero1.is_alive() and hero2.is_alive(): # Проводимо похід героїв hero1.fight(hero2) if not hero2.is_alive(): print(f"{hero1.name} переміг!") break hero2.fight(hero1) if not hero1.is_alive(): print(f"{hero2.name} переміг!") break # Створити героїв warrior = Warrior("Edward", 100, 10, "меч") archer = Archer("Archer", 80, 5, "лук") # Початок бою battle(warrior, archer)
Raw Text
-
https://www.facebook.com/2ndLifeKetoACVGummiesFacts/
20 min ago
-
Mozz Guard 2024
25 min ago
-
Untitled
28 min ago
-
Untitled
31 min ago
-
Quick Books Customer Service
35 min ago
-
Untitled
43 min ago
-
24 Hour Cash Buyers
43 min ago
-
Untitled
58 min ago
-
Untitled
1 hour ago
-
🔥😈NEW UPDATED CP FOLDERS😈🔥//02/05/24
3 hours ago