From 5978e6f1ef6bf3a99769ad682211120b23ce4929 Mon Sep 17 00:00:00 2001 From: Ryosuke Sato Date: Mon, 15 Jun 2015 17:05:01 +0900 Subject: [PATCH] =?UTF-8?q?4=E3=81=A4=E3=81=AE=E9=9D=A2=E5=AD=90=E3=81=A8?= =?UTF-8?q?=E9=9B=80=E9=A0=AD=E3=82=92=E7=B5=84=E3=81=BF=E5=90=88=E3=82=8F?= =?UTF-8?q?=E3=81=9B=E3=81=A6=E5=87=BA=E5=8A=9B=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=9F=20#8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/mahjong.coffee | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/scripts/mahjong.coffee b/scripts/mahjong.coffee index 95ae6ab..0a07064 100644 --- a/scripts/mahjong.coffee +++ b/scripts/mahjong.coffee @@ -1,30 +1,42 @@ # Description: -# 麻雀 +# 麻雀 # # Commands: # :mahjong / 麻雀 という言葉に反応して役を返します. # :point %d han / という言葉で得点計算をします +# +# Documentation: +# 麻雀の役を登録するルールとして雀頭が予め登録してあり面子4つと組み合わせて出力することにします. +# きちんと考えて書かないと字牌が5個とか出てしまうので考えてかいてください. (特に順子を追加するとき) +# +# 雀頭 +heads = [ + ":hai-ton: :hai-ton:", # 東 + ":hai-sha: :hai-sha:", # 西 + ":hai-nan: :hai-nan:", # 南 + ":hai-pei: :hai-pei:", # 北 + ":hai-hatsu: :hai-hatsu:", # 発 + ":hai-chun: :hai-chun:", # 中 + ":hai-haku: :hai-haku:", # 白 +] + +# 役(面子が4つ) hands = [ - ":2so: :2so: :3so: :3so: :4so: :4so: :6so: :6so: :6so: :8so: :8so: :hai-hatsu: :hai-hatsu: :hai-hatsu:", - ":1man: :1man: :1man: :2man: :2man: :2man: :5so: :6so: :7so: :hai-ton: :hai-ton: :hai-ton: :hai-nan: :hai-nan:", - ":1pin: :1pin: :1pin: :1so: :2so: :3so: :4pin: :5pin: :6pin: :hai-nan::hai-nan::hai-nan: :hai-sha::hai-sha:", - ":9man: :1pin: :9pin: :1so: :9so: :hai-haku: :hai-hatsu: :hai-chun: :hai-ton: :hai-nan: :hai-sha: :hai-pei:", - ":1man: :9man: :1pin: :9pin: :1so: :9so: :hai-haku: :hai-hatsu: :hai-chun: :hai-ton: :hai-nan: :hai-sha: :hai-pei:", - ":1man: :9man: :1pin: :9pin: :1so: :9so: :hai-haku: :hai-hatsu: :hai-chun: :hai-ton: :hai-nan: :hai-sha: :hai-pei:", - ":1man: :9man: :1pin: :9pin: :1so: :9so: :hai-haku: :hai-hatsu: :hai-chun: :hai-ton: :hai-nan: :hai-sha: :hai-pei:", - ":1man: :1man: :1pin: :1pin: :1pin: :1so: :1so: :1so: :9man: :9man: :9man: :9pin: :9pin:", - ] + ":1man: :2man: :3man: :4man: :5man: :6man: :7man: :8man: :9man: :1so: :2so: :3so:", + ":hai-ton: :1man: :2man: :3man: :4man: :5man: :6man: :7man: :8man: :9man: :1so: :1so:", +] module.exports = (robot) -> robot.hear /mahjong|麻雀|マージャン|まーじゃん/, (msg) -> - msg.send msg.random hands + head = msg.random heads + hand = msg.random hands + msg.send "#{head} #{hand}" robot.hear /point (\d+) han/, (msg) -> han = parseInt(msg.match[1], 10) parent_point = 0 children_point = 0 - console.log han switch han when 1 children_point = 1000