lundi 12 juillet 2021

Exception has occurred: TypeError unsupported operand type(s) for -: 'int' and 'list'

Trying to make a Basic Text Dungeon Game and was struck with the following error:

"Exception has occurred: TypeError unsupported operand type(s) for -: 'int' and 'list'"

The following error is from this line: MonsterHealth = Monster_One_Health - Move_Chooser

import random, math, sys, os, os.path, time

#These Variables are for the Player's Move DMG
Slash = 3.1
Dash = 2.5
Slam = 5

vars = [Slash,Dash,Slam]

Move_Chooser = random.sample(vars, 1)

MonsterHealth = Monster_One_Health - Move_Chooser

    if vars == 2.5:
        print("Player Has Used Dash Attack")
        print("Monster[1] has taken 2.5 Hearts of DMG")
        time.sleep(2)
        print(MonsterHealth)

    elif vars == 3.1:
        print("Player has used Slash Attack")
        print("Monster[1] has taken 3.1 Hearts of DMG")
        time.sleep(2)
        print(MonsterHealth)
    
    elif vars == 5:
        print("Player has used Slam Attack")
        print("Monster[1] has taken 5 Hearts of DMG")
        time.sleep(2)
        print(MonsterHealth)



Aucun commentaire:

Enregistrer un commentaire