簡単な質問です。テキストアドベンチャーゲームで本当に行き詰まっています。ユーザーが複数の単語を入力しているときにユーザー入力を検証するにはどうすればよいですか? 私は彼らがfire at chandelier
何かを書くことができるようにしたいのですが、一度に1つの単語を検証することしかできません.
print("input fire chandelier")
user = input()
if user in ("fire", "chandelier"):
print("works")
else:
print("fails")
現在、私の撮影コードは次のようになっています。1 つの単語のみを検証します。
user = input()
if user == "cover" or user == "stand" or user == "reload" or user == "fire"
or user == "wait" or user == "chandelier":
while turn >= 1:
#player shoots if fire entered shoot is greater than 1
#and player is standing
elif user == "fire" and shoot >= 1 and standing == True and chandelier < 2:
#does hit random number between 1 and 2 1 hits 2 misses
doesHit = random.randint(1, 2)
if doesHit == 1:
print("you shoot one round hitting Martin but his skin is made of metal the bullet bounces off")
#-1 ammo
shoot = shoot - 1
#check if in cover
cover = False
#counts down turn
turn = turn - 1
break
elif doesHit > 1:
print("you shoot but it misses")
turn = turn - 1
shoot = shoot - 1
break
#shoot the chandelier to damage martin
elif user in ["fire", "chandelier"] and shoot >= 1 and standing == True:
doesHit = random.randint(1, 2)
if doesHit == 1:
print("You shoot one round hitting the chandelier it hangs by one chain")
#-1 ammo
shoot = shoot - 1
#check if in cover
cover = False
#counts down turn
turn = turn - 1
chandelier = chandelier + 1
break
elif doesHit > 1:
print("you shoot but it misses")
turn = turn - 1
shoot = shoot - 1
break
#can shoot martin now chandelier has fallen
elif user == "fire" and shoot >= 1 and standing == True and chandelier >= 2:
#does hit random number between 1 and 2 1 hits 2 misses
doesHit = random.randint(1, 2)
if doesHit == 1:
print("you shoot one round hitting Martin")
#-1 ammo
shoot = shoot - 1
#check if in cover
cover = False
#counts down turn
turn = turn - 1
break
elif doesHit > 1:
print("you shoot but it misses")
turn = turn - 1
shoot = shoot - 1
break