Skip to content

Commit

Permalink
Actually scratch the lowest-non-1 die when a critical fumble happens
Browse files Browse the repository at this point in the history
  • Loading branch information
freiheit committed Mar 23, 2024
1 parent 1404e93 commit 206e7b5
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions mvkroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,29 @@ def calc_impact(fortunedicerolls, characterdicerolls):
raise RollError("Coding error calculating Impact") from exc
return answer

def crit_fumble(fortunedicerolls, characterdicerolls):
"""Check if we had a critical fumble. If so, add output and discard lowest non-1 die"""
answer = ""
newdicerolls = characterdicerolls
if fortunedicerolls[0] == 1:
answer += "**Critical Fumble**\n"
characterdicerolls.sort()
newdicerolls = []
scratched = False
for i in characterdicerolls:
if scratched:
newdicerolls.append(i)
elif i == 1:
newdicerolls.append(i)
else:
scratched = True
answer += f"*Scratched {i}*\n"
# no append because scratching this die

answer += "**Gain 1 inspiration point**\n"
answer += f"New character dice: {newdicerolls}\n"
return answer, newdicerolls

def mvkroll(dicestr: str):
"""Implementation of dice roller that applies MvK rules."""

Expand Down Expand Up @@ -223,9 +246,8 @@ def mvkroll(dicestr: str):

answer += print_dice(dicerolls)

if dicerolls[20][0] == 1:
answer += "**Critical Fumble**\n"
answer += "*Scratch a die that didn't roll 1, and gain 1 inspiration point*\n"
fumble_answer, characterdicerolls = crit_fumble(fortunedicerolls, characterdicerolls)
answer += fumble_answer

answer += calc_action(fortunedicerolls, characterdicerolls)

Expand Down

0 comments on commit 206e7b5

Please sign in to comment.