From 7d42c60a2cd7645e5dffa6e58a4291dcea04dd5c Mon Sep 17 00:00:00 2001 From: freiheit <19813+freiheit@users.noreply.github.com> Date: Sun, 26 Nov 2023 20:12:03 -0800 Subject: [PATCH] Implement double impact for d10/d12 rolls >=10, closing #27 (#29) --- mvkdicebot.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mvkdicebot.py b/mvkdicebot.py index 4210dcc..7e31408 100755 --- a/mvkdicebot.py +++ b/mvkdicebot.py @@ -93,7 +93,10 @@ async def roll(ctx, *, dicestr: str): } dicerolls = {} - flatdicerolls = [] + flatdicerolls = [] # all dice + # dice d4-d12 are called "Character Dice" and the d20 is called the "Fortune Die" + characterdicerolls = [] # non-d20 dice + fortunedicerolls = [] # d20s pattern_ndn = re.compile(r"([0-9]*) *[dD]([0-9]+)") @@ -109,8 +112,6 @@ async def roll(ctx, *, dicestr: str): else: await ctx.send(f"Invalid dice size d{size}") - flatdicerolls = [] - for size in dicecounts: if dicecounts[size] > 0: # logger.debug(f"rolling: d{size}={dicecounts[size]}") @@ -123,8 +124,14 @@ async def roll(ctx, *, dicestr: str): result = random.randint(1, size) dicerolls[size].append(result) flatdicerolls.append(result) + if size == 20: + fortunedicerolls.append(result) + else: + characterdicerolls.append(result) flatdicerolls.sort(reverse=True) + fortunedicerolls.sort(reverse=True) + characterdicerolls.sort(reverse=True) if len(dicerolls) > 0: answer = "" @@ -158,9 +165,13 @@ async def roll(ctx, *, dicestr: str): action_total = sum(action_dice) answer += f"**Action Total:** {str(action_total)} {str(action_dice)}\n" - impact = sum(1 for p in flatdicerolls if p >= 4) + # die results of 10 or higher on a d10 or 12 give two impact. It doesn't happen on a d20. + fortuneimpact = sum(1 for p in fortunedicerolls if p >= 4) + doublecharacterimpact = sum(2 for p in characterdicerolls if p >= 10) + characterimpact = sum(1 for p in characterdicerolls if p >= 4 and p < 10) + impact = fortuneimpact + doublecharacterimpact + characterimpact impact = max(impact, 1) - answer += f"**Impact:** {impact}" + answer += f"**Impact:** {impact} (fortune={fortuneimpact} 2x={doublecharacterimpact} 1x={characterimpact})" if cheat: answer += "\n# Cheating"