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) ⇒ Object



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
75
76
77
78
79
80
81
# File 'lib/Zeta/plugins/russian_roulette.rb', line 36

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

  # player zeta_setup
  player = 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 "takes #{player.nick} into the back room for a #{turns} turn game"
  m.action_reply "pulls out her pistol"
  # 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
      player.notice "*click*"
      sleep 5
      m.channel.kick(player, "*BLAM*")
      m.channel.action "walks back into the room *Alone*"
      break
    else
      phrase = phrases.pop
      player.notice "*click* %s" % phrase
    end
    sleep 5
  end

  if turns < round_location
    m.channel.action "walks back into the room with #{player}"
    m.reply "Looks like you get to live another day."
    m.channel.voice(player) # Voice the player because they survived
  end

  sleep 1 if turns < round_location
  end_game(m.channel)
end