Code: Select all
# a simulator to do some fake combat dice rolls to test survivability
# with new resist/vulns system
import dice
current_hitpoints = max_hitpoints = int(input("How many HPs do you want: "))
dmg = input("How much damage do you think you're doing? (xdy):")
# save a series of rolls - more than we need:
print("Storing 100 damage rolls...")
rolls = []
for num in range(100):
num = sum(dice.roll(dmg))
rolls.append(num)
# append one final massive value to make sure we die with no issues
rolls.append(max_hitpoints)
rounds = 0
standard_rnds = 0
full_vuln_rnds = 0
half_vuln_rnds = 0
full_resist_rnds = 0
half_resist_rnds = 0
# First, a standard set of rounds
lowest_dmg = rolls[0]
#print("\n1: Standard combat round, no modifiers:")
for roll in rolls:
current_hitpoints -= roll
standard_rnds += 1
if current_hitpoints < 1:
#print(f"You lasted {standard_rnds} rounds before dying.")
break
current_hitpoints = max_hitpoints
# Full Vuln - 25%
lowest_dmg = rolls[0]
#print("\n2: Full Vulnerability - 25% extra damage:")
for roll in rolls:
current_hitpoints -= int((roll/4) * 5)
full_vuln_rnds += 1
if current_hitpoints < 1:
# print(f"You lasted {full_vuln_rnds} rounds before dying.")
break
current_hitpoints = max_hitpoints
# Half Vuln - 12.5%
lowest_dmg = rolls[0]
#print("\n3: Half Vulnerability - 12.5% extra damage:")
for roll in rolls:
current_hitpoints -= int((roll/8) * 9)
half_vuln_rnds += 1
if current_hitpoints < 1:
#print(f"You lasted {half_vuln_rnds} rounds before dying.")
break
current_hitpoints = max_hitpoints
# Full Resist - 25%
lowest_dmg = rolls[0]
#print("\n4: Full Resist - 25% less damage:")
for roll in rolls:
current_hitpoints -= int((roll/4) * 3)
full_resist_rnds += 1
if current_hitpoints < 1:
# print(f"You lasted {full_resist_rnds} rounds before dying.")
break
current_hitpoints = max_hitpoints
# Half Resist - 12.5%
lowest_dmg = rolls[0]
#print("\n4: Full Resist - 25% less damage:")
for roll in rolls:
current_hitpoints -= int((roll/8) * 7)
half_resist_rnds += 1
if current_hitpoints < 1:
#print(f"You lasted {half_resist_rnds} rounds before dying.")
break
print(f"Combat Simulation Results ({dmg} damage) ({max_hitpoints} HPs):")
print("Full: 25% --- Half: 12%\n")
print(f"Full Resist:\t {full_resist_rnds} rounds.")
print(f"Half Resist:\t {half_resist_rnds} rounds.")
print(f"Standard:\t {standard_rnds} rounds.")
print(f"Half Vuln:\t {half_vuln_rnds} rounds.")
print(f"Full Vuln:\t {full_vuln_rnds} rounds.")
edit: forgot to say - delighted to discover there is a dice module for python so I had to do literally no work to translate '3d6' into an actual number. Brilliant.How many HPs do you want: 280
How much damage do you think you're doing? (xdy):7d6
Storing 100 damage rolls...
Combat Simulation Results (7d6 damage) (280 HPs):
Full: 25% --- Half: 12%
Full Resist: 16 rounds.
Half Resist: 14 rounds.
Standard: 13 rounds.
Half Vuln: 11 rounds.
Full Vuln: 10 rounds.
extra edit: and because obviously I didn't read the instructions probably I did this:
Code: Select all
num = sum(dice.roll(dmg))
Code: Select all
num = dice.roll(dmg+t)