Class: Cinch::Plugins::Roulette

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/roulette.rb

Overview

Roulette game

Instance Method Summary collapse

Instance Method Details

#rr(m) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 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) ⇒ Object



25
26
27
28
29
30
31
32
# 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