4 # :title: Greed dice game plugin for rbot
6 # Author:: Okasu <oka.sux@gmail.com>
8 # Distributed under the same license as rbot itself
20 def help(plugin, topic="")
21 "Simple dice game. Rules: https://en.wikipedia.org/wiki/Greed_(dice_game)"
25 [ [1,2,3,4,5,6], 1200 ],
26 [ [2,2,3,3,4,4], 800 ],
68 SCORING.each do |dice, dscore|
69 idx = remain.index(dice.first)
70 if idx and remain[idx,dice.size] == dice
71 groups << [dice, dscore]
82 mhash = {m.sourcenick => player[1]}
83 @players.push mhash.to_a[0][0]
84 if @players[-1] == @players[-2]
85 m.reply _("Oh you, %{who}! You can't go twice in a row!") % {:who => @players[-1]}
88 @scoreboard.merge! mhash
89 m.reply _("you rolled (%{roll}) for %{pts} points (%{groups})") % {
90 :roll => player[0].join(' '),
92 :groups => player[2].map { |d, s| "#{d.join(' ')} => #{s}"}.join(', ')
94 if params[:single] == "bot"
96 m.reply _("I rolled (%{roll}) for %{pts} points (%{groups})") % {
97 :roll => bot[0].join(' '),
99 :groups => bot[2].map { |d, s| "#{d.join(' ')} => #{s}"}.join(', ')
101 if player[1] < bot[1]
104 m.reply _("You win!")
109 if @scoreboard.values.size == 2
110 m.reply _("%{who} wins!") % {
111 :who => @scoreboard.values[0] > @scoreboard.values[1] ?
112 @scoreboard.keys.first : @scoreboard.keys.last
121 plugin.map "greed :single", :action => :greed, :requirements => {:single => /bot/}, :thread => "yes"
122 plugin.map "greed", :action => :greed, :thread => "yes"