Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toymak3r/tarot
Coding experiment with Tarot
https://github.com/toymak3r/tarot
Last synced: about 1 month ago
JSON representation
Coding experiment with Tarot
- Host: GitHub
- URL: https://github.com/toymak3r/tarot
- Owner: toymak3r
- License: mit
- Created: 2023-09-21T08:46:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-07T07:03:46.000Z (8 months ago)
- Last Synced: 2024-06-08T08:03:37.027Z (8 months ago)
- Language: Python
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Tarot
![coverage](https://raw.githubusercontent.com/toymak3r/tarot/main/coverage.svg)
## Summary
The `Tarot` class is used to generate a library of tarot cards from a given deck directory. It provides methods to generate the library, save it to a file, load it from a file, draw cards from the library, show the image of a card, and retrieve the hierarchy and card name from a file name.
## Example Usage
```python
# Create an instance of the Tarot class with the deck directory
tarot = Tarot(deck_directory)# Generate the library of tarot cards
tarot.generate_library()# Save the library to a file
tarot.save_library()# Load the library from a file
tarot.load_library()# Draw a specified number of cards from the library
tarot.draw(number)# Show the image of a card
tarot.show(card)# Retrieve the hierarchy and card name from a file name
hierarchy, card_name = tarot.retrieve_name(file_name)
```## Code Analysis
### Main functionalities
The main functionalities of the `Tarot` class are:
- Generating a library of tarot cards from a given deck directory
- Saving the library to a file
- Loading the library from a file
- Drawing a specified number of cards from the library
- Showing the image of a card
- Retrieving the hierarchy and card name from a file name___
### Methods
The `Tarot` class has the following methods:
- `__init__(self, deck_directory: str)`: Initializes the class with the deck directory
- `generate_library(self, path: str = '') -> str`: Generates a library of tarot cards and returns it as a JSON string
- `save_library(self)`: Saves the library to a file
- `load_library(self)`: Loads the library from a file
- `retrieve_name(self, file: str) -> str`: Retrieves the major or minor hierarchy and card name from a given file name
- `draw(self, number=1)`: Randomly draws a specified number of cards from the library
- `show(self, card)`: Shows the image of a card___
### Fields
The `Tarot` class has the following fields:
- `deck_directory`: The directory path where the tarot card images are located
- `library_file`: The file path of the library file
- `drawn_cards`: A list to store the drawn cards from the library
- `library`: The library of tarot cards as a JSON string___