{}
See how a CS professor is using our compiler for class assignment.
Try Programiz PRO for Educators!
Learn DSA with step-by-step code visualization.
Try Programiz PRO for Educators!
run-icon
main.py
import random # ----------------------- Variable Declarations--------------------- userInput = "x" dex = 5 prof = 3 # ----------------------- Dice Rolls---------------------------- def d20(): d20 = random.randint(1,20) if d20 == 20: print("Nat 20!!!") return d20 def d8(): d8 = random.randint(1,8) return d8 # ---------------------- Program Functions--------------------------- # ---------------------- User Input Validations START--------------------------- def validAB(): global userInput while True: userInput = input("A or B: ") if userInput == "A" or "a" or "B" or "b": break else: userInput = input ("Unreadable input. Please enter A or B: ") break def validABC(): global userInput while True: userInput = input("A, B, or C: ") if userInput == "A" or "a" or "B" or "b" or "C" or "c": break else: userInput = input ("Unreadable input. Please enter A, B, or C: ") break def validABCD(): global userInput while True: userInput = input("A, B, C, or D: ") if userInput == "A" or "a" or "B" or "b" or "C" or "c" or "D" or "d": break else: userInput = input ("Unreadable input. Please enter A, B, C or D: ") break def validABCDE(): global userInput while True: userInput = input("A, B, C, D, or E: ") if userInput == "A" or "a" or "B" or "b" or "C" or "c" or "D" or "d" or "E" or "e": break else: userInput = input ("Unreadable input. Please enter A, B, C, D, E: ") break # -----------------------User Input Validations END--------------------- # ----------------------- CHECKS START-------------------------- def p1check(): if userInput == "A" or userInput == "a": p2armored() elif userInput == "B" or userInput == "b": p2unarmored() def p2check(): if userInput == "A" or userInput == "a": p3uaActions() elif userInput == "B" or userInput == "b": p3bonusActions() elif userInput == "C" or userInput == "c": p3reactions() elif userInput == "D" or userInput == "d": exit def p3check(): if userInput == "A" or userInput == "a": p4Sai() elif userInput == "B" or userInput == "b": p4UA() elif userInput == "C" or userInput == "c": p4bladestorm() elif userInput == "D" or userInput == "d": p2unarmored() def p4check(): if userInput == "A" or userInput == "a": p5GDS() elif userInput == "B" or userInput == "b": p5AttackNick() elif userInput == "C" or userInput == "c": p5Attack() def p4uaCheck(): if userInput == "A" or userInput == "a": p5GDS() elif userInput == "B" or userInput == "b": p5Attack() #------------------------- CHECKS END------------------------- def p1start(): print("Caleb Combat") print("A. Armored") print("B. Unarmored") validAB() p1check() def p2armored(): print("") print("Caleb Combat - Armored") print("Under construction, check back later :3") print("") p1start() def p2unarmored(): print("") print("Caleb Combat - Unarmored") print("A. Actions") print("B. Bonus Actions") print("C. Reactions") print("D. End Turn") validABCD() p2check() #-----------------------UNARMORED ACTIONS TREE--------------------- def p3uaActions(): print("") print("Caleb Combat - Unarmored - Actions") print("A. Sai") print("B. Unarmed") print("C. Bladestorm") print("D. End Action") validABCD() p3check() def p4Sai(): print("") print("Caleb Combat - Unarmored - Actions - Sai") print("A. Grapple/Disarm/Shove") print("B. Attack (Nick with dual wield on 1st attack)") print("C. Attack (solo or 2nd attack)") validABC() p4check() def p4UA(): print("") print("Caleb Combat - Unarmored - Actions - Unarmed") print("A. Grapple/Disarm/Shove") print("B. Attack") validAB() p4uaCheck() def p4bladestorm(): print("") print("Caleb Combat - Unarmored - Actions - Bladestorm") print("Under construction, check back later :3") p3uaActions() def p5GDS(): print("") print("Grapple/Disarm/Shove") global dex global prof dc = (d20() + dex + prof) print("DC:", dc) p3uaActions() def p5AttackNick(): print("") print("Caleb Combat - Unarmored - Actions - Sai Dual - Attack (with Nick)") print("~Attack~") d_20 = d20() attk = (d_20 + dex + prof) print("> Attack:", attk) if d_20 == 20: dmg = d8() + d8() else: dmg = d8() print("> Damage:", dmg) print("") print("~Nick~") d_20 = d20() attk = (d_20 + dex + prof) print("> Attack:", attk) if d_20 == 20: dmg = d8() + d8() else: dmg = d8() print("> Damage:", dmg) p3uaActions() def p5Attack(): print("") print("Attack (Sai w/ No Nick and UA)") print("~Attack~") d_20 = d20() attk = (d_20 + dex + prof) print("> Attack:", attk) if d_20 == 20: dmg = d8() + d8() else: dmg = d8() print("> Damage:", dmg) p3uaActions() #--------------------UNARMORED BONUS ACTION TREE------------------ def p3bonusActions(): print("") print("Caleb Combat - Unarmored - Bonus Actions") print("Under construction, check back later :3") p2unarmored() #--------------------UNARMORED REACTIONS TREE------------------ def p3reactions(): print("") print("Caleb Combat - Unarmored - Reactions") print("Under construction, check back later :3") p2unarmored() # ---------------------- PROGRAM START----------------------- p1start() print("Ended successfully")
Output