小编The*_*nac的帖子

我有一个游戏循环,由于某种原因无法运作

我在制作这个循环工作时遇到了麻烦,任何帮助/建议都会非常感激.

这是循环(它不是完整的程序):

import random

while your_health or enemy_health >= 10:
    print("He is still attacking you.")
    print("you may either:"
          "a-dodge"
          "b-attack back")
    fight_choice_1_1 = input("What do you do?")

    if fight_choice_1_1 == "a":
        d20_1_1 = random.randint(1, 20)
        if d20_1_1 >= 10:
            print("you dodge the attack")
        elif d20_1_1 <= 10:
            your_health -= knife_damage
            print("you get hit")
            if your_health <= 0:
                print("you lose. :(")
            elif enemy_health <= 0:
                print("you win!")

    if fight_choice_1_1 == "b":
        d20_1_1 = random.randint(1, 20)
        if d20_1_1 >= 10:
            print("you get …
Run Code Online (Sandbox Code Playgroud)

python loops while-loop

1
推荐指数
1
解决办法
150
查看次数

标签 统计

loops ×1

python ×1

while-loop ×1