Skip to content

Instantly share code, notes, and snippets.

@snorfalorpagus
Created July 25, 2021 14:09
Show Gist options
  • Save snorfalorpagus/e6a31c74a908491031d59db5b9408f5e to your computer and use it in GitHub Desktop.
Save snorfalorpagus/e6a31c74a908491031d59db5b9408f5e to your computer and use it in GitHub Desktop.
Witcher Viper Fangs
from dragn.dice import D6, D10
def explode() -> int:
roll = D10()
if roll == 10:
return roll + explode()
else:
return roll
def rolld10() -> int:
roll = D10()
if roll == 10: # Critical
return roll + explode()
elif roll == 1: # Fumble
return roll - explode()
else:
return roll
REF = 11 # witcher REF
small_blades = 6 # skill in small blades
WA = 2 # weapon accuracy
bandit_ref = 6
bandit_dodge = 4
def sample():
attack = REF + small_blades + rolld10() + WA
dc = bandit_ref + bandit_dodge + rolld10()
success = attack > dc
return success
iterations = 100000
count = 0
for n in range(iterations):
result = sample()
if result:
count += 1
print(f"{count / float(iterations) * 100:.0f}%")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment