Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么我的战斗停止了,却没有';t转到move()命令:/_Python_Random - Fatal编程技术网

Python 为什么我的战斗停止了,却没有';t转到move()命令:/

Python 为什么我的战斗停止了,却没有';t转到move()命令:/,python,random,Python,Random,在我的代码的某些部分,它只是停止,不返回move()。我希望它添加分数,我使用score=score+100来添加分数,但它只是破坏了代码;-;。这有点乱,对此我很抱歉,但请帮助我,我不知道它为什么会这样。仅供参考,如果有帮助的话,我将在pythonroom上使用此代码 import random weapon = "Wooden Sword" Damage0 = 1 Damage1 = 8 Speed = 6 lives = 5 score = 0 gold = 80 armor = "No

在我的代码的某些部分,它只是停止,不返回move()。我希望它添加分数,我使用score=score+100来添加分数,但它只是破坏了代码;-;。这有点乱,对此我很抱歉,但请帮助我,我不知道它为什么会这样。仅供参考,如果有帮助的话,我将在pythonroom上使用此代码

import random
weapon = "Wooden Sword"
Damage0 = 1
Damage1 = 8
Speed = 6
lives = 5 
score = 0
gold = 80
armor = "Nothing"
health = 20

def please():
    name = input("Please put a name and not nothing.")
    if name == "":
        please1(name)
    else:
        yon(name)

def please1(name):
    name = input("Please put a name and not nothing.")
        if name == "":
        please1(name)
    else:
        yon1(name)

def yon(name):
    print("So your name is " + name + "?")
    yon = input("Is this your name? ''" + name + "'' [Yes] or [No]?")
    if yon == "Yes":
        begining()
    elif yon == "yes":
        begining()
    else:
        sorry(name)

def yon1(name):
    yon = input("Is this your +name? ''" + name + "'' [Yes] or [No]?")
    if yon == "Yes":
        begining()
    elif yon == "yes":
        begining()
    else:
        sorry1(name)

def sorry(name):
    print("                                                ")
    print("I'm sorry, so what is your name?")
    print("                                                ")
    name = input("What is you name?")
    if name != "":
        yon(name)
else:
    please1(name)

def sorry1(name):
    name = input("What is you name?")
    if name != "":
        yon1(name)
    else:
        please1(name)

def move(): 
    Next = input("Will you go and fight a monster or check stats or quit the             game? [Fight] [Stats] [Travel] [Quit]")
    Next = Next.lower()
    if "tat" in Next:
        Stats()
    elif "ight" in Next:
        Fight()
    elif "ravel" in Next:
        travel()
    elif "uit" in Next:
        print("As you quit the game your character disapears...")
    else:
        move()

def Fight():
your_speed = Speed
enemy_speed = 2
if enemy_speed >= your_speed:
    print("The " + enemy + " is faster, it goes first!")
    enemy_first()
else:
    print("You're faster and get to go first!")
    your_first()

def end(enemy_health,your_health):
    if your_health > 0:
        print("  ")
        print("You defeat the Ork")
        score = score + 100
        gold = gold + 50 'it stops here and won't continue why?
        print(gold)
        print(score)
        move()
    else:
        print("The ork beat you!")
        move()

def your_first():   
    enemy_health = 20
    your_health = health
    while your_health > 0 and enemy_health > 0:
        your_damage = random.choice(range(Damage0, Damage1))
        enemy_health -= your_damage
    if enemy_health <= 0:
        enemy_health = 0
        print(" ")
        print("You dealt " + str(your_damage) + " damage!")
        print("Enemy's health:" + str(enemy_health))
        end(enemy_health,your_health)
    else:
        print(" ")
        print("You dealt " + str(your_damage) + " damage!")
        print("Enemy's health:" + str(enemy_health))
        enemy_damage = random.choice(range(3, 12))
        your_health -= enemy_damage
        if your_health <= 0:
            your_health = 0
            print("  ")
            print("Ork dealt " + str(enemy_damage) + " damage!")
            print("Your health:" + str(your_health))
            end(enemy_health,your_health)
        else:
            print("  ")
            print("Ork dealt " + str(enemy_damage) + " damage!")
            print("Your health:" + str(your_health))

def enemy_first():  
    enemy_health = 20
    your_health = health
    while your_health > 0 and enemy_health > 0:
        enemy_damage = random.choice(range(3, 12))
        your_health -= enemy_damage
        if your_health <= 0:
            your_health = 0
            print("  ")
            print("Ork dealt " + str(enemy_damage) + " damage!")
            print("Your health:" + str(your_health))
            end(enemy_health,your_health)
        else:
            print(" ")
            print("Ork dealt " + str(enemy_damage) + " damage!")
            print("Your health:" + str(your_health))
            your_damage = random.choice(range(Damage0, Damage1))
            enemy_health -= your_damage
            if enemy_health <= 0: 
                print(" ")
                print("You dealt " + str(your_damage) + " damage!")
                print("Enemy's health:" + str(enemy_health))
                end(enemy_health,your_health)
            else:
                print("  ")
                print("You dealt " + str(your_damage) + " damage!")
                print("Enemy's health:" + str(enemy_health))

def Stats():
    if weapon == "Wooden Sword":
        Damage = 1, 8
        Damage0 = 1
        Damage1 = 8
        Speed  = 6
    if weapon == "Rusty Sword":
        Damage = 13, 17
        Damage0 = 13
        Damage1 = 17
        Speed  = 4
    if weapon == "Bow":
        Damage = 2, 13
        Damage0 = 2
        Damage1 = 13
        Speed  = 10
    if weapon == "Bronze Sword":
        Damage = 18, 24
        Damage0 = 18
        Damage1 = 24
        Speed  = 1
    if weapon == "Magic Spell":
        Damage = 25, 33
        Damage0 = 25
        Damage1 = 33
        Speed = 10
    if armor == "Nothing":
        health = 20

    print("  ")
    print("  ")
    print("(+)~~~~~~~~~~~~~~~~~~~~~~")
    print(" |   Your    | Health:   ")
    print(" |   Stats   | " + str(health) + "          ") 
    print(" |----------------------- ")
    print(" | Weapon Stats:          ")
    print(" | Damage:       "+str(Damage)+"  ")
    print(" | Speed:             "+str(Speed)+"  ")
    print("(+)~~~~~~~~~~~~~~~~~~~~~~")
    print("  Your Score:"+ str(score) +"   ")
    print("  ")
    print("  ")
    move()

def begining():
    print("  ")
    print("Welcome to the nexus!")
    print("It is the center of this world.")
    print("It is also called the hub.")
    print("During the game you can gather items and get xp")
    print("At the end of the game you can see your score based")
    print("on how well you did and how many items you found!")
    move()

def travel():
    travel = input("Where will you travel to? [Cave] [Market] [Boss]")
    if "ve" in travel:
        cave()
    elif "et" in travel:
        market()
    elif "ss" in travel:
        Boss_fight()
    else:
        move()

def cave():
    print("pie")

def market():
    print("pie")

def Boss_fight():
    your_speed = Speed
    enemy_speed = 2
    if enemy_speed >= your_speed:
        print("The " + enemy + " is faster, it goes first!")
        Boss_Boss_first
    else:
        print("You're faster and get to go first!")
        Boss_Your_First()

def Boss_end(enemy_health,your_health):
    if your_health > 0:
        print("  ")
        print("You defeat The Boss")
        score = score + 2000
        move()
    else:
        print("  ")
        if lives == 3 or lives == 2 or lives == 1:
            print("The Boss beats you!")
            lives = lives - 1
            print("You have " + str(lives) + " left")
            move()
        else:
            start= input("Restart or Quit?")
            if "start" in start or "try" in start:
                reset(xp,lvl,weapon)
            else:
                print("  ")


def Boss_Your_First():  
    enemy_health = 50
    your_health = health
    while your_health > 0 and enemy_health > 0:
    your_damage = random.choice(range(Damage0, Damage1))
    enemy_health -= your_damage
    if enemy_health <= 0:
        enemy_health = 0
        print(" ")
        print("You dealt " + str(your_damage) + " damage!")
        print("The Boss's health:" + str(enemy_health))
        Boss_end(enemy_health,your_health)
    else:
        print(" ")
        print("You dealt " + str(your_damage) + " damage!")
        print("The Boss's health:" + str(enemy_health))
        enemy_damage = random.choice(range(15, 19))
        your_health -= enemy_damage
        if your_health <= 0:
            your_health = 0
            print("  ")
            print("The Boss dealt " + str(enemy_damage) + " damage!")
            print("Your health:" + str(your_health))
            Boss_end(enemy_health,your_health)
        else:
            print("  ")
            print("The Boss dealt " + str(enemy_damage) + " damage!")
            print("Your health:" + str(your_health))

def Boss_Boss_first():  
    enemy_health = 50
    your_health = health 
    while your_health > 0 and enemy_health > 0:
        enemy_damage = random.choice(range(15, 19))
        your_health -= enemy_damage
        if your_health <= 0:
            your_health = 0
            print("  ")
            print("The Boss dealt " + str(enemy_damage) + " damage!")
            print("Your health:" + str(your_health))
            Boss_end(enemy_health,your_health)
        else:
            print(" ")
            print("The Boss dealt " + str(enemy_damage) + " damage!")
            print("Your health:" + str(your_health))
            your_damage = random.choice(range(Damage0, Damage1))
            enemy_health -= your_damage
            if enemy_health <= 0: 
                print(" ")
                print("You dealt " + str(your_damage) + " damage!")
                print("The Boss's health:" + str(enemy_health))
                Boss_end(enemy_health,your_health)
            else:
                print("  ")
                print("You dealt " + str(your_damage) + " damage!")
                print("The Boss's health:" + str(enemy_health))
print("                                                ")
print("Hello. What is your name?")
print("                                                ")
name = input("What is you name?")
if name == "":
    please()
else:
    yon(name)
随机导入
武器=“木剑”
损伤0=1
损伤1=8
速度=6
寿命=5
分数=0
黄金=80
装甲=“什么都没有”
健康=20
def please():
name=输入(“请输入一个名称,而不是什么都没有。”)
如果名称==“”:
请1(姓名)
其他:
杨(姓名)
def请1(姓名):
name=输入(“请输入一个名称,而不是什么都没有。”)
如果名称==“”:
请1(姓名)
其他:
yon1(姓名)
杨德辉(姓名):
打印(“所以你的名字是“+name+”?”)
yon=input(“这是你的名字吗?”+名字+”[是]还是[否]?)
如果yon==“是”:
开始
elif yon==“是”:
开始
其他:
对不起(姓名)
def yon1(姓名):
yon=input(“这是你的+姓名吗?“”+姓名+“”[是]还是[否]?”)
如果yon==“是”:
开始
elif yon==“是”:
开始
其他:
sorry1(姓名)
对不起(姓名):
打印(“”)
打印(“对不起,你叫什么名字?”)
打印(“”)
name=输入(“你叫什么名字?”)
如果名称!="":
杨(姓名)
其他:
请1(姓名)
def sorry1(名称):
name=输入(“你叫什么名字?”)
如果名称!="":
yon1(姓名)
其他:
请1(姓名)
def move():
下一步=输入(“你会去和怪物战斗还是检查统计数据或退出游戏?[战斗][统计数据][旅行][退出]”)
Next=Next.lower()
如果在下一步中出现“tat”:
统计数据()
下一页中的elif“ight”:
打架
下一页中的elif“ravel”:
旅行()
下一页中的elif“uit”:
打印(“当你退出游戏时,你的角色消失了…”)
其他:
移动()
定义战斗():
你的速度=速度
敌方速度=2
如果敌人速度>=你的速度:
打印(“敌人+”更快,它先走!”)
首先是敌人
其他:
打印(“您更快,可以先走!”)
你的第一个
def end(敌人生命值,你的生命值):
如果您的健康状况>0:
打印(“”)
打印(“你击败了对手”)
分数=分数+100
黄金=黄金+50'它停在这里,不会继续为什么?
印刷品(金色)
打印(分数)
移动()
其他:
打印(“工作打败了你!”)
移动()
首先定义您的_()
敌人的健康=20
你的健康=健康
当你的生命值>0而敌人的生命值>0时:
你的伤害=随机选择(范围(伤害0,伤害1))
敌人生命-=你的伤害
如果敌人的生命值为0:
敌人的伤害=随机选择(射程(3,12))
你的生命-=敌人的伤害
如果您的健康状况为0:
打印(“”)
打印(“你打败了老板”)
分数=分数+2000
移动()
其他:
打印(“”)
如果寿命=3或寿命=2或寿命=1:
打印(“老板打了你!”)
生命=生命-1
打印(“你有”+str(生命)+“左”)
移动()
其他:
开始=输入(“重新启动或退出?”)
如果“开始”中的“开始”或“开始”中的“尝试”:
重置(xp、lvl、武器)
其他:
打印(“”)
def Boss_Your_First():
敌人的生命=50
你的健康=健康
当你的生命值>0而敌人的生命值>0时:
你的伤害=随机选择(范围(伤害0,伤害1))
敌人生命-=你的伤害
如果敌人的生命值为0:
敌人的伤害=随机选择(射程(15,19))
你的生命-=敌人的伤害

如果您的健康状况您试图在函数
end
中分配全局变量
score
,如下所示:

val = 5

def func():
    val += 5
它将不起作用,并将导致
取消绑定LocalError
。要解决此问题,只需使用关键字:


你能产生一个StActTrack吗?我经常建议更多的信息技术标题,在这种情况下,请不要改变它,因为这个问题使我的天。如果回答了你的问题,请考虑接受答案。
val = 5

def func():
    global val
    val += 5