import math
import time
import random
# Дополнительные переменные
entities = ["Манекен 100 0 0", "Зомби 20 2 1", "Скелет 12 4 0"]
hp_player = 20
max_hp_player = hp_player
damage_player = 1
armor_player = 0
# Функции
def start_fight():
random_entity = random.choice(entities)
entity_data = random_entity.split()
name_entity = entity_data[0]
hp_entity = int(entity_data[1])
max_hp_entity = hp_entity
damage_entity = int(entity_data[2])
armor_entity = int(entity_data[3])
potions_amount = 3
print(f"""
Битва началась:
Статистика {name_entity}:
Здоровье {hp_entity}
Урон {damage_entity}
Защита {armor_entity}.
Статистика {name_player}:
Здоровье {hp_player}
Урон {damage_player}
Защита {armor_player}.
""")
while hp_player > 0 and hp_entity > 0:
choice_action()
time.sleep(3)
attack_entity()
attack_player()
def attack_entity():
damage = random.randint(0, damage_entity)
damage -= armor_player
print(f"Ваш враг атакует вас и наносит {damage} урона.")
hp_entity -= damage
time.sleep(2)
def attack_player():
damage = random.randint(0, damage_player)
damage -= armor_entity
print(f"Вы атакуете врага и наносите {damage} урона.")
hp_player -= damage
time.sleep(2)
def heal_player():
if potions_amount > 0:
hp_player += max_hp_player // 10
print(f"Вы исцелились на {max_hp_player // 10} здоровья.")
potions_amount -= 1
else:
print("У вас не осталось зелий исцеления.")
def choice_action():
choice_player = input("Выберите ход:\n1. Атаковать\n2. Исцелиться.\n")
if choice_player == '1':
attack_player()
elif choice_player == '2':
heal_player()
def play():
play = input("Вы готовы начать игру? (д/н)\n")
if play == 'д':
start_fight()
elif play == 'н':
play_correctly = input("Уверены? (д/н)\n")
if play_correctly == 'д':
exit()
elif play_correctly == 'н':
play()
name_player = input("Введите ваш никнейм: ")
play()