# BoardGameBuilder
!!! Project now is in very early stage.
[](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,
Components,
Player,
Steps,
Step,
Deck,
Card,
Shaker,
Dice,
log_enable
)
if __name__ == '__main__':
log_enable()
# Defining a classes
class MyPlayer(Player):
deck: Deck
# Creating of the game
class MyGame(Game):
steps: Steps
shaker: Shaker
me: MyPlayer
opp: MyPlayer
# 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.
# Use Components to fill Game class
C = Components[Dice | Card | Step]()
G = MyGame(
id="my game",
steps=Steps(id="game steps"),
shaker=Shaker(id="dice shaker"),
me=MyPlayer(
id='Me',
deck=Deck(id="my cards deck")
),
opp=MyPlayer(
id='Opponent',
deck=Deck(id="opponent cards deck")
)
)
# 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
C.step0 = Step(id='step0')
C.step1 = Step(id='step1', priority=1)
# Starting of new turn
current_steps = G.steps.deal(C)
# Game steps is a priority queue, ordered by "priority" attribute
last = G.steps.pops()
# Adding of cards to deck. "count" parameter define how mutch
# copies of card we must deal.
C.update(
Card(id='First', description='story', count=2)
)
C.update(Card(id='Second', count=1))
# All items in tools are saved in spetial object Components.
# Is a dict-like class. A component usied as base for other operations with items.
# Any item is available in Component with dot or classic dict
# notation. Names for that notation is transited from ids of items.
card = C.first
card = C['first']
step = C.step0
# You can get item by its id
card = 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()
C.update(
MyCard(id='Thierd', description='story', count=3)
)
# Use default counters of any objects - counters not added to schema
G.me.deck._counter['yellow'] = 12
G.me.deck._counter['banana'] = 0
# Dealing and shuffling of deck
G.me.deck.deal(C).shuffle()
# Adding dices to shaker
C.update(
Dice(id='dice#8', sides=8, count=10)
)
G.shaker.deal(C)
# You can use items from Components
result = C.dice_8.roll()
# Or use from tool
result = G.shaker.roll()
```
## 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)
Raw data
{
"_id": null,
"home_page": "https://github.com/KonstantinKlepikov/BoardGameBuilder",
"name": "bgameb",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "framework",
"author": "Konstantin Klepikov",
"author_email": "oformleno@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/51/1b/db2713c98c9ed60b80ff0cc192de239d9fe71a34ff5d23ee560e2eecf115/bgameb-2.0.0.tar.gz",
"platform": null,
"description": "# BoardGameBuilder\n\n!!! Project now is in very early stage.\n\n[](https://github.com/KonstantinKlepikov/BoardGameBuilder/actions/workflows/release.yml)\n[](https://github.com/KonstantinKlepikov/BoardGameBuilder/actions/workflows/build-docs.yml)\n\nObject-oriented framework for build board game logic in python\n\n`pip install bgameb`\n\n## Short example\n\n```python\nfrom typing import Optional\nfrom pydantic import Field\nfrom bgameb import (\n Game,\n Components,\n Player,\n Steps,\n Step,\n Deck,\n Card,\n Shaker,\n Dice,\n log_enable\n )\n\n\nif __name__ == '__main__':\n log_enable()\n\n # Defining a classes\n class MyPlayer(Player):\n deck: Deck\n\n # Creating of the game\n class MyGame(Game):\n steps: Steps\n shaker: Shaker\n me: MyPlayer\n opp: MyPlayer\n\n # The Player and Game are an obstract containeers for tools and stuff.\n # Deck, Bag, Shaker and Steps are tools. Dice, Card and Step are items.\n # Use Components to fill Game class\n C = Components[Dice | Card | Step]()\n\n G = MyGame(\n id=\"my game\",\n steps=Steps(id=\"game steps\"),\n shaker=Shaker(id=\"dice shaker\"),\n me=MyPlayer(\n id='Me',\n deck=Deck(id=\"my cards deck\")\n ),\n opp=MyPlayer(\n id='Opponent',\n deck=Deck(id=\"opponent cards deck\")\n )\n )\n\n # The tool objects must be filled by items by method add().\n # That because we use some other methods for check\n # data types and makes some operations with items inside tool.\n\n # Adding game tuns order in Steps tool\n C.step0 = Step(id='step0')\n C.step1 = Step(id='step1', priority=1)\n\n # Starting of new turn\n current_steps = G.steps.deal(C)\n\n # Game steps is a priority queue, ordered by \"priority\" attribute\n last = G.steps.pops()\n\n # Adding of cards to deck. \"count\" parameter define how mutch\n # copies of card we must deal.\n C.update(\n Card(id='First', description='story', count=2)\n )\n C.update(Card(id='Second', count=1))\n\n # All items in tools are saved in spetial object Components.\n # Is a dict-like class. A component usied as base for other operations with items.\n # Any item is available in Component with dot or classic dict\n # notation. Names for that notation is transited from ids of items.\n card = C.first\n card = C['first']\n step = C.step0\n\n # You can get item by its id\n card = C.by_id('First')\n\n # If you relocate some bult-in attrs, inherite from stuff classes,\n # then define aliases for attributes. In this example we use two\n # different solution: Field aliase and config.\n # Dont forget use G.dict(by_alias=True) to get aliases.\n # More infoshere:\n # https://docs.pydantic.dev/usage/model_config/#alias-generator\n # Finaly, if you need use callbacs to export data from some\n # function as field values - define properties.\n class MyCard(Card):\n description: Optional[str] = Field(None, alias='some_bla_bla')\n some_text: Optional[str] = 'some texts'\n\n class Config(Card.Config):\n fields = {'is_revealed': 'is_open'}\n\n @property\n def my_calculated_field(self) -> str:\n return self.some_text.upper()\n\n C.update(\n MyCard(id='Thierd', description='story', count=3)\n )\n\n # Use default counters of any objects - counters not added to schema\n G.me.deck._counter['yellow'] = 12\n G.me.deck._counter['banana'] = 0\n\n # Dealing and shuffling of deck\n G.me.deck.deal(C).shuffle()\n\n # Adding dices to shaker\n C.update(\n Dice(id='dice#8', sides=8, count=10)\n )\n G.shaker.deal(C)\n\n # You can use items from Components\n result = C.dice_8.roll()\n\n # Or use from tool\n result = G.shaker.roll()\n```\n\n## Documentation\n\n- [docs](https://konstantinklepikov.github.io/BoardGameBuilder/)\n- [pypi](https://pypi.org/project/bgameb/)\n\n## Development\n\n[how install project for development](https://konstantinklepikov.github.io/BoardGameBuilder/usage.html).\n\nTypicaly: `pip install -e .[dev]`\n\n### Available cli\n\n`make proj-doc`\n\n`make test`\n\nto check simple scenario use `python tests/check.py`\n\n`make test-pypi` to test deploy to testpypi\n\n`make log` - insert fragmet name to store new about project\n\n`make ipython` run interactive terminal\n\n`make check` check flake8 and mypy\n\nAvailable fragmet naming:\n\n- .feature: Signifying a new feature.\n- .bugfix: Signifying a bug fix.\n- .doc: Signifying a documentation improvement.\n- .removal: Signifying a deprecation or removal of public API.\n- .misc: A ticket has been closed, but it is not of interest to users.\n\n`make draft` - to check changelog output before release.\n\n`make release` - to bump version, build changelog, commit, push tags and changes.\n\n\\* for version management are used [incremental](https://github.com/twisted/incremental) and [towncrier](https://pypi.org/project/towncrier/) for changelog\n\\* project based on [pydantic](https://github.com/pydantic/pydantic)\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Board Game Builder",
"version": "2.0.0",
"project_urls": {
"Docs": "https://konstantinklepikov.github.io/BoardGameBuilder/",
"Homepage": "https://github.com/KonstantinKlepikov/BoardGameBuilder",
"Source": "https://github.com/KonstantinKlepikov/BoardGameBuilder"
},
"split_keywords": [
"framework"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f9fdde351a63132fa47a76c671c24f914d061f503467786a4e6a70f44798837b",
"md5": "6566b144184c96c787f25417bf79578e",
"sha256": "edb740c1a64daa581a16cff2acfbb1e979624df9157feefd08cce7cc0960dfd1"
},
"downloads": -1,
"filename": "bgameb-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6566b144184c96c787f25417bf79578e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 16054,
"upload_time": "2023-05-24T00:45:30",
"upload_time_iso_8601": "2023-05-24T00:45:30.418542Z",
"url": "https://files.pythonhosted.org/packages/f9/fd/de351a63132fa47a76c671c24f914d061f503467786a4e6a70f44798837b/bgameb-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "511bdb2713c98c9ed60b80ff0cc192de239d9fe71a34ff5d23ee560e2eecf115",
"md5": "98a82982ed0a3186c97bc4da1ea702d4",
"sha256": "0a65c53d8684b963611f35e9bee32f8813dcfc0f195940cc0327324fa25e55ed"
},
"downloads": -1,
"filename": "bgameb-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "98a82982ed0a3186c97bc4da1ea702d4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 18144,
"upload_time": "2023-05-24T00:45:32",
"upload_time_iso_8601": "2023-05-24T00:45:32.405773Z",
"url": "https://files.pythonhosted.org/packages/51/1b/db2713c98c9ed60b80ff0cc192de239d9fe71a34ff5d23ee560e2eecf115/bgameb-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-24 00:45:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "KonstantinKlepikov",
"github_project": "BoardGameBuilder",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "bgameb"
}