Skip to content

Commit

Permalink
流し満貫に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
yokoyama10 committed Jan 13, 2016
1 parent 3bd4cde commit b38f1f4
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions lib/mjai/active_game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down

0 comments on commit b38f1f4

Please sign in to comment.