-2

私のコードは、私が作成しようとしているゲーム用のものですが、コードの下部で継続的にエラーが発生します。ここにコードのコピーを残しました。助けていただけますか? エラーは 55 行目 [display.scroll ("You were slain...")] にあります。

from microbit import* 
import random
Character = []
Enemy = []
def RollDice():
    Diceroll1 = random.randint(1,6)
    Diceroll2 = random.randint(1,6)
    Total = Diceroll1 + Diceroll2
    return Total
def NewCharacter():
    Health = 100
    Strength = random.randint(30,80)
    Defence = random.randint(20,60)
    Character.append(Health)
    Character.append(Strength)
    Character.append(Defence)
    #display.scroll("You have 100 health, your strength is" + str(Strength) + " and you have" + str(Defence) + "defence.")
def NewEnemy():
    sleep(1000)
    MonsterTypes = ["Basilisk","Banshee","Behemoth"]
    Names = ["Ben","Bethany","Bobby", "Bella"]
    Enemy = []
    n1 = (random.choice(Names))
    n2 = (random.choice(MonsterTypes))
    Enemy.append(n1+ " the " +n2)
    Enemy.append(random.randint(30,70))
    Enemy.append(random.randint(35,70))
    Enemy.append(random.randint(25,70))
    return Enemy
def fight():
    Character = NewCharacter()
    while int(Character[0])>0:
        Enemy = NewEnemy()
        display.scroll (str(Enemy[0]) + "is here to fight!")
        while int(Enemy[1]>0) and int(Character[0])>0:
            display.scroll("A(Attack) or B(Block)")
            if button_a.is_pressed():
                Total = RollDice() + int(Character[1]) - int(Enemy[3])
                if Total < 1:
                    Total = 1
                Enemy[1] -= Total
                if int(Enemy[1]) < 0:
                    Enemy[1] = 0
                display.scroll (str(Enemy[0]) + "'s health is" + str(Enemy[1]) + ".")
                if int(Enemy[1]) < 1:
                    display.scroll ("You have slain" + str(Enemy[0]) + "!")
                else:
                    display.scroll (str(Enemy[0]) + "is attacking you!")
                    Total = RollDice() + int(Enemy[2]) - int(Character[2])
                    Character[0] -= Total
                    if int(Character[0]) < 0:
                        Character[0] = 0
                    display.scroll ("Your health is" + str(Character[0]) + ".")
                    if int(Character[0]) < 1:
                        display.scroll ("You were slain...")                       
fight()
4

1 に答える 1