GithubHelp home page GithubHelp logo

alexandergw / royal-game-of-ur Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 465 KB

The royal game of Ur. Online multiplayer server/client. Written in Next.Js, TypeScript using WebSockets

License: GNU General Public License v3.0

JavaScript 2.17% SCSS 18.62% TypeScript 79.21%
nodejs websockets javascript-game royal-game-of-ur nextjs typescript typescript-nextjs

royal-game-of-ur's Introduction

Royal Game of Ur

Online multiplayer server (Node.Js) & client (Next.Js), written in TypeScript, using WebSockets, by Alexander Gailey-White

Game demo

Notes

  • Initial release
  • Server waits until two or more (even number of users) are connected, and spawns a game.

Rules

Rules based on reconstruction by Irving Finkel

  • Two players take turns rolling the dice
  • First player randomly selected
  • Pieces move around the board, through blue, up along red, then down into the green squares
  • Player moves one of their available pieces, based on dice roll (between 0-4)
  • Landing on a rosette (darker squares) grants another roll, maxiumum of three (3) per turn.
  • A player can attack opposing pieces within the red squares, resetting that piece back to square zero (0), unless opposing piece is on the rosette, in which they're protected from attack
  • To finish a piece; the roll must move (exactly) to square fifteen (15)
  • To win; a player must get all pieces to square fifteen (15)

Usage

pnpm run server [1337] to run Websocket server on optional port number (default 1337)

pnpm dev to dev build and run the Next.Js frontend. Warning, you may run into socket communication issues with double-render, try command below.

pnpm run serve to build and run a production version of the frontend.

Todo

  • Improve lobby/stats area
  • Server data persistance
  • Customise board size and piece count
  • Challenging - Allow players to challenge their next opponent
  • Scoring - Highscore, win-streak, etc
  • Experimental: StyleX, for eventual react-strict-dom
  • Improve graphics
  • Chatbox (maybe)

WSS NGINX proxy

Using NGINX create an HTTPS WSS proxy server to encrypt WebSocket traffic

server {
    listen 1337 ssl;
    
    ...
    
    location / {
        proxy_pass http://ws-backend;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }
}

upstream ws-backend {
    # enable sticky session based on IP
    ip_hash;

    # The port [1337] passed to the server.js
    # Run on custom server port so that it doesn't conflict with NGINX
    server 127.0.0.1:1337;
}

royal-game-of-ur's People

Contributors

alexandergw avatar dependabot[bot] avatar

Watchers

 avatar

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.