1
0
peddlers-of-ketran/README.md
James Ketrenos 32ba1c03b1 Updated install instructions as deployed on azurite
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
2022-03-14 11:23:20 -07:00

194 lines
3.7 KiB
Markdown

# Peddlers of Ketran
This project consists of both the front-end and back-end game
API server.
The front-end is launched from the 'client' directory in development mode via 'npm start'. In production, you build
it via 'npm build' and deploy the public front-end.
The back-end is launched out of the 'server' directory via 'npm start' and will
bind to the default port 8930.
If you change the default port of the REST API server, you will need to change
client/package.json's "proxy" value to reflect the new port change.
NOTE:
Board.js currently hard codes assetsPath and gamesPath to be absolute as the
dynamic router and resource / asset loading isn't working correctly.
## Building
### Native
#### Prerequisites
```bash
sudo apt-get install -y nodejs npm python
sudo -E npm install --global npm@latest
```
### In container
```bash
```
# Architecture
```plantuml
skinparam componentStyle rectangle
component "Server" as server
component "Resources" as res
component "Client" as client
component "Game" as game
component "Player" as player
package "Game" as game {
component Players as players
}
server <-> resource : serves to client
client <-> server
player <-> client
players -r-> player
server -> game
```
# Ketr.Ketran REST API
## POST /api/v1/game
### Request
```json
{}
```
### Response
```json
{
gameId: id
gameState: {
tiles: []
}
}
```
# Configuring / installing
## Build
```bash
git clone git.ketrenos.com:jketreno/peddlers-of-ketran.git
cd server
npm install
npm start &
cd ../client
npm install
npm start
```
## Install
```bash
export BASEPATH=${PWD}
# Ensure sudo has password ready
sudo -l
sudo rsync -avprl install/ /etc/
sudo touch /var/log/ketr-ketran.log
sudo chown system:adm /var/log/ketr-ketran.log
sudo systemctl daemon-reload
sudo systemctl restart rsyslogd
sudo systemctl restart logrotate
sudo systemctl restart ketr.ketran
```
Install the following into your nginx server configuration:
```nginx
location /ketr.ketran {
root /var/www/ketrenos.com;
index unresolvable-file-html.html;
try_files $uri @index;
}
# This seperate location is so the no cache policy only applies to the index and nothing else.
location @index {
root /var/www/ketrenos.com/ketr.ketran;
add_header Cache-Control no-cache;
expires 0;
try_files /index.html =404;
}
location /ketr.ketran/api {
proxy_pass http://192.168.1.78:8930;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass_header Set-Cookie;
proxy_pass_header P3P;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
```
Add security tokens in ketr.ketran/config/local.json:
```bash
cat << EOF > config/local.json
{
"tokens": [ {
"$(whoami)": "$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;)"
} ]
}
EOF
```
## Launch
```bash
sudo systemctl start ketr.ketran
```
## To test
### New game
```bash
curl -k -s -X POST http://localhost:8930/ketr.ketran/api/v1/games/
```
### Game status
```bash
curl -k -s -X GET http://localhost:8930/ketr.ketran/api/v1/games/:id
```
# States
Chat is available at all times by registered players
## Lobby
* Register session+name
* Register session with color
* Unregister player+name from color
* Roll dice for player position
* Shuffle board
* Set "Ready" for player
* All ready? state == active
## License attribution
The dice faces (dice-six-faces-*.svg) are Copyright https://delapouite.com/ and licensed
as [CC-BY-3.0](https://creativecommons.org/licenses/by/3.0/).
## Active
*