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 [Python](https://www.python.org) – Languages -- Pylint [Pylint](https://www.pylint.org/) – Code Review -- GitHub Actions [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 @@ - -
- -# Tech Stack File -![](https://img.stackshare.io/repo.svg "repo") [freiheit/MvKDiceBot](https://github.com/freiheit/MvKDiceBot)![](https://img.stackshare.io/public_badge.svg "public") -

-|6
Tools used|11/10/23
Report generated| -|------|------| -
- -## Languages (1) - - - - -
- Python -
- Python -
- -
- -## DevOps (4) - - - - - - - - - - -
- Git -
- Git -
- -
- GitHub Actions -
- GitHub Actions -
- -
- PyPI -
- PyPI -
- -
- Pylint -
- Pylint -
- v3.0.2 -
- - -## Open source packages (1) - -## PyPI (1) - -|NAME|VERSION|LAST UPDATED|LAST UPDATED BY|LICENSE|VULNERABILITIES| -|:------|:------|:------|:------|:------|:------| -|[yarl](https://pypi.org/yarl)|v1.9.2|10/29/23|freiheit |Apache-2.0|N/A| - -
-
- -Generated via [Stack File](https://github.com/apps/stack-file) diff --git a/techstack.yml b/techstack.yml deleted file mode 100644 index 8f5bf86..0000000 --- a/techstack.yml +++ /dev/null @@ -1,61 +0,0 @@ -repo_name: freiheit/MvKDiceBot -repo_type: Public -requested_by: freiheit -provider: github -detected_tools_count: 5 -tools: -- name: Python - description: A clear and powerful object-oriented programming language, comparable - to Perl, Ruby, Scheme, or Java. - website_url: https://www.python.org - open_source: true - hosted_saas: false - category: Languages & Frameworks - sub_category: Languages - image_url: https://img.stackshare.io/service/993/pUBY5pVj.png - detection_source: Repo Metadata -- name: Git - description: Fast, scalable, distributed revision control system - website_url: http://git-scm.com/ - open_source: true - hosted_saas: false - category: Build, Test, Deploy - sub_category: Version Control System - image_url: https://img.stackshare.io/service/1046/git.png - detection_source: Repo Metadata -- name: GitHub Actions - description: Automate your workflow from idea to production - website_url: https://github.com/features/actions - open_source: false - hosted_saas: true - category: Build, Test, Deploy - sub_category: Continuous Integration - image_url: https://img.stackshare.io/service/11563/actions.png - detection_source: ".github/workflows/pylint.yml" - last_updated_by: renovate[bot] - last_updated_on: 2023-10-27 05:47:46.000000000 Z -- name: PyPI - description: A repository of software for the Python programming language - website_url: https://pypi.org/ - open_source: false - hosted_saas: false - category: Build, Test, Deploy - sub_category: Hosted Package Repository - image_url: https://img.stackshare.io/service/12572/-RIWgodF_400x400.jpg - detection_source: requirements.txt - last_updated_by: freiheit - last_updated_on: 2023-10-29 21:19:35.000000000 Z -- name: Pylint - description: Source-code, bug and quality checker for the Python programming language - website_url: https://www.pylint.org/ - version: 3.0.2 - license: GPL-2.0 - open_source: true - hosted_saas: false - category: Build, Test, Deploy - sub_category: Code Review - image_url: https://img.stackshare.io/service/4837/py.jpg - detection_source_url: requirements.txt - detection_source: requirements.txt - last_updated_by: freiheit - last_updated_on: 2023-10-29 21:19:35.000000000 Z diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..ae5e6e1 --- /dev/null +++ b/update.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +./.venv/bin/pip install -r requirements.txt