This is a Mahjong score calculation library.
If a pat is made from the entered values, the name of the role and its score are displayed.
It is released under the MIT license, so please use it within the scope of your own responsibility.
The default rule is the following. If you change it, please call corresponding function. (For the detail, please refer Function Description section)
- No red tiles
- Enable kuitan
- No round up mangan
- No basengo
- No double yakuman in kokushi-muso thirteen-sided wait
- No double yakuman in churen-poto nine-sided wait
- No double yakuman in daisushi
- No double yakuman in suanko one-side wait
The tehai array indicates the hand of Mahjong. The size of array is MJSCORE_INPUT_TEHAI_NUM (41).
- Only non-fuuro tiles are included.
- Agari tiles are also included.
- Unused tiles must be set to 0.
Array index | Hand's type |
---|---|
0 | undefined |
1 to 9 | 1 to 9 of Manzu |
10 | undefined |
11 to 19 | 1 to 9 of Pinzu |
20 | undefined |
21 to 29 | 1 to 9 of Sozu |
30 | undefined |
31 | East |
32 | South |
33 | West |
34 | North |
35 | Haku |
36 | Hatsu |
37 | Chun |
38 | Red 5 of Manzu |
39 | Red 5 of Pinzu |
40 | Red 5 of Sozu |
The fuuro array indicates the fuuro tiles. The size of array is MJSCORE_INPUT_FUURO_NUM (20).
Array index | Description |
---|---|
0 + 4*n | The type of fuuro (0 = no fuuro, 1 = pon, 2 = chi, 3 = ankan, 4 = minkan, 5 = kakan) |
1 + 4*n | The smallest tile number of its sets |
2 + 4*n | The called tile number of its sets |
3 + 4*n | The type of the other called house that relative to that person (1 = lower house, 2 = facing, 3 = upper house) |
The dora array indicates the dora tiles. The size of array is MJSCORE_INPUT_DORA_NUM (11).
Array index | Hand's type |
---|---|
0 | The number of dora display tiles |
1 to 5 | 1st to 5th dora display tile |
6 to 10 | 1st to 5th "ura" dora display tile |
Enable or disable red tiles in rule
Enable or disable kuitan in rule
Enable or disable round up mangan in rule
Enable or disable basengo in rule
Enable or disable double yakuman in kokushi-muso thirteen-sided wait in rule
Enable or disable double yakuman in churen-poto nine-sided wait in rule
Enable or disable double yakuman in daisushi in rule
Enable or disable double yakuman in suanko one-side wait in rule
Input tehai
Input fuuro
Input dora
Input jikaze
Input bakaze
Input winning tile
Input whether tumo or not. True is tumo, false is ron.
Input how many places
Input whether deposition reach or not
Input the number of dora
Input whetehr riichi or not
Input whether tenho or not
Input whether tiho or not
Input whether double richi or not
Input whether ippatu or not
Input whether tyankan or not
Input whether rinsyankaiho or not
Input whether nagashimangan or not
Input whether haitei or not
Perform calculation
Get error code.
Error Code | Desription |
---|---|
-1 | uncalculating |
0 | success |
1 | invalid input data (non furo tiles + the number fuuro * 3 isn't 14 or the elements of tehai have less than 0 or greater than 5) |
2 | invalid input data (No information on winning tile or no winning tile in hand) |
3 | invalid input data (no finished) |
4 | invalid input data (no information of bakaze or jikaze) |
5 | invlaid input data (called and reached) |
6 | no tile combination |
Get score in case of Parent's ron
Get score in case of Parent's tumo
Get score in case of Child's ron
Get score in case of Child's tumo to Parent
Get score in case of Child's tumo to other child
Get fu nunber
Get fan number
Get final score the parent receives in case of ron
Get final score the child receives in case of ron
Get final score the parent receives in case of tumo
Get final score the child receives in case of tumo
Get yaku table array. The size of array is 60.
Get yaku name array. The size of array is 20.
Get the number of dora
Get the number of "ura" dora
Get the number of akadora
Get whether mangan or not
Get each sets after evaluation
Clear the state
Clear the state without rule
This library is based on the following source code. Thanks to cmj3-san!
http://cmj3.web.fc2.com/index.htm#mjscore