Так что я пытаюсь прокомментировать базовый текстовый бой, подумайте, но он не позволяет мне вызвать мою функцию, это мой код.NameError, function not defined
import random
import math
import sys
# Variables
health = 100
goblin_health = 100
# Intro
def game_start():
print('As you are walking down the street, you see a goblin!')
print('He draws his sword and dashes towards you!')
# Fight Sequence
def fight_start():
while True:
print('Would you like to:\n1. Run\n2. Attack\n3. Block')
action = input()
if action == 1:
print('You tried to run away like the coward you are, but there is no where to run.')
goblindamage = random.randint(1, 9)
health = health - goblin_damage
print('You took ' + str(goblin_damage) + ' damage. You now have ' + str(health) + ' health left.')
continue
elif action == 2:
damage = random.randint(10, 20)
goblin_health = goblin_health - damage
print('You attack the goblin for ' + str(damage) + ' damage. It has ' + str(goblin_health) + ' health left.')
continue
elif action == 3:
block = random.randint(60, 90)
goblin_damage = random.randint(1, 9)
health = health - goblin_damage/block
print('You blocked ' + str(block) + ' percent of the damage delt, you took ' + str(goblin_damage) + ' damage and have ' + str(health) + ' health left.')
continue
elif goblin_health <= 0:
print('You killed the goblin! Congradulations, you win!')
break
elif health <= 0:
print('You died! Restarting...')
fight_start()
game_start()
print('It is time to fight! You draw your sword.')
fight_start()
Моя ошибка говорит: Traceback (самый последний вызов последнего): Файл "AdventureLibs.py", строка 46, в fight_start() NameError: имя 'fight_start' не определен
Я не мог найти исправление в Интернете, которое сработало, может кто-нибудь мне помочь?
'fight_start' имеет отступы внутри' game_start', поэтому он не определен в глобальной области –