bgameb-0.1.2
توضیحات
Board Game Builder
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | bgameb-0.1.2 |
| نام | bgameb |
| نسخه کتابخانه | 0.1.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Konstantin Klepikov |
| ایمیل نویسنده | oformleno@gmail.com |
| آدرس صفحه اصلی | https://github.com/KonstantinKlepikov/BoardGameBuilder |
| آدرس اینترنتی | https://pypi.org/project/bgameb/ |
| مجوز | MIT |
# BoardGameBuilder
!!! Project now is in very early stage. Dont use it in any apps :)
[](https://github.com/KonstantinKlepikov/BoardGameBuilder/actions/workflows/release.yml)
[](https://github.com/KonstantinKlepikov/BoardGameBuilder/actions/workflows/build-docs.yml)
Object-oriented framework for build board game logic in python
`pip install bgameb`
## Short example
```python
from typing import Optional
from pydantic import Field
from bgameb import (
Game, Player, Steps, Step, Deck, Card, Shaker, Dice,
Bag, log_enable
)
if __name__ == '__main__':
log_enable()
# Creating of the game
class MyGame(Game):
steps: Steps
deck: Deck
shaker: Shaker
bag: Bag
players: list[Player] = []
# The Player and Game are an obstract containeers for tools and stuff.
# Deck, Bag, Shaker and Steps are tools. Dice, Card and Step are items.
G = MyGame(
id='one board game',
steps=Steps(id='steps'),
deck=Deck(id='deck'),
shaker=Shaker(id='shaker'),
bag=Bag(id='bag'),
players=[Player(id='player1'), Player(id='player2')]
)
# The tool objects must be filled by items by method add().
# That because we use some other methods for check
# data types and makes some operations with items inside tool.
# Adding game tuns order in Steps tool
G.steps.add(Step(id='step0'))
G.steps.add(Step(id='step1', priority=1))
# Starting of new turn
current_steps = G.steps.deal()
# Game steps is a priority queue, ordered by "priority" attribute
last = G.steps.pop()
# Adding of cards to deck. "count" parameter define how mutch
# copies of card we must deal.
G.deck.add(
Card(id='First', description='story', count=2)
)
G.deck.add(Card(id='Second', count=1))
# All items in tools are saved in spetial object Component.
# Is a dict-like class. Component is predefined as attribute "c".
# A component usied as base for other operations with items.
cards_component = G.deck.c
# Any item is available in Component with dot or classic dict
# notation. Names for that notation is transited from ids of items.
card = G.deck.c.first
card = G.deck.c['first']
# You can get item by its id
card = G.deck.c.by_id('First')
# If you relocate some bult-in attrs, inherite from stuff classes,
# then define aliases for attributes. In this example we use two
# different solution: Field aliase and config.
# Dont forget use G.dict(by_alias=True) to get aliases.
# More infoshere:
# https://docs.pydantic.dev/usage/model_config/#alias-generator
# Finaly, if you need use callbacs to export data from some
# function as field values - define properties.
class MyCard(Card):
description: Optional[str] = Field(None, alias='some_bla_bla')
some_text: Optional[str] = 'some texts'
class Config(Card.Config):
fields = {'is_revealed': 'is_open'}
@property
def my_calculated_field(self) -> str:
return self.some_text.upper()
G.deck.add(
MyCard(id='Thierd', description='story', count=3)
)
# Use default counters of any objects - counters not added to schema output
G.deck.c.first._counter['yellow'] = 12
G.deck.c.second._counter['banana'] = 0
# Dealing and shuffling of deck
G.deck.deal().shuffle()
# Adding dices to shaker
G.shaker.add(
Dice(id='dice#8', sides=8, count=10)
)
# Roll dices
result = G.shaker.c.dice_8.roll()
# Use bag as collection of any items
G.bag.add(Dice(id='dice'))
G.bag.add(Card(id='card'))
```
## Documentation
- [docs](https://konstantinklepikov.github.io/BoardGameBuilder/)
- [pypi](https://pypi.org/project/bgameb/)
## Development
[how install project for development](https://konstantinklepikov.github.io/BoardGameBuilder/usage.html).
Typicaly: `pip install -e .[dev]`
### Available cli
`make proj-doc`
`make test`
to check simple scenario use `python tests/check.py`
`make test-pypi` to test deploy to testpypi
`make log` - insert fragmet name to store new about project
`make ipython` run interactive terminal
`make check` check flake8 and mypy
Available fragmet naming:
- .feature: Signifying a new feature.
- .bugfix: Signifying a bug fix.
- .doc: Signifying a documentation improvement.
- .removal: Signifying a deprecation or removal of public API.
- .misc: A ticket has been closed, but it is not of interest to users.
`make draft` - to check changelog output before release.
`make release` - to bump version, build changelog, commit, push tags and changes.
\* for version management are used [incremental](https://github.com/twisted/incremental) and [towncrier](https://pypi.org/project/towncrier/) for changelog
\* project based on [pydantic](https://github.com/pydantic/pydantic)
نیازمندی
| مقدار | نام |
|---|---|
| ==21.3.0 | incremental |
| ==0.6.0 | loguru |
| ==1.10.4 | pydantic |
| ==0.20.0 | python-dotenv |
| ==4.3.0 | typing-extensions |
| ==0.7.12 | alabaster |
| ==2.0.8 | asttokens |
| ==22.1.0 | attrs |
| ==20.2.0 | Automat |
| ==2.10.3 | Babel |
| ==0.2.0 | backcall |
| ==4.11.1 | beautifulsoup4 |
| ==5.0.1 | bleach |
| ==0.8.0 | build |
| ==2022.12.7 | certifi |
| ==1.15.1 | cffi |
| ==2.1.1 | charset-normalizer |
| ==8.1.3 | click |
| ==1.2.2 | click-default-group |
| ==0.9.1 | commonmark |
| ==15.1.0 | constantly |
| ==38.0.4 | cryptography |
| ==5.1.1 | decorator |
| ==0.17.1 | docutils |
| ==1.0.0 | executing |
| ==5.0.4 | flake8 |
| ==21.0.0 | hyperlink |
| ==3.3 | idna |
| ==1.4.1 | imagesize |
| ==4.12.0 | importlib-metadata |
| ==21.3.0 | incremental |
| ==1.1.1 | iniconfig |
| ==8.4.0 | ipython |
| ==0.18.1 | jedi |
| ==0.8.0 | jeepney |
| ==3.1.2 | Jinja2 |
| ==23.8.2 | keyring |
| ==0.6.0 | loguru |
| ==2.1.0 | markdown-it-py |
| ==2.1.1 | MarkupSafe |
| ==3.17.1 | marshmallow |
| ==1.5.1 | marshmallow-enum |
| ==0.1.6 | matplotlib-inline |
| ==0.7.0 | mccabe |
| ==0.3.0 | mdit-py-plugins |
| ==0.1.2 | mdurl |
| ==0.982 | mypy |
| ==0.4.3 | mypy-extensions |
| ==0.18.0 | myst-parser |
| ==21.3 | packaging |
| ==0.8.3 | parso |
| ==0.13.0 | pep517 |
| ==4.8.0 | pexpect |
| ==0.7.5 | pickleshare |
| ==1.8.3 | pkginfo |
| ==1.0.0 | pluggy |
| ==3.0.30 | prompt-toolkit |
| ==0.7.0 | ptyprocess |
| ==0.2.2 | pure-eval |
| ==1.11.0 | py |
| ==2.9.1 | pycodestyle |
| ==2.21 | pycparser |
| ==1.10.4 | pydantic |
| ==2.5.0 | pyflakes |
| ==2.13.0 | Pygments |
| ==3.0.9 | pyparsing |
| ==7.1.2 | pytest |
| ==0.20.0 | python-dotenv |
| ==2022.2.1 | pytz |
| ==6.0 | PyYAML |
| ==1.0.10 | Random-Word |
| ==37.0 | readme-renderer |
| ==2.28.1 | requests |
| ==0.9.1 | requests-toolbelt |
| ==2.0.0 | rfc3986 |
| ==12.5.1 | rich |
| ==3.3.3 | SecretStorage |
| ==1.16.0 | six |
| ==2.2.0 | snowballstemmer |
| ==2.3.2.post1 | soupsieve |
| ==5.1.1 | Sphinx |
| ==0.0.1a12 | sphinx-basic-ng |
| ==1.0.0 | sphinx-rtd-theme |
| ==1.0.2 | sphinxcontrib-applehelp |
| ==1.0.2 | sphinxcontrib-devhelp |
| ==2.0.0 | sphinxcontrib-htmlhelp |
| ==1.0.1 | sphinxcontrib-jsmath |
| ==1.0.3 | sphinxcontrib-qthelp |
| ==1.1.5 | sphinxcontrib-serializinghtml |
| ==0.5.0 | stack-data |
| ==2.0.1 | tomli |
| ==21.9.0 | towncrier |
| ==5.3.0 | traitlets |
| ==4.0.1 | twine |
| ==22.10.0 | Twisted |
| ==0.8.0 | typing-inspect |
| ==4.3.0 | typing-extensions |
| ==1.26.12 | urllib3 |
| ==0.2.5 | wcwidth |
| ==0.5.1 | webencodings |
| ==3.8.1 | zipp |
| ==5.4.0 | zope.interface |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.9 | Python |
نحوه نصب
نصب پکیج whl bgameb-0.1.2:
pip install bgameb-0.1.2.whl
نصب پکیج tar.gz bgameb-0.1.2:
pip install bgameb-0.1.2.tar.gz