Skip to content

Contributor's Guide

James Craster edited this page Jun 14, 2020 · 7 revisions

Building OpenWerewolf from source

For Ubuntu 20.04:

sudo apt update
sudo apt upgrade
sudo apt install curl
sudo apt install git

#install python2 (needed for node in ubuntu 20.04)
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install python2

#installing node 10x from PPA
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

#install openwerewolf
git clone https://www.github.com/JamesCraster/OpenWerewolf.git/
cd OpenWerewolf
npm install
sudo npm install -g sass
npm run build
sudo apt-get install redis-server
npm run start debug

then visit localhost:8081 and it runs!

Instructions for other systems in general:

Clone the repository:

   git clone https://www.github.com/JamesCraster/OpenWerewolf
   cd OpenWerewolf

Now install Node.js for your platform (the LTS version is recommended.)
Then install Redis for your platform (the 'stable' version is recommended)
Now install development prerequisites using npm (you can paste these into your terminal):

   sudo npm install -g typescript
   sudo npm install -g sass
   sudo npm install -g typedoc
   sudo npm install -g babel-cli babel-preset-react
   sudo npm install -g webpack-cli

Then run within the OpenWerewolf directory to install dependencies:

  npm install

Now build and run OpenWerewolf:

  npm run build
  npm start

Now navigate to localhost:8081 and OpenWerewolf is running!

Useful Scripts

   npm run build       - this builds OpenWerewolf
   npm run watch       - this builds and runs OpenWerewolf, and rebuilds and restarts whenever it detects 
                         changes
   npm run watch:debug - watches OpenWerewolf in 'debug mode' which reduces turn timers, 
                         allows multiple players in a single browser
   npm run watch:database - watches OpenWerewolf in 'database mode' which runs the database, allowing 
                            logins/registers
   npm run start (or start:debug or start:database) - runs OpenWerewolf (in the respective mode)
   npm run release - creates release zip which can be distributed (delete the release folder afterwards or it 
                     will create compile errors!)
   npm run builddocs - builds the Typedoc documentation 
   npm run test - runs tests, you will need Selenium Webdriver and broken-link-checker (on npm)

Mobile Client

To build the local multiplayer mobile client, cd Mobile and npm run build, then visit localhost:8081/mobile (any mobile device will be automatically redirected to this)

Technologies

Backend

The backend of OpenWerewolf is written entirely in Typescript, using Node.js, express to serve static assets, and socket.io to send data between the client and server. The markup is written in Pug. I use express-session and connect-redis to store sessions. The database is MySQL. Bcrypt is used to encrypt passwords.

Frontend

The desktop client of OpenWerewolf is also written in Typescript and uses Semantic UI, Sass, JQuery, React and socket.io. The mobile client is written using Semantic-UI-React, create-react-app and socket.io.

Documentation

The documentation is written using Typedoc. Run npm run builddocs to generate documentation.