Giter Club home page Giter Club logo

codebreaker-game's Introduction

codebreaker-game

Decrypto-like multiplayer online browser game

It uses Vue.js for reactive pages.

The current page can be seen here: https://loomie.github.io/codebreaker-game/

Here is a screenshot how it might look: screenshot of the ui

Glossary

Code : Three numbers that denote the position of a keyword for which a hint must be given. For example 312 means the first hint must relate to the third keyword, second hint is for the first keyword and last hint is for the second keyword.

Encoder : The player who gives hints in the current round.

Guess : One number of the code. One guess is given for each hint to reconstruct the code used by the encoder.

Hint : A related word for a specific keyword. It describes/encodes one keyword so the own team can guess it but hopefully the other team can not.

Keyword : One of the four fixed words for which hints must be given to guess them.

Round : The game is played in multiple rounds. Each round consists of multiple steps that are went through: A code is generated for each team, Encoder gives hints for that code to her team, each team guesses the code based on the hints for both teams, the original code is revealed and compared to the guesses and finally the result is checked if the game ends or continues with the next round.

Configuration

Language of keywords

To determine which language will be used for the keywords, the environment variable LANG must be set when starting the server. The first two letters are used for choosing a word list.

# Linux/macOS
export LANG="de_DE.UTF-8"
; Windows PowerShell
$env:LANG="de_DE.UTF-8"

The following languages are currently available:

  • de
  • en (default)

To customize the wordlist look at the files server/wordlist_*.mjs.

Installation

To run the game a central server is needed. It hosts the web pages and connects the players.

Requirements

For the server part node.js must be installed. For the development version git is recommended. But the files can be downloaded directly form GitHub.

As an alternate the server can be run with Docker. You need docker to be installed in this case. See below for instructions to run the game server.

Setup

To setup the server just clone the git repository. Change to the folder server and initialize the project:

npm install

You need a TLS (SSL) certificate for HTTP/2 (HTTPS). Put a link to your certificate chain and key file as cert.pem and key.pem in the folder server/.

You can configure on which port the server runs with the environment variable CODEBREAKER_PORT (default: 12034).

Start

The server runs on port 12034 by default. So point your browser to https://<yourserver>:12034/. You can change the port by setting the environment variable CODEBREAKER_PORT.

Background service (daemon)

It is recommended to manage the service with systemd. A template service file is included. You need to create a copy and modify the path and maybe user name.

cd codebreaker-game/server
cp codebreaker.service.template codebreaker.service
nano codebreaker.service
sudo ln -s codebreaker.service /etc/systemd/system/
sudo systemctl daemon-reload
# autostart on boot
sudo systemctl enable codebreaker

Afterwards you can start and stop the service with

sudo systemctl start codebreaker
sudo systemctl stop codebreaker

Foreground

To run the process in the foreground:

cd codebreaker-game/server
npm start

Background one shot (Linux)

To run the process in the background just append an ampersand. To read the output redirect it into a log file:

node server.mjs >server.log &

Stop

To stop the service run sudo systemctl stop codebreaker. To stop the foreground server press CTRL + C.

Recommendation

Use a separate user to run the process. For linux create a system user without a login (needs root privileges). You need to start the server with a privileged user who changes to the dedicated system user. That is what systemd does for you.

# create system user
adduser --system --group codebreakeruser
# download game
su -s /bin/sh -c 'git clone https://github.com/Loomie/codebreaker-game.git' - codebreakeruser
# setup service as described above with the created user
# start the server in background (one shot)
systemctl start codebreaker

Instead of calling su for each step you can get an interactive shell with su -s /bin/bash - codebreakeruser

Use a free HTTPS certificate from Let's Encrypt by using certbot on your server. Because the game runs as a separate user you have to give it access to the private key. You have to change the group of the key file to your codebreakeruser (primary) group.

# change group of private key and certificate files if your domain is 'example.com'
chgrp -R codebreakeruser /etc/letsencrypt/archive/example.com
# allow the group to read the private key
chmod g+r /etc/letsencrypt/archive/example.com/privkey1.pem
# tell codebreaker to use the letsencrypt files
su -s /bin/sh -c 'cd codebreaker-game/server && ln -s /etc/letsencrypt/live/example.com/cert.pem cert.pem' - codebreakeruser
su -s /bin/sh -c 'cd codebreaker-game/server && ln -s /etc/letsencrypt/live/outstare.de/privkey.pem privkey.pem' - codebreakeruser

Docker

All the setup is done in a Docker container. It needs a certificate and private key for secure connections (HTTPS) as stated in the section "Setup".

To build the docker image locally run the following after your setup is done (in main folder of this project):

docker build --rm -t codebreakergame:latest .

To run the docker image in a container you need to provide the certificate and key file. Also set a local port where the game is reachable, like 4321 below:

docker run --init -d -v <your/path/to/privkey.pem>:/usr/games/codebreaker/server/privkey.pem -v <your/path/to/cert.pem>:/usr/games/codebreaker/server/cert.pem -p 4321:12034 --name codebreakergame codebreakergame:latest

Access the game on your machine like https://localhost:4321

To stop the so started container run

docker stop codebreakergame

To start again:

docker start codebreakergame

codebreaker-game's People

Contributors

loomie avatar manquqhapaq avatar

Stargazers

 avatar  avatar

Watchers

 avatar

codebreaker-game's Issues

Show author of hint

In the columns with the hints of previous round the author should be visible. It is useful when thinking about the keyword as the author may relate words to specific schemes.

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.