Skip to content

Commit

Permalink
鳴きを考慮するときに「ハイテイ牌は鳴けない」を考慮しないよう修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kobalab committed Jan 4, 2022
1 parent 9bc7ce6 commit 0c31150
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions legacy/player-0202.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,19 @@ module.exports = class Player extends Majiang.Player {

tingpai(shoupai) {

const get_peng_mianzi = (shoupai, p) =>
Majiang.Game.get_peng_mianzi(this._rule, shoupai, p);
const get_chi_mianzi = (shoupai, p) =>
Majiang.Game.get_chi_mianzi(this._rule, shoupai, p);

let n_xiangting = this.xiangting(shoupai);

let pai = [];
for (let p of Majiang.Util.tingpai(shoupai, (s)=>this.xiangting(s))) {

if (n_xiangting > 0) {

for (let m of this.get_peng_mianzi(shoupai, p+'+')) {
for (let m of get_peng_mianzi(shoupai, p+'+')) {
let new_shoupai = shoupai.clone().fulou(m);
if (this.xiangting(new_shoupai) < n_xiangting) {
pai.push(p+'+');
Expand All @@ -267,7 +272,7 @@ module.exports = class Player extends Majiang.Player {
}
if (pai[pai.length - 1] == p+'+') continue;

for (let m of this.get_chi_mianzi(shoupai, p+'-')) {
for (let m of get_chi_mianzi(shoupai, p+'-')) {
let new_shoupai = shoupai.clone().fulou(m);
if (this.xiangting(new_shoupai) < n_xiangting) {
pai.push(p+'-');
Expand Down
9 changes: 7 additions & 2 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,19 @@ module.exports = class Player extends Majiang.Player {

tingpai(shoupai) {

const get_peng_mianzi = (shoupai, p) =>
Majiang.Game.get_peng_mianzi(this._rule, shoupai, p);
const get_chi_mianzi = (shoupai, p) =>
Majiang.Game.get_chi_mianzi(this._rule, shoupai, p);

let n_xiangting = this.xiangting(shoupai);

let pai = [];
for (let p of Majiang.Util.tingpai(shoupai, (s)=>this.xiangting(s))) {

if (n_xiangting > 0) {

for (let m of this.get_peng_mianzi(shoupai, p+'+')) {
for (let m of get_peng_mianzi(shoupai, p+'+')) {
let new_shoupai = shoupai.clone().fulou(m);
if (this.xiangting(new_shoupai) < n_xiangting) {
pai.push(p+'+');
Expand All @@ -267,7 +272,7 @@ module.exports = class Player extends Majiang.Player {
}
if (pai[pai.length - 1] == p+'+') continue;

for (let m of this.get_chi_mianzi(shoupai, p+'-')) {
for (let m of get_chi_mianzi(shoupai, p+'-')) {
let new_shoupai = shoupai.clone().fulou(m);
if (this.xiangting(new_shoupai) < n_xiangting) {
pai.push(p+'-');
Expand Down

0 comments on commit 0c31150

Please sign in to comment.