mipt-dragons/tournament.py
nihonium c674151180 new file: .gitignore
new file:   LICENSE
	new file:   README.md
	new file:   enemies.py
	new file:   gameunit.py
	new file:   hero.py
	new file:   main.py
	new file:   tournament.py

 Changes to be committed:
2021-11-15 11:58:38 +03:00

53 lines
1.9 KiB
Python
Raw Permalink 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.

# coding: utf-8
# license: GPLv3
from enemies import *
from hero import *
def annoying_input_int(message =''):
answer = None
while answer == None:
try:
answer = int(input(message))
except ValueError:
print('Вы ввели недопустимые символы')
return answer
def game_tournament(hero, dragon_list):
for dragon in dragon_list:
print('Вышел', dragon._color, 'дракон!')
while dragon.is_alive() and hero.is_alive():
print('Вопрос:', dragon.question())
answer = annoying_input_int('Ответ:')
if dragon.check_answer(answer):
hero.attack(dragon)
print('Верно! \n** дракон кричит от боли **')
else:
dragon.attack(hero)
print('Ошибка! \n** вам нанесён удар... **')
if dragon.is_alive():
break
print('Дракон', dragon._color, 'повержен!\n')
if hero.is_alive():
print('Поздравляем! Вы победили!')
print('Ваш накопленный опыт:', hero._experience)
else:
print('К сожалению, Вы проиграли...')
def start_game():
try:
print('Добро пожаловать в арифметико-ролевую игру с драконами!')
print('Представьтесь, пожалуйста: ', end = '')
hero = Hero(input())
dragon_number = 3
dragon_list = generate_dragon_list(dragon_number)
assert(len(dragon_list) == 3)
print('У Вас на пути', dragon_number, 'драконов!')
game_tournament(hero, dragon_list)
except EOFError:
print('Поток ввода закончился. Извините, принимать ответы более невозможно.')