Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RussianBlackjack < Plugin
- def initialize
- super
- @player = 0
- @bot = 0
- end
- def help(plugin, topic="")
- "Russian variant of Blackjack."
- end
- def card_check(card)
- case card
- when 5..10
- card
- when 2
- "Jacket"
- when 3
- "Queen"
- when 4
- "King"
- when 11
- "Ace"
- end
- end
- def game(m, params)
- if params[:stop] == "stop"
- if @player > @bot
- m.reply "You win!"
- @player = @bot = 0
- return
- end
- end
- player = bot = 0
- player = rand(2..11)
- @player += player
- m.reply "You have #{card_check(player)}. Total:#{@player}"
- if @bot == 0
- bot = rand(2..11)
- @bot += bot
- m.reply "I have #{card_check(bot)}. Total:#{@bot}"
- elsif rand(2) == 1
- bot = rand(2..11)
- @bot += bot
- m.reply "I have #{card_check(bot)}. Total:#{@bot}"
- else
- m.reply "Pass"
- end
- if @player > 21 && @bot < @player
- m.reply "You lost!"
- @player = @bot = 0
- end
- if @bot > 21 && @player < @bot || @player == 21
- m.reply "You win!"
- @player = @bot = 0
- end
- end
- end
- plugin = RussianBlackjack.new
- plugin.map "rbj", :action => :game, :thread => "yes"
- plugin.map "rbj :stop", :action => :game, :requirements => {:stop => /stop/}, :thread => "yes"
Advertisement
Add Comment
Please, Sign In to add comment