class Cinch::Plugins::Roulette

Roulette game

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/cinch/plugins/roulette.rb, line 16
def initialize(*args)
  super
  @shells = {}
  @shot = {}
end

Public Instance Methods

rr(m) click to toggle source
# File lib/cinch/plugins/roulette.rb, line 35
def rr(m)
  # just starting?
  @shells[m.channel] = 6 if @shells[m.channel].nil?
  @shot[m.channel] = rand(1..@shells[m.channel]) if @shot[m.channel].nil?

  shooter = m.user.nick
  # Cheating in the console
  lines = '=' * 10
  puts "#{lines}\nShells left: #{@shells[m.channel]}"
  puts "Hot shot: #{@shot[m.channel]}\n#{lines}"

  if @shot[m.channel] == @shells[m.channel]
    @shells[m.channel] = 6
    @shot[m.channel] = rand(1..@shells[m.channel])
    m.reply 'Bang!'
    m.channel.kick(shooter, 'Bad luck, you\'re dead!')
    sleep(2)
    m.action_reply 'reloads the revolver and spins the chamber!'
  else
    m.reply 'Click!'
    @shells[m.channel] -= 1
  end
end
spin(m) click to toggle source
# File lib/cinch/plugins/roulette.rb, line 25
def spin(m)
  @shells[m.channel] = 6
  @shot[m.channel] = rand(1..@shells[m.channel])
  lines = '=' * 10
  puts "#{lines}\nShells left: #{@shells[m.channel]}"
  puts "Hot shot: #{@shot[m.channel]}\n#{lines}"
  m.action_reply 'spins the chamber!'
end