-RouletteHistory = Struct.new("RouletteHistory", :games, :shots, :deaths, :misses, :wins)
+define_structure :RouletteHistory, :games, :shots, :deaths, :misses, :wins
class RoulettePlugin < Plugin
- BotConfig.register BotConfigBooleanValue.new('roulette.autospin',
+ Config.register Config::BooleanValue.new('roulette.autospin',
:default => true,
:desc => "Automatically spins the roulette at the butlast shot")
- BotConfig.register BotConfigBooleanValue.new('roulette.kick',
+ Config.register Config::BooleanValue.new('roulette.kick',
:default => false,
:desc => "Kicks shot players from the channel")
+ Config.register Config::BooleanValue.new('roulette.twice_in_a_row',
+ :default => false,
+ :desc => "Allow players to go twice in a row")
def initialize
super
reset_chambers
@players = Array.new
+ @last = ''
end
def help(plugin, topic="")
totals = RouletteHistory.new(0,0,0,0,0)
end
+ if @last == m.sourcenick and not @bot.config['roulette.twice_in_a_row']
+ m.reply "you can't go twice in a row!"
+ return
+ end
+
+ @last = m.sourcenick
unless @players.include?(m.sourcenick)
@players << m.sourcenick
playerdata.games += 1
end
playerdata.shots += 1
totals.shots += 1
-
+
shot = @chambers.pop
if shot
m.reply "#{m.sourcenick}: chamber #{6 - @chambers.length} of 6 => *BANG*"
totals.wins += 1
@registry["player " + plyr] = pdata
}
- @players = Array.new
+ @players.clear
+ @last = ''
@bot.kick(m.replyto, m.sourcenick, "*BANG*") if @bot.config['roulette.kick']
else
m.reply "#{m.sourcenick}: chamber #{6 - @chambers.length} of 6 => +click+"
@registry["player " + m.sourcenick] = playerdata
@registry["totals"] = totals
-
+
if shot || @chambers.empty?
reload(m)
elsif @chambers.length == 1 and @bot.config['roulette.autospin']
totals.games += 1
@registry["totals"] = totals
- @players = Array.new
+ @players.clear
+ @last = ''
end
def spin(m, params={})