Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Roulette
- include Cinch::Plugin
- match /roulette/i, method: :roulette
- match /join/i, method: :join
- match /begin roulette/i, method: :start
- def roulette(m)
- @people_joined = [] if @people_joined.nil?
- unless @begun == true
- person = m.user.nick
- m.reply person + " has begun roulette! Type !join to join the round."
- @begun = true
- else
- m.reply "Roulette has already been started."
- end
- end
- def join(m)
- unless @begun == true
- unless @people_joined.include?(m.user.nick)
- @people_joined.push(m.user.nick)
- m.reply m.user.nick + " has joined the roulette."
- else
- m.reply m.user.nick + ", you've already joined this roulette game."
- end
- end
- end
- def start(m)
- @size = @people_joined.size
- @done = [] if @done.nil?
- if @size > 1
- while @people_joined.size > 1
- while !@done.include?(accused)
- accused = @people_joined[rand(@people_joined.size)]
- end
- bot.action(m.channel, "points the gun at " + accused + ".")
- case rand(3)
- when 0, 1
- bot.action(m.channel, "pulls the trigger, but it only clicks. " + accused + " gets out alive... For now.")
- when 2
- bot.action(m.channel, "shoots " + accused + ".")
- @done.push(accused)
- @people_joined.delete(accused)
- end
- end
- end
- winner = @people_joined[0]
- m.reply winner + " is the last man standing!"
- else
- m.reply "There aren't enough people."
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement