Skip to content

Commit

Permalink
Merge branch 'release/v0.4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
kobalab committed Mar 19, 2022
2 parents eadda95 + 1b981e2 commit 5908590
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 11 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### v0.4.5 / 2022-03-19

- examples を追加
- double_lizhi.js - ダブルリーチの好形率・和了率・平均打点
- @kobalab/majiang-core 0.2.1 → 0.2.4

### v0.4.4 / 2022-01-24

- examples を追加
Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
| after_lizhi.js | [先制リーチを受けた局の結果と収支](https://blog.kobalab.net/entry/2020/12/21/202933)
| trap_lizhi.js | [モロ引っ掛けの危険度](https://blog.kobalab.net/entry/2021/11/19/201332)
| dist_lizhi.js | [リーチ宣言牌および最初に切った数牌と同種の牌の危険度](https://blog.kobalab.net/entry/2021/11/21/121835)
| double_lizhi.js | [ダブルリーチの好形率・和了率・平均打点](https://blog.kobalab.net/entry/2022/03/19/124607)
56 changes: 56 additions & 0 deletions examples/double_lizhi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* ダブルリーチの好形率・和了率・平均打点
*/
"use strict";

const Majiang = require('@kobalab/majiang-core');

class AnaLog extends require('../') {

init() {
this._result = {
'好形': { lizhi: 0, hule: 0, defen: 0 },
'愚形': { lizhi: 0, hule: 0, defen: 0 },
};
}
qipai(qipai) {
this._game = { lizhi: [], diyizimo: true };
}
dapai(dapai) {
if (! this._game.diyizimo) return;
if (dapai.p.substr(-1) == '*') {
let shoupai = this.board.shoupai[dapai.l];
let n_tingpai = Majiang.Util.tingpai(shoupai)
.map(p => 4 - shoupai._bingpai[p[0]][p[1]])
.reduce((x, y)=> x + y, 0);
let form = n_tingpai >= 6 ? '好形' : '愚形';
this._game.lizhi[dapai.l] = form;
this._result[form].lizhi++;
}
if (dapai.l == 3) this._game.diyizimo = false;
}
fulou(fulou) {
this._game.diyizimo = false;
}
gang(gang) {
this._game.diyizimo = false;
}
hule(hule) {
let form = this._game.lizhi[hule.l];
if (form) {
this._result[form].hule++;
this._result[form].defen += hule.defen;
}
}
}

const yargs = require('yargs');
const argv = yargs
.usage('Usage: $0 <log-dir>')
.option('times', { alias: 't' })
.option('silent', { alias: 's', boolean: true })
.demandCommand(1)
.argv;
const filename = argv._[0];

console.log(AnaLog.analyze(filename, argv)._result);
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kobalab/majiang-analog",
"version": "0.4.4",
"version": "0.4.5",
"description": "電脳麻将牌譜解析ツール",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -31,6 +31,6 @@
"yargs": "^17.2.1"
},
"dependencies": {
"@kobalab/majiang-core": "^0.2.1"
"@kobalab/majiang-core": "^0.2.4"
}
}

0 comments on commit 5908590

Please sign in to comment.