Coder Social home page Coder Social logo

shengji's Introduction

What is this?

ๅ‡็บง is a popular Chinese trick-taking playing card game. Rules are available here. Due to the COVID-19 shelter-in-place, I've been unable to play the this game in person... so I figured an online version would be worthwhile.

Usage:

cargo run

The server is a self-contained static binary and does not terminate TLS. It listens on 127.0.0.1:3030, and should only be exposed to an external network behind a proxy that supports both HTTP and WebSocket protocols (only tested with nginx).

Development

cd frontend && yarn watch
cd backend && cargo run --features dynamic

Generating JSON

A mapping of card data is generated from the server. It's checked in at src/generated/cards.json. To update it, start up the server and run

yarn download-cards-json

Prettier

To format frontend code:

# Dry-run/check
yarn prettier --check

# Fix files, will overwrite files
yarn prettier --fix

Lint

To run tslint:

yarn lint

Tests

To run tests:

yarn test

Technical details

The entire state of each game is stored in the memory of the server process. Restarting the game kicks all players, and games are automatically closed when all players have disconnected. The bulk of the game logic is implemented in the server, but players are expected to keep each other in check -- the server does not validate moves in their entirety.

For simplicity, the game is written in Rust and Javascript, linking in Warp as the WebSocket/HTTP server implementation and using React from a CDN.

Known issues

  • No mobile support
  • Incomplete validity checking for forced-plays
  • No player limit per game
  • No overall player limit

Demo

https://robertying.com/shengji/

shengji's People

Contributors

danwang avatar rbtying 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.