Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

Commit

Permalink
Fix 🐛 #9 #13
Browse files Browse the repository at this point in the history
* 13飜と入力した時に1の位のみしか認識されていなかった問題を修正
* 翻の字と飜の字両方に対応
  • Loading branch information
ryosan-470 committed Jun 17, 2015
1 parent 8173fa7 commit 0967067
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scripts/mahjong.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,33 @@ hands = [

# 10の位を切り上げ
carry10 = (num) ->
Math.ceil(num / 100) * 100 # 少数にしてから小数点以下を切り捨てる
Math.ceil(num / 100) * 100 # 小数にしてから小数点以下を切り捨てる

# 1の位を切り上げ
carry1 = (num) ->
Math.ceil(num / 10) * 10 # 少数にしてから小数点以下を切り捨てる
Math.ceil(num / 10) * 10 # 小数にしてから小数点以下を切り捨てる

module.exports = (robot) ->
robot.hear /mahjong|麻雀|マージャン|まーじゃん/, (msg) ->
head = msg.random heads
hand = msg.random hands
msg.send "#{head} #{hand}"

robot.hear /(\d)翻(\d+)符/, (msg) ->
robot.hear /(\d+)(翻|飜)(\d+)符/, (msg) ->
han = parseInt(msg.match[1], 10)
hu = parseInt(msg.match[2], 10)
hu = parseInt(msg.match[3], 10)
if (hu <= 10 and 110 < hu) or (han == 1 and hu <= 20) or han < 1
msg.send "404 Not Found"
return

hu = carry1(hu) if hu != 25
parent_ron = 0
parent_tumo = 0
children_ron = 0
children_tumo4parent = 0
children_tumo4children = 0
if 1 <= han <= 4

if 1 <= han <= 4
basic_point = hu * (2 ** (han + 2))
if basic_point > 2000 then basic_point = 2000
children_tumo4children = carry10(basic_point * 1)
Expand Down

0 comments on commit 0967067

Please sign in to comment.