From b38f1f43b156e6e92373325702a887fb44c88081 Mon Sep 17 00:00:00 2001 From: Shu YOKOYAMA Date: Wed, 13 Jan 2016 17:28:57 +0900 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E3=81=97=E6=BA=80=E8=B2=AB=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mjai/active_game.rb | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/mjai/active_game.rb b/lib/mjai/active_game.rb index 8db9730..de391be 100644 --- a/lib/mjai/active_game.rb +++ b/lib/mjai/active_game.rb @@ -245,7 +245,25 @@ def process_ryukyoku(reason, actors=[]) def process_fanpai() tenpais = [] tehais = [] + + is_nagashi = false + nagashi_deltas = [0,0,0,0] + for player in players + #流し満貫の判定 + if player.sutehais.size == player.ho.size && #鳴かれておらず + player.sutehais.all?{ |p| p.yaochu? } + is_nagashi = true + if player == self.oya + nagashi_deltas = nagashi_deltas.map{|i| i - 4000} + nagashi_deltas[player.id] += (4000 + 12000) + else + nagashi_deltas = nagashi_deltas.map{|i| i - 2000} + nagashi_deltas[player.id] += (2000 + 8000) + nagashi_deltas[self.oya.id] -= 2000 + end + end + if player.tenpai? tenpais.push(true) tehais.push(player.tehais) @@ -256,18 +274,23 @@ def process_fanpai() end tenpai_ids = (0...4).select(){ |i| tenpais[i] } noten_ids = (0...4).select(){ |i| !tenpais[i] } - deltas = [0, 0, 0, 0] - if (1..3).include?(tenpai_ids.size) - for id in tenpai_ids - deltas[id] += 3000 / tenpai_ids.size - end - for id in noten_ids - deltas[id] -= 3000 / noten_ids.size + + if is_nagashi + deltas = nagashi_deltas + else + deltas = [0, 0, 0, 0] + if (1..3).include?(tenpai_ids.size) + for id in tenpai_ids + deltas[id] += 3000 / tenpai_ids.size + end + for id in noten_ids + deltas[id] -= 3000 / noten_ids.size + end end end do_action({ :type => :ryukyoku, - :reason => :fanpai, + :reason => is_nagashi ? :nagashimangan : :fanpai, :tenpais => tenpais, :tehais => tehais, :deltas => deltas,