samedi 11 mai 2019

Why doesn't the "if statement" with numbers in the if statement not working and not running and just stopping after the statement in python 3.7.2?

I am trying to make a python script to make random dice plus numbers and a random dice that can increase the amount of dice rolled. Think D&D 5e.

I have tried changing variables but it seems that no matter what I try it is all around the if statement that is causing the problem.

    rolls = 2
    critrolls = 4
    FDMG = 6
    DMG = 0
    Tohit = random.randrange(12, 32)
            if Tohit == "31":
                while str(critrolls) > str(0):
                    DMG = random.randrange(1, 9)
                    FDMG = FDMG + DMG
                    rolls = int(critrolls) - 1
                print("Your to hit is", Tohit)
                print("Your Damage is", FDMG)
            elif Tohit <= 30:
                while str(rolls) > str(0):
                    DMG = random.randrange(1, 9)
                    FDMG = FDMG + DMG
                    rolls = int(rolls) - 1
                print("Your to hit is", Tohit)
                print("Your Damage is", FDMG)

I want it to be able to based on the number from the Tohit variable to control the amount of dice rolled. The idea of this is on a 31 roll it will roll 4 dice instead of 2.

Aucun commentaire:

Enregistrer un commentaire