def DaggerAttack(user, target, charList): dexMod = math.floor((charList[user]['Stats'][1] - 10) / 2) attackRoll = universal_functions.rollDice(1, 20, 1, 1, False) + dexMod print("You attacked with your dagger") print("You rolled " + str(attackRoll) + " to hit") if attackRoll - dexMod == 20: damage = 2 * (universal_functions.rollDice(1, 4, 1, 1, False)) + dexMod print("You rolled a critical and dealt: " + str(damage) + " damage") elif attackRoll >= charList[target]['AC']: damage = universal_functions.rollDice(1, 4, 1, 1, False) + dexMod print("You hit and dealt: " + str(damage) + " damage") else: damage = 0 print("You missed") return ([target, -damage])
def FireBolt(user, target, charList): intMod = math.floor((charList[user]['Stats'][3] - 10) / 2) attackRoll = universal_functions.rollDice(1, 20, 1, 1, False) + intMod print("You used firebolt") print("You rolled " + str(attackRoll) + " to hit") if attackRoll - intMod == 20: damage = 2 * (universal_functions.rollDice(1, 10, 1, 1, False)) + intMod print("You rolled a critical and dealt: " + str(damage) + " damage") elif attackRoll >= charList[target]['AC']: damage = universal_functions.rollDice(1, 10, 1, 1, False) + intMod print("You hit and dealt: " + str(damage) + " damage") else: damage = 0 print("You missed") return ([target, -damage])
def opaf(user, target, charList): modifyer = math.floor((charList[user]['Stats'][0] - 10) / 2) attackRoll = universal_functions.rollDice(1, 20, 1, 1, False) + modifyer print(charList[user]['Name'] + ' used opaf') print(charList[user]['Name'] + ' rolled a ' + str(attackRoll) + ' to hit') if attackRoll - modifyer == 20: damage = 2 * (universal_functions.rollDice(1, 20, 10, 10, False)) + modifyer print(charList[user]['Name'] + ' rolled a critical and dealt: ' + str(damage) + ' damage') elif attackRoll >= charList[target]['AC']: damage = universal_functions.rollDice(1, 20, 10, 10, False) + modifyer print(charList[user]['Name'] + ' hit and dealt: ' + str(damage) + ' damage') else: damage = 0 print(charList[user]['Name'] + ' missed') return ([target, -damage])
def RunProgram(): print("When rolling the format is: '[rolls]d[sides]<k[numDiceToKeep]><+/-[modifyers]><i(if the roller should show the individual rolls)>'") rolling = True while(rolling): numDice = "" roll = "" adition = "" dice = "" keep = "" roll = input("What dice-roll do you want to make: ").lower() try: numDice,roll = roll.split("d") individual = False if "i" in roll: individual = True roll = roll.split("i")[0] if "+" in roll: roll,adition = roll.split("+") elif "-" in roll: roll,adition = roll.split("-") adition = "-" + adition else: adition = "0" if "k" in roll: dice,keep = roll.split("k") else: keep = numDice dice = roll numDice = int(numDice) adition = int(adition) dice = int(dice) keep = int(keep) total = universal_functions.rollDice(1,dice,numDice,keep, individual) if individual: sum = 0 for i in range(len(total)): print("For roll nr. " + str(i+1) + " you rolled a: " + str(total[i])) sum += total[i] print("You rolled a total of: " + str(sum+adition)) else: print("You rolled a total of: " + str(total+adition)) except ValueError: print("Your input was not a valid string") keepRolling = input("Do you want to keep rolling (y/n)? ").lower() if keepRolling not in ["y","yes","true","","t"]: rolling = False
def SmallHealthPot(user, target, charList): healing = universal_functions.rollDice(1, 4, 2, 2, False) + 2 print("You used a health pot and healed " + str(healing) + " health") return ([user, healing])