| Name | yadr JSON |
| Version |
0.1.4
JSON |
| download |
| home_page | https://github.com/pji/yadr |
| Summary | Yet another dice roller for Python. |
| upload_time | 2023-08-23 12:18:02 |
| maintainer | |
| docs_url | None |
| author | Paul J. Iutzi |
| requires_python | >=3.10 |
| license | |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
#############################
yadr: Yet Another Dice Roller
#############################
Another common RPG die rolling syntax random number generator.
Why did you do this?
====================
That's a very good question. I guess the answer is that I started just
to see if I could, and it snowballed from there. In order to explore
Python, I had built a few packages in the past that would randomly
generate table top role playing game (TTRPG) characters. Each of them
had a version of a dice rolling module I had written, so I had this
code in a bunch of places.
"I'll make that a package!" I thought.
But, wait, what if I want to use dice from different game systems? I
had run across Backus Naur form (BNF) descriptions of languages in the
past when looking into algorithms, and it seemed like writing a
parser to handle different dice systems seemed a reasonable way to go.
As reasonable as any thought involving, "I'll use BNF here," can be,
I guess. And so was born Yet Another Dice Notation (YADN) and `yadr`.
For a description of YADN see: YADN_
.. _YADN: https://github.com/pji/yadr/docs/build/html/dice_notation.html
Do we need another Python dice rolling package?
===============================================
No. Probably not. Unsurprisingly, there seems to be a lot of people who
play TTRPGs and write Python packages. This is yet another one.
Hence the name.
Does it support my game?
========================
Check through the YADN doc to see if the operations you need are described
there. If not, open an issue, and I'll see what I can do.
Why does it require Python 3.10?
================================
Another reason for this package is I wanted a project to explore the
new `match case` feature in Python 3.10. I'd read that parsing is
one of the cases where it's really useful.
So, I implemented it.
Then I removed it.
The problem isn't with `match case`. It worked well enough, and I
think the syntax was fairly clear. I'm not really sure it bought me
anything over using `if...elif...else`, but I think that is because
everything I'm lexing or parsing is fairly simple. More complex cases
my see greater benefit from `match...case`.
The problem is with `mypy`. It doesn't support `match case` yet.
So, my options were:
1. Ditch `mypy`,
2. Mark all the `match` blocks as `type: ignore`,
3. Go back to `if`.
Option 2 was just a mess in the code.
My impression is that `mypy` is still here to stay, so I want to try
to make things work with it.
So, I went back to `if`, at least until `mypy` better supports `match
case`.
Since I removed the `match case`, I can probably lower the Python
requirement to 3.7 or so. If anyone ever uses this, I'll think about
it. For now, I'm only testing it under a 3.10 virtual environment, so
I'll keep it at 3.10.
How do I use this package?
==========================
If you want to execute the package from the command line, you can
install the package using `pip` or other Python package manager, and
run it as a module with the following::
python -m yadr <YADN_string>
If you want to import it into your own code, install and import the
package as usual. You can then use the `roll()` function in the `yadr`
module to execute a string of YADN.::
>>> import yadr
>>>
>>> yadn = '3d6'
>>> result = yadr.roll(yadn)
How do I run the tests?
=======================
I'm using the `pytest` library for the unit tests. To just run those tests,
go to the root of your clone of the `yadr` repository and use the following
command::
python3 -m pytest
The full suite of style checks, mypy, and such I use can be run using a
shortcut I have set up in the Makefile::
make pre
Raw data
{
"_id": null,
"home_page": "https://github.com/pji/yadr",
"name": "yadr",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "",
"author": "Paul J. Iutzi",
"author_email": "pji@mac.com",
"download_url": "https://files.pythonhosted.org/packages/97/5b/55d64613f6eba583706c43b6dcec8d7e43c6b36e5c7cb8ec2453c470bd5e/yadr-0.1.4.tar.gz",
"platform": null,
"description": "#############################\nyadr: Yet Another Dice Roller\n#############################\n\nAnother common RPG die rolling syntax random number generator.\n\n\nWhy did you do this?\n====================\nThat's a very good question. I guess the answer is that I started just\nto see if I could, and it snowballed from there. In order to explore\nPython, I had built a few packages in the past that would randomly\ngenerate table top role playing game (TTRPG) characters. Each of them\nhad a version of a dice rolling module I had written, so I had this\ncode in a bunch of places.\n\n\"I'll make that a package!\" I thought.\n\nBut, wait, what if I want to use dice from different game systems? I\nhad run across Backus Naur form (BNF) descriptions of languages in the\npast when looking into algorithms, and it seemed like writing a\nparser to handle different dice systems seemed a reasonable way to go.\nAs reasonable as any thought involving, \"I'll use BNF here,\" can be,\nI guess. And so was born Yet Another Dice Notation (YADN) and `yadr`.\n\nFor a description of YADN see: YADN_\n\n.. _YADN: https://github.com/pji/yadr/docs/build/html/dice_notation.html\n\n\nDo we need another Python dice rolling package?\n===============================================\nNo. Probably not. Unsurprisingly, there seems to be a lot of people who\nplay TTRPGs and write Python packages. This is yet another one.\n\nHence the name.\n\n\nDoes it support my game?\n========================\nCheck through the YADN doc to see if the operations you need are described\nthere. If not, open an issue, and I'll see what I can do.\n\n\nWhy does it require Python 3.10?\n================================\nAnother reason for this package is I wanted a project to explore the\nnew `match case` feature in Python 3.10. I'd read that parsing is\none of the cases where it's really useful.\n\nSo, I implemented it.\n\nThen I removed it.\n\nThe problem isn't with `match case`. It worked well enough, and I\nthink the syntax was fairly clear. I'm not really sure it bought me\nanything over using `if...elif...else`, but I think that is because\neverything I'm lexing or parsing is fairly simple. More complex cases\nmy see greater benefit from `match...case`.\n\nThe problem is with `mypy`. It doesn't support `match case` yet.\nSo, my options were:\n\n1. Ditch `mypy`,\n2. Mark all the `match` blocks as `type: ignore`,\n3. Go back to `if`.\n\nOption 2 was just a mess in the code.\n\nMy impression is that `mypy` is still here to stay, so I want to try\nto make things work with it.\n\nSo, I went back to `if`, at least until `mypy` better supports `match\ncase`.\n\nSince I removed the `match case`, I can probably lower the Python\nrequirement to 3.7 or so. If anyone ever uses this, I'll think about\nit. For now, I'm only testing it under a 3.10 virtual environment, so\nI'll keep it at 3.10.\n\n\nHow do I use this package?\n==========================\nIf you want to execute the package from the command line, you can\ninstall the package using `pip` or other Python package manager, and\nrun it as a module with the following::\n\n python -m yadr <YADN_string>\n\nIf you want to import it into your own code, install and import the\npackage as usual. You can then use the `roll()` function in the `yadr`\nmodule to execute a string of YADN.::\n\n >>> import yadr\n >>>\n >>> yadn = '3d6'\n >>> result = yadr.roll(yadn)\n\n\nHow do I run the tests?\n=======================\nI'm using the `pytest` library for the unit tests. To just run those tests,\ngo to the root of your clone of the `yadr` repository and use the following\ncommand::\n\n python3 -m pytest\n\nThe full suite of style checks, mypy, and such I use can be run using a\nshortcut I have set up in the Makefile::\n\n make pre\n",
"bugtrack_url": null,
"license": "",
"summary": "Yet another dice roller for Python.",
"version": "0.1.4",
"project_urls": {
"Bug Tracker": "https://github.com/pji/yadr/issues",
"Homepage": "https://github.com/pji/yadr"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a6a02fdfa20cce6bbaa98e162a2efb8b60aa922d84031097ba627bd26a53b2de",
"md5": "1032a04c5f838cfa07faabc66cad84f8",
"sha256": "ed6d1498502b047bd877527da8da4fef5e649458dd3c11969c84b1fdef670b85"
},
"downloads": -1,
"filename": "yadr-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1032a04c5f838cfa07faabc66cad84f8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 25857,
"upload_time": "2023-08-23T12:18:00",
"upload_time_iso_8601": "2023-08-23T12:18:00.492575Z",
"url": "https://files.pythonhosted.org/packages/a6/a0/2fdfa20cce6bbaa98e162a2efb8b60aa922d84031097ba627bd26a53b2de/yadr-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "975b55d64613f6eba583706c43b6dcec8d7e43c6b36e5c7cb8ec2453c470bd5e",
"md5": "5db0f6c99040b43359fabdc6d1f50d89",
"sha256": "cf3550afff07a2f1c990ea1da68cdfa7531aa3cc475c74a32405a2fad8a77b5a"
},
"downloads": -1,
"filename": "yadr-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "5db0f6c99040b43359fabdc6d1f50d89",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 31233,
"upload_time": "2023-08-23T12:18:02",
"upload_time_iso_8601": "2023-08-23T12:18:02.239545Z",
"url": "https://files.pythonhosted.org/packages/97/5b/55d64613f6eba583706c43b6dcec8d7e43c6b36e5c7cb8ec2453c470bd5e/yadr-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-23 12:18:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pji",
"github_project": "yadr",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "yadr"
}