import random # roll an s-sided die r times def rollDice(s,r): total = 0 for count in range(r): total += random.randint(1,s) return total # calculate damage done to hero/boss def getDamage(strength, luck, superAttack = False): damage = rollDice(4,2) if superAttack: damage *= 2 return damage # get a valid action for battle def getBattleAction(): action = input("Do you (A)ttack, use a (S)uper Attack, or attempt to (F)lee? ") while not action in ("A","F","S","a","f","s"): action = input("Not a valid option. You must (A)ttack, use a (S)uper Attack, or (F)lee: ") return action # determine who wins a battle round def playerWinsRound(skill, bossSkill): playerRoll = rollDice(6,2) + skill bossRoll = rollDice(6,2) + bossSkill if playerRoll > bossRoll: return True else: return False