A scoring app for playing majong using "Chinese classical" rules

React is loading all the necessary code

Unless, of course, you're blocking JavaScript. Then the app will never load

How to use this app

This app has been designed for use while playing, requiring one person to keep score as players reveal tiles and declare wins. Each player has five sets that can be filled out while playing, using the numbers 1 through 9 for numeric tiles and the letters [e], [s], [w], [n], [c], [f], and [p] for the four winds and the three dragons. For numeric tiles, the suits are indicated with the suit buttons next to the input field (these will automatically "click" if you type a numeric hand with a suit letter anywhere in it; suit letters are "c", "b", and "d" for characters, bamboo, and dots respectively). To mark a set as concealed, use the "..." button, or use the "!" character in the input field to toggle visibility.

Note that kongs have special "conceal" rules: a self drawn kong is concealed, and recorded as the relevant tile four times, and the concealed button pressed. If a kong was formed by drawing a tile and adding it to an already played pung, record it by adding the fourth tile to the pung's pattern. However, if a kong is formed by claiming a discard, with a concealed pung in hand, the fact that the pung was concealed can be recorded by recording the kong as unconcealed (which it is), but clicking the tiles. This will flip three of them to show that the pung was concealed, even if the kong is on the table now. This is important for evaluating hands for the "three concealed triplets" bonus.

To score a hand after someone has declared a win, simply make sure all tiles have been chronicled, and that the winner's special win conditions have been marked. Then hit the "score" button, and the app should score everyone, process the balances, and move the app over to the next turn, with the winds rotated appropriately.

If a player declares a win without having a winning hand, the "illegal win declaration!" button can be used. This processes the associated penalty and resets the hand. Should a player commit a "nine tile error", click its button for the offending player, then score hands regularly. The scoring algorithm will take the nine tile error into account.

Limit hands are not automatically detected - you will have to pick the appropriate limit hand from the list of limit hands for the winning player.

Scores are listed below the main UI area, newest score on top with the scores arranged in the same order as the players are. By default only the total number of points won/list per hand are shown, but these values can be clicked to reveal detailed win/loss information such as hand tiles, points for patterns, doubles, etc.

If you want to start a game with scores and winds written down from some previous, unfinished game, you can use the "Advance hand" button to move the game forward until you get the right combination (it looks disabled; it is not). In order to set the scores to what they were in your old game, click the player's score and type in a new number. If you do this by accident, cancel or OK will both leave the score as it was before. The number of wins can be changed in the same way.

The app currently only supports Chinese Classical rules, however the code has been structured in such a way as to allow additional rulesets to be encoded without having to fiddle with any other aspects of the app. If you are interested in helping write additional rulesets, head on over to the github project page and file an issue for the ruleset you wish to help with, or hit me up on twitter. I'd love to hear from you!