Skip to content

cmorley191/nothing-to-declare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nothing to Declare

Turn-based, multiplayer deception game that runs in your web-browser!

Players are international traders trying to move merchandise and make the most money. Contraband goods are worth the most, but they need to fool the customs officer player if they want a chance to sell them!

The client side of the game is hosted at cmorley191.github.io, but you will be prompted to connect to a game server address. Currently there is no "officially" hosted server, but you can host your own (see the Running The Game section below).

Screenshots - How to Play

The game has multiple rounds; one player is the "Officer" each round, while all the other players are "Traders" trying to get their merchandise past the Officer (or perhaps trying to bait the Officer into a trap!)

Step 1: Swap

Traders have a "hand" of merchandise. They can select one or more items from their hand to bring through customs that round.

However, before preparing their cart of merchandise, traders can first Swap out items from their hand to improve their options! In general, trying to gather a bunch of copies of one single type of merchandise will help you in the later steps:

Bob already has 3 Strawberries, so he throws out his Milk and Herbs to see if he can get a few more Strawberries! Unfortunately, no such luck this time: he found grapes and herbs instead.

Image example of Supply Contract Swap game phase

The game also has an optional, more complicated version of the Swap phase that lets you interact more with the other players via a "Community Pool". The host player can choose this mode in the game setup screen:

Strategic Swap Mode

Throwing out an item from your hand in a Simple Swap will remove it from the game. But recycling from your hand in Strategic Swap will instead put that item at the top of one of the "Urgent" columns, which other players can pull from. The mode adds an extra layer of depth to the game's strategy: sure, you might not want that Cheese, but perhaps you should hold on to it anyways to deny it from another player?

Trader Gabby currently has 2 Pigs, and she's spotted that another Trader has previously thrown out 2 more Pigs! (they're in one of the Urgent columns)

The Grapes in the Urgent column are higher priority, so she'll have to swap out 3 of her hand's merchandise to grab the Grapes and 2 Pigs from that column. She decides to swap out a fourth item for a random one, too.

Image example of Strategic-mode Supply Contract Swap game phase


Step 2: Prepare Cart

Traders now need to form a plan:

  • What merchandise should they bring through customs today?
  • Will they lie or be truthful in their statement to the customs officer?

Trader Gabby did really well when Swapping: she managed to get 5 Pigs in her hand! Her best move is probably to bring in those 5 Pigs and declare them honestly to the customs officer:

Image example of Preparing Cart game phase

Gabby could've tried to sneak in some Grapes alongside her Pigs, but she'd risk the Officer player calling her bluff!

Instead, by having a fully-honest declaration, Gabby can turn the tables! In the next step, she can try to trick the Officer into performing an unlawful search on her perfectly legal merchandise, earning her some extra compensation!

Step 3: Interrogation

After traders have packed their carts with merchandise, the Officer player runs the show! They can interrogate them about the contents that they claim to have.

If the Officer thinks they're being truthful, they are duty-bound to let them through the gate:

Officer Faith only knows that Gabby is claiming there are 5 Pigs in this crate. But Faith trusts Gabby, and decides that searching the cart isn't worth the risk of overstepping her authority. She lets Gabby through, and it's good that she did because Gabby was, indeed, being truthful!

Image example of an Interrogation that resulted in allowing the trader through the gate

However, if the officer suspects the trader is smuggling illegal merchandise, they should threaten to open the crate and issue a penalty! (the officer keeps the fine)

On the other hand, Faith can read right through Daniel's poker face. She doesn't believe he's actually carrying 5 Milk, and she's right! Daniel's swords are thrown out, and Faith fines him 4 Gold for smuggling!

Image example of an Interrogation that resulted in the crate being opened and its contents inspected

The player who makes the most money by the end of the game (by selling legal merchandise, smuggling illegal merchandise, collecting compensation, etc.) will be crowned the winner!

Running The Game

This project has two parts:

  • a backend Websocket-powered proxy server written in python
  • a static webpage frontend ("client") built by Node.js.

The client/frontend is already hosted at cmorley191.github.io!

However, github uses Secure-HTTPS, so your server will also need to be hosted securely / have an active TLS Certificate. If registering a certificate is a problem for you, you'll need to instead host both the client and server yourself, insecurely.

Server

The server requires python3 to be installed, as well as the websockets pip package.

pip install websockets

Run the server with:

py server/server.py

On first run, a configuration file will be generated in the same folder as the script. See discussion of config options below

Client

The latest client version is securely hosted at cmorley191.github.io -- your users can use that page to connect to your server.

If you need to host the client yourself, simply host the client/dist folder -- the client code is already pre-built in the repo in that folder.

Building the Client

If you need to make changes to the client code, you can re-build it with Node.js and the Node package manager npm

In the client folder, download dependency packages:

npm install

And build the project:

npm run build-dev

Then, open (or refresh) in browser: dist/index.html

When pushing to source control, please build the project in production mode first:

npm run build

Implementation notes

The project uses Typescript (strict), React, and Webpack. Pretty much no other packages of note.

Configuration

Secure

If your server has a registered TLS/SSL certificate, your setup will be very simple:

  1. Run the server once to generate the template config file
  2. Configure:
{
  "host_to_bind": "your.domain.example.com", 
  "insecure_enabled": false, 
  "secure_enabled": true, 
  "http_enabled": false, 
  "ports": {"wss": 9283}, 
  "ssl_cert": {
    "certfile": "/path/to/your.certfile.pem", 
    "keyfile": "/etc/ssl/your.domain.example.com/your.domain.example.com.key"
  }
}
  1. Properly port forward TCP/9283
  2. Run the server.
  3. Players can connect by typing your address in at cmorley191.github.io

Insecure

If you want to host the server without TLS, then you need to host both the server and the client without TLS.

Hosting the client is as simple as hosting the client/dist folder with your favorite hosting provider. The python provider is pretty easy to use:

cd client/dist
py -m http.server     # players access the game at http://youraddress:8000

And in a separate console, host the server:

  1. Run the server once to generate the template config file
  2. Configure:
{
  "host_to_bind": "your.domain.example.com", 
  "insecure_enabled": true,
  "secure_enabled": false,
  "http_enabled": false,
  "ports": {"ws": 9282},
  "ssl_cert": { "certfile": null, "keyfile": null }
}
  1. Properly port forward TCP/9282
  2. Run the server.
  3. Players first browse to http://youraddress:8000, then type in the server adddress your.domain.example.com

Other options

The http_enabled option is there simply to let you hack around expired certificates if needed. It opens a simple https server that hosts nothing. In a setup where the client is hosted securely (cmorley191.github.io) but the server certificate is expired/inactive, players can force their browsers to accept the bad certificate by first navigating to https://your.domain.example.com and using their browsers "I don't care if this page is trying to steal my information" button, and then trying to connect to the game. This approach is not recommended for obvious reasons.

You can technically put different port numbers in the server's "ports" but currently the client's connect ports are hardcoded -- there's no way to change them without rebuilding the client code.

About

Multiplayer Turn-based Deception Game in your browser

Resources

Stars

Watchers

Forks