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

Commit

Permalink
4つの面子と雀頭を組み合わせて出力するように変更した #8
Browse files Browse the repository at this point in the history
  • Loading branch information
ryosan-470 committed Jun 15, 2015
1 parent 9115f08 commit 5978e6f
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions scripts/mahjong.coffee
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
# Description:
# 麻雀
# 麻雀
#
# Commands:
# :mahjong / 麻雀 という言葉に反応して役を返します.
# :point %d han / という言葉で得点計算をします
#
# Documentation:
# 麻雀の役を登録するルールとして雀頭が予め登録してあり面子4つと組み合わせて出力することにします.
# きちんと考えて書かないと字牌が5個とか出てしまうので考えてかいてください. (特に順子を追加するとき)
#
# 雀頭

This comment has been minimized.

Copy link
@ryosan-470

ryosan-470 Jun 15, 2015

Author Owner

雀頭はとりあえず字牌のみを用意(今のところ)

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 = [

This comment has been minimized.

Copy link
@ryosan-470

ryosan-470 Jun 15, 2015

Author Owner

25行目は雀頭1つと4つの面子の例
26行目は東3つが来れば役になるけどそうでないときは上がれない例

":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

This comment has been minimized.

Copy link
@ryosan-470

ryosan-470 Jun 15, 2015

Author Owner

これは要らないな

switch han
when 1
children_point = 1000
Expand Down

1 comment on commit 5978e6f

@bobkuro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ひとまずタンヤオ、清老頭、混老頭あたりじゃないですか??
書けるのかどうかわからんけど、
ifでstring(なのか?)1,9,ton,nan,sha,pe,haku,hatsu,chunのいずれかが入ってなかったらタンヤオみたいなさ。
その流れで清老頭、混老頭はタンヤオの2345678が入ってたらダメか、上の条件に合致する項目のみとか。

ここでみると、国士無双、字一色とか大四喜(なおアタマが1,9)とかいう問題が浮上してくるのでまた考えないといけないんですけど。
役満が変動しない(しにくい?)というか決まった点数、限定された手の内なので、そちらを実装してみては~~って話かも?

Please sign in to comment.