🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

agari

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agari

Japanese riichi mahjong agari calculation

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
146
-23.96%
Maintainers
1
Weekly downloads
 
Created
Source

Agari

麻雀アガリ和了形計算
Japanese riichi mahjong hand agari calculation

Install with npm:

# npm i agari

Use in browser:

<script src="https://cdn.jsdelivr.net/npm/agari"></script>

Usage:

const agari = require('agari')
let hai = [
    [3,1,1,3,0,0,0,0,0], //萬子
    [3,0,0,0,0,0,0,0,0], //筒子
    [3,0,0,0,0,0,0,0,0], //索子
    [0,0,0,0,0,0,0]      //字牌
]
console.log(agari(hai))

Output:

[
    //和了形1
    [
        '1m', //雀頭
        [ '1m', '2m', '3m' ], //順子
        [ '1p' ], //刻子
        [ '1s' ], //刻子
        [ '4m' ]  //刻子
    ],
    //和了形2
    [
        [ '1m' ], //刻子
        [ '1p' ], //刻子
        [ '1s' ], //刻子
        [ '2m', '3m', '4m' ], //順子
        '4m' //雀頭
    ]
]

"m,p,s,z" means "萬子,筒子,索子,字牌"
"1z-7z" means "東南西北白發中"

Check only:

const agari = require('agari')

//check 一般形
agari.check([
    [3,1,1,1,2,1,1,1,3],
    [0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0]
]) //return true

//check7 七対子形
agari.check7([
    [2,0,2,2,2,2,2,0,2],
    [0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0]
]) //return true

//check13 国士形
agari.check13([
    [1,0,0,0,0,0,0,0,1],
    [1,0,0,0,0,0,0,0,1],
    [1,0,0,0,0,0,0,0,1],
    [1,1,1,1,2,1,1]
]) //return true

//check all types
agari.checkAll([
    [1,1,1,1,1,0,0,0,0],
    [0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0]
]) //return boolean

Keywords

riichi

FAQs

Package last updated on 24 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts