diff --git a/README.md b/README.md index 1939ef0..ffba05d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ [![CodeQL](https://github.com/freiheit/MvKDiceBot/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/freiheit/MvKDiceBot/actions/workflows/github-code-scanning/codeql) [![Pylint](https://github.com/freiheit/MvKDiceBot/actions/workflows/pylint.yml/badge.svg)](https://github.com/freiheit/MvKDiceBot/actions/workflows/pylint.yml) - - - # MvKDiceBot Dice bot for MvK ruleset... @@ -22,11 +19,3 @@ https://discord.com/api/oauth2/authorize?client_id=1168083075515826186&permissio 7. Generate an invite URL: - Scopes: bot, applications.commands - Bot Permissions: Read Messages/View Channels, Send Messages, Send Messages in Threads - -## Tech Stack -freiheit/MvKDiceBot is built on the following main stack: -- [Python](https://www.python.org) – Languages -- [Pylint](https://www.pylint.org/) – Code Review -- [GitHub Actions](https://github.com/features/actions) – Continuous Integration - -Full tech stack [here](/techstack.md) diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..450fefc --- /dev/null +++ b/install.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +if which yum; then + sudo yum --skip-broken -y install python3.11 python3.11-devel python3.11-pip python3.11-pip-wheel python3.11-wheel +fi +# TODO: elif apt ... + +python3.11 -m venv --symlinks --system-site-packages .venv +./.venv/bin/pip install -r requirements.txt diff --git a/mvkdicebot.py b/mvkdicebot.py index 940a153..054d264 100755 --- a/mvkdicebot.py +++ b/mvkdicebot.py @@ -50,7 +50,7 @@ async def on_ready(): logger.warning(f"Logged in as {bot.user} (ID: {bot.user.id})") -@bot.hybrid_command() # pylint: disable=no-member +@bot.hybrid_command(aliases=["r", "rolldice", "diceroll"]) # pylint: disable=no-member async def roll(ctx, *, dicestr: str): """Rolls a pool of dice in NdN format. Example: '?roll 1d20 2d10 d8 2d6' @@ -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,16 @@ 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 4 <= p < 10) + impact = fortuneimpact + doublecharacterimpact + characterimpact impact = max(impact, 1) - answer += f"**Impact:** {impact}" + answer += f"**Impact:** {impact} " + answer += ( + f"(fortune={fortuneimpact} 2x={doublecharacterimpact} 1x={characterimpact})" + ) if cheat: answer += "\n# Cheating" diff --git a/requirements.txt b/requirements.txt index f3b63a9..06da567 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -aiohttp==3.9.0 +aiohttp==3.9.1 aiosignal==1.3.1 astroid==3.0.1 async-timeout==4.0.3 diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..846b539 --- /dev/null +++ b/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +./.venv/bin/python3 mvkdicebot.py diff --git a/techstack.md b/techstack.md deleted file mode 100644 index cbc490d..0000000 --- a/techstack.md +++ /dev/null @@ -1,93 +0,0 @@ - -
-
- - Python - - - |
-
-
-
- - Git - - - |
-
-
-
- - GitHub Actions - - - |
-
-
-
- - PyPI - - - |
-
-
-
- - Pylint - - v3.0.2 - |
-
-