4 # :title: Greed dice game plugin for rbot
6 # Author:: Okasu <oka.sux@gmail.com>
8 # Distributed under the same license as rbot itself
19 def help(plugin, topic="")
20 "Simple dice game. Rules: https://en.wikipedia.org/wiki/Greed_(dice_game)"
24 [ [1,2,3,4,5,6], 1200 ],
25 [ [2,2,3,3,4,4], 800 ],
67 SCORING.each do |dice, dscore|
68 idx = remain.index(dice.first)
69 if idx and remain[idx,dice.size] == dice
70 groups << [dice, dscore]
81 mhash = {m.sourcenick => player[1]}
82 @scoreboard.merge! mhash
83 m.reply _("you rolled (%{roll}) for %{pts} points (%{groups})") % {
84 :roll => player[0].join(' '),
86 :groups => player[2].map { |d, s| "#{d.join(' ')} => #{s}"}.join(', ')
88 if params[:single] == "bot"
90 m.reply _("I rolled (%{roll}) for %{pts} points (%{groups})") % {
91 :roll => bot[0].join(' '),
93 :groups => bot[2].map { |d, s| "#{d.join(' ')} => #{s}"}.join(', ')
101 if @scoreboard.values.size == 2
102 m.reply _("%{who} wins!") % {
103 :who => @scoreboard.values[0] > @scoreboard.values[1] ?
104 @scoreboard.keys.first : @scoreboard.keys.last
112 plugin.map "greed :single", :action => :greed, :requirements => {:single => /bot/}, :thread => "yes"
113 plugin.map "greed", :action => :greed, :thread => "yes"