Class: Plugins::RussianRoulette

Inherits:
Object
  • Object
show all
Includes:
Cinch::Helpers, Cinch::Plugin
Defined in:
lib/Zeta/plugins/russian_roulette.rb

Constant Summary collapse

PHRASES =
[
    "\"BANG\" You're dead! ... Just kidding comrade... for now.",
    "\"...BLAMMO!\" (hangfires are a bitch, aren't they?)",
    "Are you scared yet, comrade?",
    "Are you pissing your pants yet?",
    "You are lucky, comrade. At least for now.",
    "The chamber was as empty as your head.",
    "Damn. And I thought that it had bullet too.",
    "Lucky you, comrade.",
    "Must be your lucky day, comrade.",
    "\"BLAM!\" you can't play russian roulette with a tokarev, comrade.",
    "... Looks like you get to live another day... or 5 second.",
    "... Bad primer."
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cinch::Plugin

#check?, #log2chan

Constructor Details

#initialize(*args) ⇒ RussianRoulette

Returns a new instance of RussianRoulette.



28
29
30
31
# File 'lib/Zeta/plugins/russian_roulette.rb', line 28

def initialize(*args)
  super
  @games = []
end

Instance Attribute Details

#gamesObject (readonly)

Returns the value of attribute games.



11
12
13
# File 'lib/Zeta/plugins/russian_roulette.rb', line 11

def games
  @games
end

Instance Method Details

#russian(m, nick) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/Zeta/plugins/russian_roulette.rb', line 35

def russian(m, nick)
  #return m.reply "I am sorry comrade, but I do not have pistol on me." unless check_user(m.channel, @bot)
  return m.user.notice "Sorry comrade, but there is already game going on." if @games.include?(m.channel.name)

  # player setup
  player = User(nick) || m.user
  player = m.user if player == @bot
  # be nice, don't force the game on the starter unless the user actually exists in the channel.
  return m.reply "I am terribly sorry %s, but I don't know %s." % [m.user.nick, player.nick] unless m.channel.users.include?(player)

  # start game
  @games << m.channel.name

  turns, round_location = Array.new(2) { |i| Random.new.rand(1..6) }
  m.channel.action "starts a %d-turn game of Russian Roulette with %s." % [turns, player.nick]

  phrases = PHRASES.dup.shuffle

  sleep 5

  turns.times do |chamber|
    return end_game(m.channel, true) unless m.channel.users.include?(player)
    if round_location == chamber.succ
      m.reply "*click*"
      sleep 5
      m.channel.kick(player, "*BLAM*")
      m.reply "*BLAM*"
      m.channel.action "watches %s's brain splatter across the wall." % player.nick
      break
    else
      phrase = phrases.pop
      m.reply "*click* %s" % phrase
    end
    sleep 5
  end

  m.reply "Looks like you get to live another day." if turns < round_location
  sleep 1 if turns < round_location
  end_game(m.channel)
end