私はコードのアンダーラインをテストし、テキストベースのゲームを作成する方法を学ぼうとしています。これは、私の攻撃フェーズのテキスト断片です。現在、私は36行目にデバッグしています。これは、menu = input( ">>>")がインデントされるべきであるというエラーが表示されます。なぜ私はそのエラーを受け取っているのですか?攻撃ベースのテキストベースのRPG
#-*-coding:utf8;-*-
#qpy:3
#qpy:console
#basic attack for an rpg text based game
from random import randint
#dice function
def die(sides):
return (randint(1, sides))
# the two object fighting created as lists, later to be used as classes
human = [2, 25, 5]
monster = [1, 20, 2]
#setting the input bar
menu = 0
#attack and defence phase for the game
def attackphase():
while menu != 2:
menu == 0
x = (human[0] + die(20)) - monster[2] #calulations for damage
y = (monster[0] + die(20)) - human[2]
print("You dealt", x, "to the monster")
monster[1] -= x
if monster[1] > 0: #monster returns attack
print("Monster dealt", y, "to you.")
human[1] -= y
else:
print("You killed the monster")
print("Congrats your game works")
menu == 2
if human[1] <= 0: #to end game state
menu == 2
#game state
while menu!= 2:
print("What would you like to do")
print('''1. Attack
2. Quit''')
menu = input(">>>")
if menu == 1:
attackphase()
else:
print("sorry, that has not yet been programed")
print("Wooot, Wooot, Wooot!!!!!!!!!!")
初期問題が解決した、私は私が1、2、または任意の他のキーストロークを入力して天気を現在のゲームは、まだプログラムされていない申し訳ありませんelse文にループしている、アドバイスに合わせてコードをパッチを適用しました。
python2とpython3の両方を使用して多数のエラーが発生しますが、インデントはそれらの1つではありません。 – itdoesntwork