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

Commit

Permalink
テスト環境からマージ Close #8, #14
Browse files Browse the repository at this point in the history
  • Loading branch information
ryosan-470 committed Jun 18, 2015
1 parent 8eb0a45 commit e1e97a9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Please refer to the [guide](https://github.com/jtwp470/gochiusa-bot/issues/12) o

* @dorapon2000
* [点数計算機能の追加](https://github.com/jtwp470/gochiusa-bot/pull/13)

* @index30, @sga0221
* [麻雀役を出力する機能の追加](https://github.com/jtwp470/gochiusa-bot/issues/14)
## License
The MIT License (MIT)

Expand Down
64 changes: 31 additions & 33 deletions scripts/mahjong.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ carry10 = (num) ->
# 1の位を切り上げ
carry1 = (num) ->
Math.ceil(num / 10) * 10 # 小数にしてから小数点以下を切り捨てる

module.exports = (robot) ->
robot.hear /mahjong|麻雀|マージャン|まーじゃん/, (msg) ->
kaze = (n1,n2) ->
Expand All @@ -41,11 +41,11 @@ module.exports = (robot) ->
when 1 then msg.send "自風:東"
when 2 then msg.send "自風:南"
when 3 then msg.send "自風:北"
else msg.send "自風:西"
#牌のカウント
else msg.send "自風:西"
# 牌のカウント
jhcount = [0,0,0,0,0,0,0]
hcount = [[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]]
#ドラ設定
# ドラ設定
dorandam = Math.floor(Math.random()*4)+1
if dorandam == 1
doj = Math.floor(Math.random()*7)+1
Expand All @@ -59,12 +59,12 @@ module.exports = (robot) ->
doh = dora-1
hcount[domsp][doh] = hcount[domsp][doh]+1
msg.send "ドラ:#{hands1[domsp][doh]}"
#雀頭生成
#雀頭選択用乱数生成1(字牌か数牌か)
# 雀頭生成
# 雀頭選択用乱数生成1(字牌か数牌か)
headra = Math.floor(Math.random() * 4)+1
#雀頭選択用乱数生成2(字牌を選んだ場合)
# 雀頭選択用乱数生成2(字牌を選んだ場合)
headrb = Math.floor(Math.random() * 7)+1
#雀頭選択用乱数生成3(数牌を選んだ場合)
# 雀頭選択用乱数生成3(数牌を選んだ場合)
headrc = Math.floor(Math.random() * 9)+1
hb = headrb-1
hc = headrc-1
Expand All @@ -78,44 +78,42 @@ module.exports = (robot) ->
jhcount[heb] = jhcount[heb]+2
else
hms = Math.floor(Math.random()*3)+1
hmsp = hms-1
hmsp = hms-1
loop
hbodyrc = Math.floor(Math.random() * 9)+1
hc = hbodyrc-1
break unless hcount[hmsp][hc] >= 3
head1 = hands1[hmsp][hc].concat(hands1[hmsp][hc])
hcount[hmsp][hc] = hcount[hmsp][hc]+2

#場風、自風の設定(関数呼び出し)
# 場風、自風の設定(関数呼び出し)
bakaze = Math.floor(Math.random() * 100)+1
mykaze = Math.floor(Math.random() * 4)+1
kaze.call(null,bakaze,mykaze)
#makebody!
#body!

# makebody!
# body!
body = []
finalbody = []
#順子にするのか刻子にするのかの乱数生成


#字牌の場合の乱数生成
#bodyrb = Math.floor(Math.random() * 7)+1
#数牌の場合の乱数生成
# 順子にするのか刻子にするのかの乱数生成
# 字牌の場合の乱数生成
# bodyrb = Math.floor(Math.random() * 7)+1
# 数牌の場合の乱数生成
bodyrc = Math.floor(Math.random() * 9)+1
bb = bodyrb-1
bc = bodyrc-1
count = [0,0,0,0,0]

for i in [0..3]
j = 5
j = 5
j = j - i
sork = Math.floor(Math.random() * 2)+1
na = Math.floor(Math.random()*5)+1
naki = na-1
#乱数の生成(字牌にするか数牌にするか)
# 乱数の生成(字牌にするか数牌にするか)
bodyra = Math.floor(Math.random() * 4)+1
switch sork
#刻子の場合
# 刻子の場合
when 1
ms = Math.floor(Math.random()*3)+1
msp = ms-1
Expand All @@ -142,16 +140,16 @@ module.exports = (robot) ->
else
hand2 = hands1[msp][bb].concat(hands1[msp][bb].concat(hands1[msp][bb]))
body = body.concat(hand2)
#順子の場合
# 順子の場合
else
ms1 = Math.floor(Math.random()*3)+1
msp1 = ms1-1
loop
#選択した牌の番号
# 選択した牌の番号
tbodyrb = Math.floor(Math.random() * 7)+1
#選択した牌の一つ前の牌の番号
# 選択した牌の一つ前の牌の番号
tbb = tbodyrb-1
#選択した牌の一つ後の牌の番号
# 選択した牌の一つ後の牌の番号
tbb1 = tbodyrb+1
break unless hcount[msp1][tbodyrb] >= 4 || hcount[msp1][tbb] >= 4 || hcount[msp1][tbb1] >= 4
hcount[msp1][tbodyrb] = hcount[msp1][tbodyrb]+1
Expand All @@ -162,14 +160,14 @@ module.exports = (robot) ->
else
hand2 = hands1[msp1][tbb].concat(hands1[msp1][tbodyrb].concat(hands1[msp1][tbb1]))
body = body.concat(hand2)
#鳴きの判定
b1 = body.shift()#i=3
b2 = body.shift()#i=2
b3 = body.shift()#i=1
b4 = body.shift()#i=0

# 鳴きの判定
b1 = body.shift()# i = 3
b2 = body.shift()# i = 2
b3 = body.shift()# i = 1
b4 = body.shift()# i = 0
msg.send "#{head1} #{b1} #{b2} #{b3} #{b4}"

robot.hear /(\d+)(翻|飜)(\d+)符/, (msg) ->
han = parseInt(msg.match[1], 10)
hu = parseInt(msg.match[3], 10)
Expand Down

0 comments on commit e1e97a9

Please sign in to comment.