{ "info": { "author": "Finn Ellis", "author_email": "relsqui@chiliahedron.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "## protocards\n\nis a library for implementing card game logic in python. It's designed to be\ngeneric enough to build unique card types with, but also implements a standard\npoker deck for convenience. Basic usage is simple:\n\n```\n>>> from protocards.standard import make_deck\n>>>\n>>> deck = make_deck(shuffle=True)\n>>> hand = deck.deal(5)\n>>> print(hand)\nAJ6s 2h 3c\n>>> print(hand[0])\nAce of Spades\n```\n\nThe cribbage module implements some example game logic using protocards.\n\n```\n>>> from protocards.standard import make_deck\n>>> from protocards.cribbage import score_hand\n>>>\n>>> deck = make_deck(shuffle=True)\n>>> hand = deck.deal(4)\n>>> turned = deck.pop()\n>>> print(hand)\nJh 8d QTc\n>>> print(turned)\nSix of Spades\n>>> score_hand(hand, turned)\n{'runs': 3, 'fifteens': 0, 'pairs': 0, 'nobs': 0, 'flush': 0, 'heels': 0}\n```\n\n### package summary\n\n#### base\nbase is for abstract classes which can be used on their own in\nsimple projects or subclassed to build more complex mechanics.\n\nA `CardProperty` is a category a card can belong to, like \"spade\"\nor \"three\" or \"green\" or \"flying.\" This base class only has a name;\nsubclass it to add other attributes, or just to have a new type\nfor easy comparison.\n\n`Card` is a placeholder, which provides a basic equality test to\nits subclasses.\n\n`Hand` is a container for storing cards. It behaves like a list in\nthat it can be indexed or sliced, and implements the standard list\nmethods as well as these:\n* `.shuffle()` is the opposite of `.sort()`.\n* `.deal(n)` removes the number of cards you specify and returns them\n as a new `Hand`.\n\n\n#### standard\nstandard implements the standard 52-card deck. It defines `Rank`\nand `Suit` as card properties, and a list of each: `RANKS` and\n`SUITS`. These lists define the sorting order for cards with those\nproperties. Specific ranks and suits can also be accessed as\nconstants--`TWO`, `QUEEN`, `HEART`, and so on.\n\n`StandardCard` is your normal playing card. It has a rank, a suit, and\na name. You can compare StandardCards to each other; cards with lower\nranks are less than cards with higher ranks, and a card with a lower\nsuit is less than a card with a higher suit and the same rank. (Aces\nare high in the default implementation. Ascending suit order is clubs,\ndiamonds, hearts, spades, following bridge.)\n\n`StandardHand` is what you hold StandardCards in. To Hand it adds a\ntidy string representation (as seen in the examples), and two more\nmethods:\n * `.by_rank(Rank)` returns a new StandardHand containing the cards\n from your hand which have the given rank. It does *not* remove them\n from your hand.\n * `.by_suit(Suit)` is the same thing but for suits.\n\nFinally, `make_deck()` is a top-level function which just creates a full\ndeck of cards, defined as one of each possible pair of the members of\nRANKS and SUITS. By default, it is returned still in order; pass\n`shuffle=True` to have it shuffled first.\n\n\n#### cribbage\ncribbage implements the hand-scoring rules of cribbage (but not the\nplay rules). Its main interface is `score_hand()`, which takes a\nStandardHand and returns a dictionary of (\"score-type\": points) pairs.\nYou can also pass it `turned=StandardCard` and the boolean arguments\n`crib` and `dealer` to cover all the scoring possibilities.\n\nscore_hand() has a series of helper functions which can be called\nindividually with a StandardHand: `score_fifteens()` etc. return\nintegers, and `check_flush()` returns a boolean. It also has the\n`value()` function, which takes a StandardCard and returns the point\nvalue of that card (for fifteens and the play).\n\n\n___\n\nI originally wrote this because I wanted to know what the cribbage\nscore for a whole deck of cards was. Now I can find out!\n\n```\n>>> from protocards import standard, cribbage\n>>>\n>>> def score_deck():\n... score = cribbage.score_hand(standard.make_deck())\n... for key, value in score.items():\n... if value:\n... print(\"{} for {:,}\".format(key, value))\n... print(\"total: {:,}\".format(sum(score.values())))\n... \n>>> score_deck()\nruns for 872,415,232\nfifteens for 34,528\npairs for 156\ntotal: 872,449,916\n```\n\nPlus 1-2 for heels/nobs, depending on the turned card and whether you're\ndealing.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/relsqui/protocards", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "protocards", "package_url": "https://pypi.org/project/protocards/", "platform": "", "project_url": "https://pypi.org/project/protocards/", "project_urls": { "Homepage": "https://github.com/relsqui/protocards" }, "release_url": "https://pypi.org/project/protocards/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "Basic tools for working with generic game cards in python.", "version": "0.1.2" }, "last_serial": 5361334, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "6a11e62de19733e08b25db9e7c1c0fcd", "sha256": "7e8bdf326a13507105e7ffba113b109ef57d6b01562355b67f30e72c14e02777" }, "downloads": -1, "filename": "protocards-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6a11e62de19733e08b25db9e7c1c0fcd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8527, "upload_time": "2019-06-05T06:35:52", "url": "https://files.pythonhosted.org/packages/92/ac/9a20ae54d75088780ca51b619879e7f3be5faac2a8e98c4cf6831b3752cb/protocards-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c505486104363a98a07b787dc0715ddb", "sha256": "a0744f6e08c76cfddbcca1531ceb6d89ffc8c6cbd0bc4a6266444abb7e6e5be2" }, "downloads": -1, "filename": "protocards-0.1.0.tar.gz", "has_sig": false, "md5_digest": "c505486104363a98a07b787dc0715ddb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8001, "upload_time": "2019-06-05T06:35:55", "url": "https://files.pythonhosted.org/packages/63/9a/f63ed8a5f79a93d9862177f2459e18ae3995218b5255997dbd8906f51e43/protocards-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "b48b0acdad7693df06be349e7a70696d", "sha256": "04368f958431e0f626ed94b166b5c7f0530a1dbedd9e9b64ce6908a8e3cea4e3" }, "downloads": -1, "filename": "protocards-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b48b0acdad7693df06be349e7a70696d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3965, "upload_time": "2019-06-05T06:47:33", "url": "https://files.pythonhosted.org/packages/b9/f9/6f042cbb7cb0c488879f80fee47bca203b8ad38378bd81e14ec450c64a28/protocards-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "949bc63e2aef48d1743af6d75ba8cdf5", "sha256": "a367ea0b253906daef0371210dbf6bdbf974084dc6195dd0d5ad6a2992120556" }, "downloads": -1, "filename": "protocards-0.1.1.tar.gz", "has_sig": false, "md5_digest": "949bc63e2aef48d1743af6d75ba8cdf5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3525, "upload_time": "2019-06-05T06:47:34", "url": "https://files.pythonhosted.org/packages/54/0f/8d1263db425d8f34f07b9231705d21733574460f54fe0b2accad61171068/protocards-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "87d5a8034ed9220cdc1b1773d1e77ca0", "sha256": "1d825bf6a847bc1820a5016ce759010602d858fc1102bb408c5122b73f0e2d30" }, "downloads": -1, "filename": "protocards-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "87d5a8034ed9220cdc1b1773d1e77ca0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11217, "upload_time": "2019-06-05T07:11:34", "url": "https://files.pythonhosted.org/packages/24/6d/8bfa0a3704183c2e5c96347eaa467a5774a34cce53b598bb56f61e6a5c1d/protocards-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "01f310603e0354e386bf7c4f2ba8a69f", "sha256": "0c44f9d3a7e7909c432eaea15a5a21cadbc64a5e0f39a7ed58e19b2fa4135d8c" }, "downloads": -1, "filename": "protocards-0.1.2.tar.gz", "has_sig": false, "md5_digest": "01f310603e0354e386bf7c4f2ba8a69f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10483, "upload_time": "2019-06-05T07:11:35", "url": "https://files.pythonhosted.org/packages/56/0b/9baf6998c2847fb357d1c1c72ef70fae019417951ec9e84823347980c726/protocards-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "87d5a8034ed9220cdc1b1773d1e77ca0", "sha256": "1d825bf6a847bc1820a5016ce759010602d858fc1102bb408c5122b73f0e2d30" }, "downloads": -1, "filename": "protocards-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "87d5a8034ed9220cdc1b1773d1e77ca0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11217, "upload_time": "2019-06-05T07:11:34", "url": "https://files.pythonhosted.org/packages/24/6d/8bfa0a3704183c2e5c96347eaa467a5774a34cce53b598bb56f61e6a5c1d/protocards-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "01f310603e0354e386bf7c4f2ba8a69f", "sha256": "0c44f9d3a7e7909c432eaea15a5a21cadbc64a5e0f39a7ed58e19b2fa4135d8c" }, "downloads": -1, "filename": "protocards-0.1.2.tar.gz", "has_sig": false, "md5_digest": "01f310603e0354e386bf7c4f2ba8a69f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10483, "upload_time": "2019-06-05T07:11:35", "url": "https://files.pythonhosted.org/packages/56/0b/9baf6998c2847fb357d1c1c72ef70fae019417951ec9e84823347980c726/protocards-0.1.2.tar.gz" } ] }