]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
uno plugin: game starter how has temporary full uno::manage permissions for the game
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 14 Apr 2008 17:58:31 +0000 (19:58 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 14 Apr 2008 17:58:31 +0000 (19:58 +0200)
data/rbot/plugins/games/uno.rb

index 8fd0d087547ac9cd7ead4ba7fa30a22d05450586..5ae780c7e199cc5d17a4c16ee21e3d3035af0d4e 100644 (file)
@@ -160,7 +160,10 @@ class UnoGame
   # number of cards to be picked if the player can't play an appropriate card
   attr_reader :picker
 
-  def initialize(plugin, channel)
+  # the IRC user that created the game
+  attr_reader :manager
+
+  def initialize(plugin, channel, manager)
     @channel = channel
     @plugin = plugin
     @bot = plugin.bot
@@ -178,6 +181,7 @@ class UnoGame
     @picker = 0
     @last_picker = 0
     @must_play = nil
+    @manager = manager
   end
 
   def get_player(user)
@@ -888,10 +892,14 @@ class UnoPlugin < Plugin
 
   def create_game(m, p)
     if @games.key?(m.channel)
-      m.reply _("There is already an %{uno} game running here, say 'jo' to join in") % { :uno => UnoGame::UNO }
+      m.reply _("There is already an %{uno} game running here, managed by %{who}. say 'jo' to join in") % {
+        :who => @games[m.channel].manager,
+        :uno => UnoGame::UNO
+      }
       return
     end
-    @games[m.channel] = UnoGame.new(self, m.channel)
+    @games[m.channel] = UnoGame.new(self, m.channel, m.source)
+    @bot.auth.irc_to_botuser(m.source).set_temp_permission('uno::manage', true, m.channel)
     m.reply _("Ok, created %{uno} game on %{channel}, say 'jo' to join in") % {
       :uno => UnoGame::UNO,
       :channel => m.channel
@@ -969,6 +977,7 @@ class UnoPlugin < Plugin
       pstats[k] = pls
     end
 
+    @bot.auth.irc_to_botuser(@games[channel].manager).reset_temp_permission('uno::manage', channel)
     @games.delete(channel)
   end