Coder Social home page Coder Social logo

shit-happens's Introduction

PyPI Contributors Forks Stargazers Issues MIT License


Customized Shit Happens

Create your own Shit Happens playing cards!
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

Front.
Back.

Ever wanted to play with your own Shit Happens playing cards? Now you can. Write down the most miserable situations you can think of and rank them. This project automatically outputs playing cards in pdf format.

This project is not related to the original card game. Open an issue in case of any objections.

(back to top)

Built With

Python

(back to top)

Getting Started

Prerequisites

A virtual environment with python 3.11 or higher.

Installation

Run

pip install shithappens

from within the target environment.

To allow for pdf merging, run pip install shithappens[merge]. To show a progressbar, run pip install shithappens[pbar]. To install all dependencies, run pip install shithappens[all].

Installing for developers

Retrieve the latest version of the code

Developers should fork this repository and run

git clone https://github.com/<your-username>/shit-happens.git

This will place the sources in a directory shit-happens below your current working directory, set up the origin remote to point to your own fork, and set up the upstream remote to point to the shit-happens main repository. Change into this directory before continuing:

cd shit-happens

Create a dedicated environment

You should set up a dedicated environment to decouple your shithappens development from other Python and shithappens installations on your system.

The simplest way to do this is to use either Python's virtual environment venv or conda. Here, instructions for conda are shown. If mamba is installed, replace conda with mamba in the commands below.

conda env create -f environment.yml

Activate the environment using

conda activate shithappens-dev

Remember to activate the environment whenever you start working on shithappens.

Installing shithappens in editable mode

Install shithappens in editable mode from the shithappens directory using the command

python -m pip install -e .

The 'editable/develop mode', builds everything and places links in your Python environment so that Python will be able to import shithappens from your development source directory. This allows you to import your modified version of shithappens without re-installing after every change.

(back to top)

Usage

CLI

The tool is available as a command line interface (CLI). It requires an Excel file in the input directory (default current working directory). The excel files must have two columns with any header. The first column must contain the miserable situations. The second column must contain the corresponding misery indices. See the examples directory for an example.

usage: shithappens [-h] [-n NAME] [-m | --merge | --no-merge] [-s {front,back,both}] [-l {en,nl}] [-f {pdf,png}] [-r | --rank | --no-rank] [-w WORKERS] [-c CHUNKS] [input_dir]

help:
  -h, --help            show this help message and exit

input:
  input_dir             Input directory. Defaults to current working directory.

options:
  -n NAME, --name NAME  Expansion name. If no name is specified, infers name from input_dir.
  -m, --merge, --no-merge
                        Merge output. Defaults to --no-merge
  -s {front,back,both}, --side {front,back,both}
                        Side(s) to generate. Defaults to both.
  -l {en,nl}, --lang {en,nl}
                        Language. 'en' and 'nl' supported. Defaults to 'en'.
  -f {pdf,png}, --format {pdf,png}
                        Output format. 'pdf' and 'png' supported. Defaults to 'pdf'.
  -r, --rank, --no-rank
                        Rank situations and output in new file. Does not guarantee a linear ranking, i.e. situations can have equal misery index. Ignores all other options. Defaults to --no-rank.

multiprocessing:
  -w WORKERS, --workers WORKERS
                        Number of workers. Defaults to 4.
  -c CHUNKS, --chunks CHUNKS
                        Number of chunks for the workers to process. Defaults to 30.

The input directory must be structured as follows:

expansion
├───images
│   └───expansion-logo.*
├───outputs
│   ├───back
│   └───front
└───*.xlsx

If the output folder does not exist, it will be created. The format of the expansion logo must be on this list.

(back to top)

Contributing

Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the GPL-3.0 license. See LICENSE for more information.

(back to top)

Contact

Project Link: https://github.com/siemdejong/shit-happens

(back to top)

shit-happens's People

Contributors

siemdejong avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

krixby87 matdriks

shit-happens's Issues

Relative imports only fetch from a locally pip installed version

Describe the bug
import shithappens.sort_situations imports from a pip installed version, but during development, it is useful to let it do relative imports from a local tree.

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\siemd\mambaforge\envs\shithappens\Scripts\shithappens.exe\__main__.py", line 7, in <module>
  File "C:\Users\siemd\mambaforge\envs\shithappens\Lib\site-packages\shithappens\create_cards.py", line 648, in main_cli
    main()
  File "C:\Users\siemd\mambaforge\envs\shithappens\Lib\site-packages\shithappens\create_cards.py", line 604, in main
    from sort_situations import sort
ModuleNotFoundError: No module named 'sort_situations'

To Reproduce
Steps to reproduce the behavior:

  1. pip uninstall shithappens
  2. python src/shithappens/create_cards.py examples/example -r
  3. See error

Expected behavior
No ModuleNotFoundError given.

Additional context
Is a possible solution to use importlib.resources?

Managing fonts is ugly

The current way of managing fonts is ugly, it requires a new fm.FontProperties for everything that needs another weight of the Open Sans font. Is there a way to only specify one family (Open Sans) and use local files to find the font files?

After sorting, situations can have the same score

Is your feature request related to a problem? Please describe.
After sorting, situations can have the same score

Describe the solution you'd like
After sorting, situations all have different scores. Ideally, within a short amount of time.

Describe alternatives you've considered
Is Elo rating a good way to achieve this?

Move from argparse to click

Is your feature request related to a problem? Please describe.
Sorting the cards can be done with the command line, which is accessed by the sorting flag.
All other settings still need to be set, but will be disregarded.

Describe the solution you'd like
Using a cli where I do not need to set settings which will not be used anyway, because I want to sort the cards, not create them.

Describe alternatives you've considered
It is easier to separate sorting from creating cards with argparse subcommands.
This will make usage more straightforward.

Additional context
argparse.add_subparsers

Speed up card plotting

Plotting the cards and exporting them to pdfs takes a long time. Every card is independent, is it possible to make them concurrently, using multiple cores or threads?

Implement internationalization/localization

Misery index is English. If it is desired to make cards in another language, it could be done with a command line option, like

python create_cards.py -l nl

for Dutch (nl).

Can be implemented with the std library gettext.

Efficient sorting

Is your feature request related to a problem? Please describe.
With 200 cards, sorting becomes a very labour intensive with the currently implemented round-robin format. 100 comparisons need to be made to only divide the set in 2...

Describe the solution you'd like
An acceptable solution would be where sorting takes 1 minute per card maximum, but possibly quicker. Simple insertion sort would take about 1 minute.

Describe alternatives you've considered

Preseed:
Categorize every situation into 9 score groups. Random seed for situations per score group. (10s per card)

Monrad Swiss system:

  1. In every score group r1 is paired with r2 and r3 with r4, etc. (10s per comparison, effectively 5s per card.)
  2. Winners get one point, losers none.
  3. Recalculate score groups. Rank determined by score and previous rank as tiebreaker.
  4. Repeat N times (in total 5xNs per card)
    The complete procedure takes approx. 1 minute per card for N=9. Tiebreaker: sum of all opponent's scores (Bucholz chess rating)

Rules:

  • no rematches.

Additional context
https://en.wikipedia.org/wiki/Swiss-system_tournament

create standalone

Currently, the package can be installed using pip, but it would be even nicer to freeze the package to use is a standalone script, packaged with all the dependencies.

Move to CMYK

Is your feature request related to a problem? Please describe.
A black background will not be printed as black. The printing company suggest a very specific CMYK color for black. PIL allows for drawing images in CMYK mode, and thus specifying specific colors.

Describe the solution you'd like
A move to another library like PIL that can draw cards in CMYK mode, choosing specific CMYK colors for use with printing. Ideally with a CLI switch to turn CMYK color off/on.

Describe alternatives you've considered
PIL.Image.new() has a mode parameter that accepts cmyk. All colors can be specified with a cmyk tuple of four numbers.

Additional context
For larger areas with black, the CMYK color designer black (C70 M50 Y30 K100) is recommended by printenbind.nl.

Command line arguments are unclear

Is your feature request related to a problem? Please describe.
There are many different arguments available. Also, if -r/--rank is set, some other arguments are ignored.

Describe alternatives you've considered
Does it make sense to use subcommands? sort and create for sorting and creating the cards

Add bleed to the cards

Currently, the cards have sizes 62x88 mm (standard poker cards), but when cutting the cards to shape, a bleed with cutting marks is necessary.

Add a bleed of 5 mm with crop marks.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.