🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
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 - npm Package Compare versions

Comparing version
0.0.0
to
0.0.1
+21
LICENSE
MIT License
Copyright (c) 2020 takayama-lily
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+11
-11

@@ -9,3 +9,3 @@ 'use strict'

}
const check7 = (haiArr)=>{ //七対子形
const check7 = (haiArr)=>{
let arr = haiArr[0].concat(haiArr[1]).concat(haiArr[2]).concat(haiArr[3])

@@ -19,7 +19,7 @@ let s = 0

}
const check13 = (haiArr)=>{ //国士形
const check13 = (haiArr)=>{
let arr = [haiArr[0][0], haiArr[0][8], haiArr[1][0], haiArr[1][8], haiArr[2][0], haiArr[2][8]].concat(haiArr[3])
return arr.indexOf(0) == -1 && sum(arr) == 14
}
const check = (haiArr)=>{ //一般形
const check = (haiArr)=>{
const _check = (e, isJihai = false)=>{

@@ -84,3 +84,3 @@ let arr = e.concat()

}
const findKotus = (haiArr)=>{
const findKotsu = (haiArr)=>{
let res = []

@@ -141,3 +141,3 @@ for (let i in haiArr) {

let tmpHaiArr = JSON.parse(JSON.stringify(haiArr))
let firstRes = findKotus(tmpHaiArr).concat(j)
let firstRes = findKotsu(tmpHaiArr).concat(j)
if (sumAll(tmpHaiArr) === 2) {

@@ -154,3 +154,3 @@ res.push(firstRes.sort())

} else {
secondRes = secondRes.concat(findKotus(tmpHaiArr))
secondRes = secondRes.concat(findKotsu(tmpHaiArr))
res.push(secondRes.sort())

@@ -204,6 +204,6 @@ }

}
module.exports = findAllAgariPatterns
module.exports.check = check
module.exports.check7 = check7
module.exports.check13 = check13
module.exports.checkAll = checkAll
module.exports = findAllAgariPatterns //一般形限定
module.exports.check = check //一般形
module.exports.check7 = check7 //七対子形
module.exports.check13 = check13 //国士形
module.exports.checkAll = checkAll //全部形
{
"name": "agari",
"version": "0.0.0",
"description": "riichi mahjong (JP) agari calculation",
"version": "0.0.1",
"description": "Japanese riichi mahjong hand agari calculation",
"main": "index.js",

@@ -19,3 +19,3 @@ "scripts": {

"calculation",
"japan"
"Japan"
],

@@ -22,0 +22,0 @@ "author": "takayama <takayama@foxmail.com>",

+19
-15
## Agari
Riichi Mahjong hand agari calculation
麻雀アガリ和了形計算
Japanese riichi mahjong hand agari calculation

@@ -8,3 +9,2 @@ **Install with npm:**

```
**Usage:**

@@ -21,3 +21,3 @@ ```js

```
You will get an array result includes all the patterns of agari:
Output:
```js

@@ -28,10 +28,10 @@ [

[ '1m', '2m', '3m' ], //順子
[ '1p' ], //暗刻
[ '1s' ], //暗刻
[ '4m' ] //暗刻
[ '1p' ], //刻子
[ '1s' ], //刻子
[ '4m' ] //刻子
],
[
[ '1m' ], //暗刻
[ '1p' ], //暗刻
[ '1s' ], //暗刻
[ '1m' ], //刻子
[ '1p' ], //刻子
[ '1s' ], //刻子
[ '2m', '3m', '4m' ], //順子

@@ -42,7 +42,11 @@ '4m' //雀頭

```
"m,p,s,z" means "萬子,筒子,索子,字牌"
You will get an array result includes all the patterns of the agari.
"m,p,s,z" means "萬子,筒子,索子,字牌"
"1z-7z" means "東南西北白發中"
**Only check true or false:**
**Check only:**
```js
//check 一般型
const agari = require('agari')
//check 一般形
agari.check([

@@ -55,3 +59,3 @@ [3,1,1,1,2,1,1,1,3],

//check7 七対子型
//check7 七対子形
agari.check7([

@@ -64,3 +68,3 @@ [2,0,2,2,2,2,2,0,2],

//check13 国士型
//check13 国士形
agari.check13([

@@ -70,3 +74,3 @@ [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,1]
[1,1,1,1,2,1,1]
]) //return true

@@ -73,0 +77,0 @@