Skip to content
Permalink
de8188658e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
40 lines (30 sloc) 1.13 KB
from character import Character
def roll_initiative(character: Character) -> None:
"""Roll initiative with advantage"""
print("\nRolling initiative with advantage (Dex mod applies)")
# Get two rolls due to advantage
roll1 = character.roll_saving_throw("dexterity")[1] # Just get the raw roll
roll2 = character.roll_saving_throw("dexterity")[1]
# Use the higher roll
base_roll = max(roll1, roll2)
print(f"Rolling with advantage: {roll1} and {roll2}, using {base_roll}")
# Add Dex modifier
dex_mod = character.dexterity_mod
total = base_roll + dex_mod
print(f"Adding: {dex_mod:+d} dexterity modifier")
print(f"Final Initiative: {total}")
def main():
character = Character("Your Character")
while True:
print("\nAvailable commands:")
print("1. Roll Initiative")
print("2. Exit")
choice = input("\nEnter choice (1-2): ")
if choice == "1":
roll_initiative(character)
elif choice == "2":
break
else:
print("Invalid choice")
if __name__ == "__main__":
main()