Backend logic for DND 5e(2014)
Project description
Mind Goblin
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣠⣤⣤⣀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀
⠀⠀⠀⠀⠀⠀⠀⢀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀
⠀⠀⠀⠀⢀⣀⢾⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣭⡍⣿⣿⣿⣿⣿⣿⠀
⠀⢀⣴⣶⣶⣝⢷⡝⢿⣿⣿⣿⠿⠛⠉⠀⠀⣰⣿⣿⢣⣿⣿⣿⣿⣿⣿⡇
⢀⣾⣿⣿⣿⣿⣧⠻⡌⠿⠋⠁⠀⠀⠀⠀⢰⣿⣿⡏⣸⣿⣿⣿⣿⣿⣿⣿
⣼⣿⣿⣿⣿⣿⣿⡇⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⠇⢻⣿⣿⣿⣿⣿⣿⡟
⠙⢹⣿⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⣿⣿⡿⠟⠁
⠀⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Initial Idea
- Set of random generation tools (use DMG tables for reference)
- random dungeon generation
- random encounter generation
- random npc generation
- random villain generation
- random adventure genration
- have options to lock/freeze certain features and re-roll others
- have option to pipe output to a json file on "save"
- ea. sub-table used in any of the above generation must be accessible on its own
terminal input or API
stretch goal: UI (fuck this shit)
- Combat DM utils
- hell, write a fucking engine for combat that takes an excel sheet and randomly rolls initiative scores for all monsters, sorts them according to initiative and updates the same sheet
- Story DM utils
- weather rolls
- random encounter rolls
- Encounter planning utils
- calculate "difficulty" of an encounter
- generate equivalent difficulty of encounter, according to parameters:
- monsters given as input
- number of monsters
- specific categories of monsters ! will need DB full of monsters
Better Goals, to also help with Assessment
Pick a web python framework
Pick from the following:
- Django
- fucking complex, piece of shit
- fucking complex, piece of shit, I hate it
- ORM and signals and shit
- Flask
- simple
- SQL alchemy ORM
- we use on the project
1. FastAPI+ lightweight+ tight overlap with what I do for work
Tables should be stored in model layer, via ORM
I can also fucking model the combat encounter data
- calls monster manual
- conditions model
- AC mechanism
I can also store a bestiary or see if there is any open-source API that has these fucks that I can call
Deliverables
DM utils
- Encounter automation
- intiative calculation
- ordering by initiative
- need to take this as json artifact, have another middleware service that converts to excel-like
- then writes this data into an excel spreadsheet
- input: monster, number
- Set of random generation tools (use DMG tables for reference)
- random dungeon generation
- random encounter generation
- random npc generation
- random villain generation
- random adventure genration
- story randomization
- have options to lock/freeze certain features and re-roll others
- have option to pipe output to a json file on "save"
- ea. sub-table used in any of the above generation must be accessible on its own
- (stretch) I want something like a query processor:
- input: a term that I am searching for, with fuzzy search
- output: a description of its mechanics (str output), along with source of reference
- Encounter planning utils
https://github.com/fantasycalendar/kobold-plus-fight-club/tree/master
https://koboldplus.club/
-
poach this
-
fuck the ui
-
calculate "difficulty" of an encounter
-
generate equivalent difficulty of encounter, according to parameters:
- monsters given as input
- number of monsters
- specific categories of monsters
Prerequisites
- DB of monsters
- poach this, convert to relational mapping, practice ORM techniques
- DB of active effects
- poach this, convert to relational mapping, practice ORM techniques
Implementation
-
Web Framework: Flask
-
DB Layer/ORM: sqlAlchemy
-
Architecturally I want to have 3 major components:
- Self-contained, monolithic backend logic that can be interfaced with
dungeons_logic
- CLI interface: basic unix input handling and shit
dungeons_local
- MVC REST API that makes contact with the monolith
dungeons_web
TODO
- deploy everything in docker image, create db dynamically
Working with Alebic
- Generate migration scripts to review: this also serves to check any "compilation errors" in the models
alembic revision --autogenerate -m "description of your migration"
-
--autogenerate: Tells Alembic to automatically compare the database schema and the models to generate migration instructions.
-
-m: Specifies a short message describing the migration, such as "add new column to users table".
- Update/fix the migration generated in
alembic/versions
NOTE: upgrade, downgrade functions contain steps for upgrading and downgrading respectively
- If satisfied, run
alembic upgrade head
Reverting Migrations
Latest Migration
Run
alembic downgrade -1
This command will undo the last migration, rolling back the database schema to its previous state.
Migration by id
alembic downgrade <revision_id>
Show History
alembic history --verbose
Pending Migrations
alembic heads
Versioning and Poetry
Use semver
Poetry
At the time of this commit, I am new to Poetry, as such some practices listed below may be non-optimal. Who fucking cococares.
Workflow
- Use
pipandrequirements.txtfor local development - Maintain
requirements.txtin parity withpyproject.toml - To update
pyproject.tomldependencies with those inrequirements.txt
poetry add $(cat requirements.txt)
Pushing new releases
I have not implemented a workflow for releases to be pushed on commits to the main branch. Should do that later.
Currently, need to manually tag and release tags from CLI:
git tag <x.y.z>
git push origin --tags
semper fi
Deleting tags if build fails
Locally
git tag -d <x.y.z>
Remotely
git push origin --delete <tag-name>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dungeons_logic-0.0.2.tar.gz.
File metadata
- Download URL: dungeons_logic-0.0.2.tar.gz
- Upload date:
- Size: 33.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f03593db1249b5ffd82c090e05a7fca253e78a30e834fb048a1dd161e6c4b83c
|
|
| MD5 |
b0e439db849064ed13c133d9b5791411
|
|
| BLAKE2b-256 |
ef0102cd30ab91c81dde918301b4d19b4074b36d5a0dba9e051a310e5b474cf4
|
Provenance
The following attestation bundles were made for dungeons_logic-0.0.2.tar.gz:
Publisher:
release.yaml on nickchkonia/dungeons_logic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dungeons_logic-0.0.2.tar.gz -
Subject digest:
f03593db1249b5ffd82c090e05a7fca253e78a30e834fb048a1dd161e6c4b83c - Sigstore transparency entry: 169879289
- Sigstore integration time:
-
Permalink:
nickchkonia/dungeons_logic@7b641996e39327b2ac752456a856a9080816276f -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/nickchkonia
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@7b641996e39327b2ac752456a856a9080816276f -
Trigger Event:
push
-
Statement type:
File details
Details for the file dungeons_logic-0.0.2-py3-none-any.whl.
File metadata
- Download URL: dungeons_logic-0.0.2-py3-none-any.whl
- Upload date:
- Size: 53.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d53cdabf33b5759af0a33218e87f847c58acc73d54e41a133848c5452a2f4cc0
|
|
| MD5 |
a814caf01199316e7d8b436d6b835702
|
|
| BLAKE2b-256 |
38798b12869aff7565b1b83eeb0c48eaaaa8cc427e0475482f90c245c4e8059b
|
Provenance
The following attestation bundles were made for dungeons_logic-0.0.2-py3-none-any.whl:
Publisher:
release.yaml on nickchkonia/dungeons_logic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dungeons_logic-0.0.2-py3-none-any.whl -
Subject digest:
d53cdabf33b5759af0a33218e87f847c58acc73d54e41a133848c5452a2f4cc0 - Sigstore transparency entry: 169879291
- Sigstore integration time:
-
Permalink:
nickchkonia/dungeons_logic@7b641996e39327b2ac752456a856a9080816276f -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/nickchkonia
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@7b641996e39327b2ac752456a856a9080816276f -
Trigger Event:
push
-
Statement type: