Skip to content

Commit

Permalink
Strip out cheating code.
Browse files Browse the repository at this point in the history
Closes #111
  • Loading branch information
freiheit committed Mar 25, 2024
1 parent 66cca03 commit 2553451
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions mvkroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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

Expand Down Expand Up @@ -201,7 +197,6 @@ def mvkroll(dicestr: str):
logger.debug("Roll %s", {dicestr})

answer = ""
cheat = False
advantage = False
disadvantage = False

Expand All @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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


Expand All @@ -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)

Expand Down

0 comments on commit 2553451

Please sign in to comment.