{"id":24426078,"url":"https://github.com/bilbottom/playing-cards","last_synced_at":"2025-04-24T02:05:25.893Z","repository":{"id":271520859,"uuid":"850353907","full_name":"Bilbottom/playing-cards","owner":"Bilbottom","description":"Playing cards from the French-suited, standard 52-card pack.","archived":false,"fork":false,"pushed_at":"2025-04-09T08:05:40.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T02:05:21.198Z","etag":null,"topics":["python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bilbottom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-31T14:39:08.000Z","updated_at":"2025-04-09T08:05:42.000Z","dependencies_parsed_at":"2025-01-08T09:44:07.769Z","dependency_job_id":null,"html_url":"https://github.com/Bilbottom/playing-cards","commit_stats":null,"previous_names":["bilbottom/playing-cards"],"tags_count":2,"template":false,"template_full_name":"Bilbottom/python-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bilbottom%2Fplaying-cards","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bilbottom%2Fplaying-cards/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bilbottom%2Fplaying-cards/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bilbottom%2Fplaying-cards/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bilbottom","download_url":"https://codeload.github.com/Bilbottom/playing-cards/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250546077,"owners_count":21448260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python"],"created_at":"2025-01-20T11:15:34.007Z","updated_at":"2025-04-24T02:05:25.881Z","avatar_url":"https://github.com/Bilbottom.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n[![Python](https://img.shields.io/badge/Python-3.11+-blue.svg)](https://www.python.org/downloads/)\n[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)\n[![tests](https://github.com/Bilbottom/playing-cards/actions/workflows/tests.yaml/badge.svg)](https://github.com/Bilbottom/playing-cards/actions/workflows/tests.yaml)\n[![coverage](coverage.svg)](https://github.com/dbrgn/coverage-badge)\n[![GitHub last commit](https://img.shields.io/github/last-commit/Bilbottom/playing-cards)](https://shields.io/badges/git-hub-last-commit)\n\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Bilbottom/playing-cards/main.svg)](https://results.pre-commit.ci/latest/github/Bilbottom/playing-cards/main)\n\n\u003c/div\u003e\n\n---\n\n# Playing Cards 🃏\n\nPlaying cards from the French-suited, standard 52-card pack.\n\n## Installation ⬇️\n\nThis package is currently only available from GitHub:\n\n```\npip install git+https://github.com/Bilbottom/playing-cards@v0.0.3\n```\n\n## Usage 📖\n\nThis library provides classes to represent playing cards and decks of cards.\n\nImport the package and start using the classes. Here's an example of a simple game of _Red or Black_:\n\n```python\nimport playing_cards\n\n\ndef ask(choices: list[str]) -\u003e str:\n    \"\"\"Ask a question and return the user's choice.\"\"\"\n    question = f\"{', '.join(choices[:-1])} or {choices[-1]}? \"\n    while (choice := input(question).lower()) not in choices:\n        pass\n\n    return choice\n\n\ndef print_cards(cards: list[playing_cards.Card]) -\u003e None:\n    \"\"\"Print the faces of the cards in the list.\"\"\"\n    print(f\"[{', '.join(card.face for card in cards)}]\")\n\n\ndef red_or_black() -\u003e None:\n    \"\"\"Play a game of Red or Black.\"\"\"\n    deck = playing_cards.Deck()\n    cards = []\n\n    ###  red or black\n    colour_choice = ask([\"red\", \"black\"])\n    cards.append(deck.take_card()), print_cards(cards)\n    if cards[-1].colour != colour_choice:\n        print(\"Wrong colour. You lose!\")\n        return\n\n    ###  higher or lower (ties lose)\n    hl_choice = ask([\"higher\", \"lower\"])\n    cards.append(deck.take_card()), print_cards(cards)\n    is_higher = cards[-1].rank \u003e cards[-2].rank\n    is_lower = cards[-1].rank \u003c cards[-2].rank\n    if not (\n        (hl_choice == \"higher\" and is_higher)\n        or (hl_choice == \"lower\" and is_lower)\n    ):\n        print(\"Wrong direction. You lose!\")\n        return\n\n    ###  inside or outside (only inside is inclusive)\n    io_choice = ask([\"inside\", \"outside\"])\n    cards.append(deck.take_card()), print_cards(cards)\n    rank_min, rank_max = sorted([cards[-3].rank, cards[-2].rank])\n    is_inside = rank_min \u003c= cards[-1].rank \u003c= rank_max\n    if not (\n        (io_choice == \"inside\" and is_inside)\n        or (io_choice == \"outside\" and not is_inside)\n    ):\n        print(\"Wrong range. You lose!\")\n        return\n\n    ###  suit\n    suit_choice = ask(list(playing_cards.Suit))\n    cards.append(deck.take_card()), print_cards(cards)\n    if cards[-1].suit != suit_choice:\n        print(\"Wrong suit. You lose!\")\n        return\n\n    print(\"You win!\")\n\n\nif __name__ == \"__main__\":\n    red_or_black()\n```\n\n## Contributing\n\nInstall [uv](https://docs.astral.sh/uv/getting-started/installation/) and then enable [pre-commit](https://pre-commit.com/):\n\n```bash\nuv sync --all-groups\npre-commit install --install-hooks\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbilbottom%2Fplaying-cards","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbilbottom%2Fplaying-cards","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbilbottom%2Fplaying-cards/lists"}