-3
私は基本的なテキストベースの戦闘を考えようとしていますが、私の関数を呼び出すことはできません。これは私のコードです。NameError、関数が定義されていません
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()
私のエラーは言う: トレースバック(最新の呼び出しの最後): ファイル "AdventureLibs.py"、ライン46を、 fight_startに() NameError:名 'fight_start' が定義されていません
オンラインで修正プログラムが見つからない、誰かが私を助けることができますか?
'fight_start'は' game_start'内でインデントされているので、グローバルスコープでは定義されていません –