From 255345177629dc98f15a288eb413414dabf93fa2 Mon Sep 17 00:00:00 2001 From: freiheit Date: Sun, 24 Mar 2024 20:05:16 -0700 Subject: [PATCH] Strip out cheating code. Closes #111 --- mvkroller.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/mvkroller.py b/mvkroller.py index 709dbe2..71d6d2d 100644 --- a/mvkroller.py +++ b/mvkroller.py @@ -74,7 +74,7 @@ def parse_dice(dicestr: str): return dicecounts -def roll_dice(dicecounts, cheat=False): +def roll_dice(dicecounts): """Returns a dictionary of dieSize => rolls[]""" dicerolls = { 20: [], @@ -88,11 +88,7 @@ def roll_dice(dicecounts, cheat=False): try: for size, num in dicecounts.items(): if num > 0: - # pylint: disable=unused-variable - if cheat: - dicerolls[size] = [size for idx in range(0, num)] - else: - dicerolls[size] = [random.randint(1, size) for idx in range(0, num)] + dicerolls[size] = [random.randint(1, size) for idx in range(0, num)] except Exception as exc: raise RollError("Exception while rolling dice.") from exc @@ -201,7 +197,6 @@ def mvkroll(dicestr: str): logger.debug("Roll %s", {dicestr}) answer = "" - cheat = False advantage = False disadvantage = False @@ -210,9 +205,6 @@ def mvkroll(dicestr: str): elif re.search(r"advantage", dicestr, flags=re.IGNORECASE): advantage = True - if re.search(r"cheat", dicestr, flags=re.IGNORECASE): - cheat = True - dicecounts = parse_dice(dicestr) # advantage and disadvantage need _at least_ 2d20 @@ -225,7 +217,7 @@ def mvkroll(dicestr: str): dicecounts[20] = 1 answer += "_No advantage/disadvantage, setting 1d20_\n" - dicerolls = roll_dice(dicecounts, cheat) + dicerolls = roll_dice(dicecounts) # the d20 is called the "Fortune Die" fortunedicerolls = dicerolls[20] @@ -259,9 +251,6 @@ def mvkroll(dicestr: str): answer += calc_impact(fortunedicerolls, characterdicerolls) - if cheat: - answer = "\n# Cheating #\n" + answer + "\n# Cheater #\n" - return answer @@ -271,10 +260,9 @@ def plainroll(dicestr: str): logger.debug("Roll %s", {dicestr}) answer = "" - cheat = False dicecounts = parse_dice(dicestr) - dicerolls = roll_dice(dicecounts, cheat) + dicerolls = roll_dice(dicecounts) answer += print_dice(dicerolls)