|
1 | 1 | # Codenames |
| 2 | + |
2 | 3 | <a href="https://www.buymeacoffee.com/schluggi" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/white_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a> |
3 | 4 |
|
| 5 | +I like the game cardboard game [codenames](https://en.wikipedia.org/wiki/Codenames_\(board_game\)) and now that COVID-19 is part of our life I have played a lot online with my friends on [this](https://www.horsepaste.com/) website. But I realized that I want to play codename pictures instead. So I've decided to create my own. |
4 | 6 |
|
5 | | -I like the game cardboard game [codenames](https://en.wikipedia.org/wiki/Codenames_\(board_game\)) and now that COVID-19 is |
6 | | -part of our life I have played a lot online with my friends on [this](https://www.horsepaste.com/) website. But I |
7 | | -realized that I want to play codename pictures instead. So I've decided to create my own. |
| 7 | +# Features |
8 | 8 |
|
9 | | -## Features |
10 | 9 | - Realtime online multiplayer |
11 | 10 | - Multiple game modes: |
12 | 11 | - Codename classic (with words) |
13 | | - - Codename pictures |
| 12 | + - Codename pictures |
14 | 13 | - Does not include any images (for copyright reasons, but you can import your own) |
15 | | -- Just like the codenames board game... |
16 | | - |
17 | | -## Requirements |
18 | | -- Python >= 3.6 |
19 | | -- [Almost every](https://docs.sqlalchemy.org/en/13/core/engines.html#database-urls) database engine is supported (SQLite |
20 | | - in memory by default) |
21 | | - |
22 | | -## Installation & Quickstart |
23 | | -1. Clone this repo |
24 | | -2. Create a virtualenv and join them |
25 | | -3. Install python requirements |
26 | | - ```shell script |
27 | | - $ pip3 install -r requirements.txt |
28 | | - ``` |
29 | | -4. Generate text images (for the classic mode) |
30 | | - ```shell script |
31 | | - $ ./words2img/words2img.py |
32 | | - ``` |
33 | | - Optional: [Import images](https://github.com/Schluggi/codenames#import-images) for picture mode |
34 | | -5. Configuration |
35 | | - - 5.1 Create a secret key by running `python3 -c "import os; print(os.urandom(24).hex())"` and insert that key into the |
36 | | -`config.py` |
37 | | -6. Test your setup by running `flask run` |
38 | | -7. If everything works as expected, you should now be able to play at `http://localhost:5000` |
39 | | - |
40 | | -## Configuring |
41 | | -### Add new words or languages |
| 14 | +- Just like the codenames board game but online |
| 15 | + |
| 16 | +# Quickstart |
| 17 | + |
| 18 | +## Docker |
| 19 | + |
| 20 | +```commandline |
| 21 | +docker run -p 5000:5000 -e GAME_MODES="pictures,classic_de,classic_en,classic_en-undercover" <placeholder>:latest |
| 22 | +``` |
| 23 | + |
| 24 | +## Git |
| 25 | + |
| 26 | +```commandline |
| 27 | +git clone git@github.com:Schluggi/codenames.git |
| 28 | +cd codenames |
| 29 | +python3 -m venv .venv |
| 30 | +source .venv/bin/activate |
| 31 | +pip install -r requirements.txt |
| 32 | +python3 ./words2img/words2img.py |
| 33 | +flask --app codenames run |
| 34 | +``` |
| 35 | + |
| 36 | +Optional: [Import images](https://github.com/Schluggi/codenames#import-images) for picture mode |
| 37 | + |
| 38 | +# Configuring |
| 39 | + |
| 40 | +## Environment variables |
| 41 | + |
| 42 | +| name | Description | required | default | |
| 43 | +|------------|------------------------------------------------|----------|------------------------------------------------------| |
| 44 | +| GAME_MODES | A comma separated list of available game modes | No | pictures,classic_de,classic_en,classic_en-undercover | |
| 45 | +| SECRET_KEY | A secret key to encrypt the user sessions | No | \<a random key will be created\> | |
| 46 | + |
| 47 | +## Add new words or languages |
| 48 | + |
42 | 49 | In this example we'll add france as language for the classic mode. |
43 | 50 |
|
44 | 51 | 1. Create a language file: `./words2img/words/fr.txt` (one word each line) |
45 | 52 | 2. Run the script (existing files will be overwritten) |
46 | | - ```shell script |
47 | | - $ python3 ./words2img/words2img.py |
| 53 | + ```commandline |
| 54 | + python3 ./words2img/words2img.py |
48 | 55 | ``` |
49 | | -3. Append `classic_fr` to the `GAME_MODES` list in the `config.py` |
| 56 | +3. Append `classic_fr` to your `GAME_MODES` environment variable |
| 57 | +
|
| 58 | +## Import images |
50 | 59 |
|
51 | | -### Import images |
52 | 60 | To get the best experience it's recommend to buy the original cardboard game and scan all images. In my case I scanned |
53 | | -all pictures with 400dpi and used [picpunch](https://github.com/Schluggi/picpunch) to cut them to size and render for |
| 61 | +all pictures with 400dpi and used [picpunch](https://github.com/Schluggi/picpunch) to cut them to size and render for |
54 | 62 | web (`--border 5 --quallity 30`).The new images have to be placed into the corresponding folders. |
55 | 63 |
|
56 | 64 | The code images into (at least 20): |
| 65 | +
|
57 | 66 | - `codenames/static/images/codes` |
58 | 67 |
|
59 | 68 | And the colored team cards (at least 1 each): |
60 | | -- `codenames/static/images/cards/assassin` |
| 69 | +
|
| 70 | +- `codenames/static/images/cards/assassin` |
61 | 71 | - `codenames/static/images/cards/blue` |
62 | 72 | - `codenames/static/images/cards/neutral` |
63 | 73 | - `codenames/static/images/cards/red` |
64 | 74 |
|
65 | 75 | The filename does not matter. But the file extension and type has to be JPEG/JPG. |
66 | 76 |
|
67 | | -### Apache2 with mod_wsgi |
68 | | -`flask run` works fine but you should'nt use it for production deployment. However you can use Apache2 instead. |
69 | | -If not already installed you have to install `libapache2-mod-wsgi-py3`. After installation you can create a virtualhost |
70 | | -like in this example: |
71 | | -
|
72 | | -``` |
73 | | -<VirtualHost *:80> |
74 | | - ServerName codenames.example.org |
75 | | - Redirect / https://codenames.example.org/ |
76 | | -</VirtualHost> |
77 | | -
|
78 | | -<VirtualHost *:443> |
79 | | - ServerName codenames.example.org |
80 | | - |
81 | | - WSGIDaemonProcess wsgi_codenames user=www-data group=www-data processes=1 threads=5 python-home=python-home=/virtualenvs/codenames/ |
82 | | - WSGIScriptAlias / /var/www/codenames/wsgi.py |
83 | | -
|
84 | | - SSLEngine On |
85 | | - SSLCertificateFile /etc/letsencrypt/live/codenames.example.org/cert.pem |
86 | | - SSLCertificateKeyFile /etc/letsencrypt/live/codenames.example.org/privkey.pem |
87 | | - SSLCertificateChainFile /etc/letsencrypt/live/codenames.example.org/chain.pem |
88 | | - SSLProtocol ALL -SSLv2 -SSLv3 |
89 | | - SSLHonorCipherOrder On |
90 | | - SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES: |
91 | | - SSLCompression Off |
92 | | - Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" |
93 | | -
|
94 | | - <Directory /var/www/codenames/> |
95 | | - WSGIProcessGroup wsgi_codenames |
96 | | - WSGIApplicationGroup %{GLOBAL} |
97 | | - </Directory> |
98 | | -</VirtualHost> |
99 | | -``` |
100 | | -I use Let's Encrypt for free ssl certificates. Please ensure that all paths are correct. After restating Apache2, |
101 | | -codenames should be run as part of the Apache2-daemon. |
| 77 | +# Credits |
102 | 78 |
|
103 | | -## Credits |
104 | 79 | Created and maintained by Schluggi. |
0 commit comments