Skip to content

Commit

Permalink
Merge branch 'release/v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
kobalab committed Apr 8, 2023
2 parents fb88242 + 9085a3f commit 5a7132d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.1.0 / 2023-04-09

- #6 連風牌を2符とするルールを追加

### v1.0.2 / 2023-01-21

- 脆弱性警告に対応(json5 2.2.0 → 2.2.3)
Expand Down
6 changes: 4 additions & 2 deletions lib/hule.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function hule_mianzi(shoupai, rongpai) {
.concat(hule_mianzi_jiulian(new_shoupai, hulepai));
}

function get_hudi(mianzi, zhuangfeng, menfeng) {
function get_hudi(mianzi, zhuangfeng, menfeng, rule) {

const zhuangfengpai = new RegExp(`^z${zhuangfeng+1}.*$`);
const menfengpai = new RegExp(`^z${menfeng+1}.*$`);
Expand Down Expand Up @@ -257,6 +257,7 @@ function get_hudi(mianzi, zhuangfeng, menfeng) {
if (m.match(zhuangfengpai)) fu += 2;
if (m.match(menfengpai)) fu += 2;
if (m.match(sanyuanpai)) fu += 2;
fu = rule['連風牌は2符'] && fu > 2 ? 2 : fu;
hudi.fu += fu;
if (hudi.danqi) hudi.fu += 2;
}
Expand Down Expand Up @@ -694,7 +695,8 @@ function hule(shoupai, rongpai, param) {

for (let mianzi of hule_mianzi(shoupai, rongpai)) {

let hudi = get_hudi(mianzi, param.zhuangfeng, param.menfeng);
let hudi = get_hudi(mianzi, param.zhuangfeng, param.menfeng,
param.rule);
let hupai = get_hupai(mianzi, hudi, pre_hupai, post_hupai, param.rule);
let rv = get_defen(hudi.fu, hupai, rongpai, param);

Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* @kobalab/majiang-core v1.0.2
* @kobalab/majiang-core v1.1.0
*
* Copyright(C) 2021 Satoshi Kobayashi
* Released under the MIT license
Expand Down
1 change: 1 addition & 0 deletions lib/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = function(param = {}) {
/* 点数関連 */
'配給原点': 25000,
'順位点': ['20.0','10.0','-10.0','-20.0'],
'連風牌は2符': false,

/* 赤牌有無/クイタンなど */
'赤牌': { m: 1, p: 1, s: 1 },
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kobalab/majiang-core",
"version": "1.0.2",
"version": "1.1.0",
"description": "麻雀基本ライブラリ",
"publishConfig": {
"access": "public"
Expand Down
11 changes: 11 additions & 0 deletions test/hule.js
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,17 @@ suite('Majiang.Util', ()=>{

let hule;

suite('連風牌は2符', ()=>{
test('連風牌を2符とする', ()=>{
hule = Majiang.Util.hule(
Majiang.Shoupai.fromString(
'm123p123z1z1,s1-23,z555='),
null,
param({menfeng:0,
rule:Majiang.rule({'連風牌は2符':true})}));
assert.equal(hule.fu, 30);
});
});
suite('クイタンなし', ()=>{
test('クイタンは役とならない', ()=>{
hule = Majiang.Util.hule(
Expand Down

0 comments on commit 5a7132d

Please sign in to comment.