Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.51 KB | None | 0 0
  1. class Roulette
  2.   include Cinch::Plugin
  3.   match /roulette/i, method: :roulette
  4.   match /join/i, method: :join
  5.   match /begin roulette/i, method: :start
  6.   def roulette(m)
  7.     @people_joined = [] if @people_joined.nil?
  8.     unless @begun == true
  9.       person = m.user.nick
  10.       m.reply person + " has begun roulette! Type !join to join the round."
  11.       @begun = true
  12.     else
  13.       m.reply "Roulette has already been started."
  14.     end
  15.   end
  16.   def join(m)
  17.     unless @begun == true
  18.     unless @people_joined.include?(m.user.nick)
  19.       @people_joined.push(m.user.nick)
  20.       m.reply m.user.nick + " has joined the roulette."
  21.     else
  22.       m.reply m.user.nick + ", you've already joined this roulette game."
  23.     end
  24.   end
  25.   end
  26.  
  27.   def start(m)
  28.     @size = @people_joined.size
  29.     @done = [] if @done.nil?
  30.     if @size > 1
  31.     while @people_joined.size > 1
  32.       while !@done.include?(accused)
  33.       accused = @people_joined[rand(@people_joined.size)]
  34.       end
  35.       bot.action(m.channel, "points the gun at " + accused + ".")
  36.       case rand(3)
  37.         when 0, 1
  38.           bot.action(m.channel, "pulls the trigger, but it only clicks. " + accused + " gets out alive... For now.")
  39.         when 2
  40.           bot.action(m.channel, "shoots " + accused + ".")
  41.           @done.push(accused)
  42.           @people_joined.delete(accused)
  43.         end
  44.       end
  45.     end
  46.     winner = @people_joined[0]
  47.     m.reply winner + " is the last man standing!"
  48.   else
  49.     m.reply "There aren't enough people."
  50.   end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement