diff --git a/data/rbot/plugins/games/uno.rb b/data/rbot/plugins/games/uno.rb index df6a1ee..7413117 100644 --- a/data/rbot/plugins/games/uno.rb +++ b/data/rbot/plugins/games/uno.rb @@ -162,6 +162,8 @@ def to_s # game start time attr :start_time + # time since current player's turn started + attr :turn_time # the IRC user that created the game attr_accessor :manager @@ -180,6 +182,7 @@ def initialize(plugin, channel, manager) @stock = [] make_stock @start_time = nil + @turn_time = nil @join_timer = nil @picker = 0 @last_picker = 0 @@ -338,6 +341,7 @@ def next_turn(opts={}) @players << @players.shift @player_has_picked = false show_turn unless opts[:silent] + @turn_time = Time.now end def can_play(card) @@ -728,6 +732,28 @@ def add_player(user) end end + def kick_player(nick) + unless p = get_player(nick) + announce _("%{p} isn't playing %{uno}") % { + :p => p, :uno => UNO + } + return + end + if not has_turn?(p.user) + announce _("it is not %{p}'s turn") % { + :p => p + } + return + end + if Time.now-@turn_time < 7*60 + announce _("%{p} has not idled long enough") % { + :p => p + } + return + end + drop_player(nick) + end + def drop_player(nick) # A nick is passed because the original player might have left # the channel or IRC @@ -1202,6 +1228,14 @@ def drop_player(m, p) @games[m.channel].drop_player(p[:nick] || m.source.nick) end + def kick_player(m, p) + unless @games.key?(m.channel) + m.reply _("There is no %{uno} game running here") % { :uno => UnoGame::UNO } + return + end + @games[m.channel].kick_player(p[:nick] || m.source.nick) + end + def print_stock(m, p) unless @games.key?(m.channel) m.reply _("There is no %{uno} game running here") % { :uno => UnoGame::UNO } @@ -1290,6 +1324,7 @@ def do_top(m, p) pg.map 'uno drop', :private => false, :action => :drop_player, :auth_path => 'manage::drop::self!' pg.map 'uno giveup', :private => false, :action => :drop_player, :auth_path => 'manage::drop::self!' pg.map 'uno drop :nick', :private => false, :action => :drop_player, :auth_path => 'manage::drop::other!' +pg.map 'uno kick :nick', :private => false, :action => :kick_player pg.map 'uno replace :old [with] :new', :private => false, :action => :replace_player, :auth_path => 'manage' pg.map 'uno transfer [game [ownership]] [to] :nick', :private => false, :action => :transfer_ownership, :auth_path => 'manage' pg.map 'uno stock', :private => false, :action => :print_stock