Don_Stewatd

Rbot Plugin for Blackjack

Apr 19th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. class RussianBlackjack < Plugin
  2.  
  3. def initialize
  4. super
  5. @player = 0
  6. @bot = 0
  7. end
  8.  
  9. def help(plugin, topic="")
  10. "Russian variant of Blackjack."
  11. end
  12.  
  13. def card_check(card)
  14. case card
  15. when 5..10
  16. card
  17. when 2
  18. "Jacket"
  19. when 3
  20. "Queen"
  21. when 4
  22. "King"
  23. when 11
  24. "Ace"
  25. end
  26. end
  27.  
  28. def game(m, params)
  29. if params[:stop] == "stop"
  30. if @player > @bot
  31. m.reply "You win!"
  32. @player = @bot = 0
  33. return
  34. end
  35. end
  36. player = bot = 0
  37. player = rand(2..11)
  38. @player += player
  39. m.reply "You have #{card_check(player)}. Total:#{@player}"
  40. if @bot == 0
  41. bot = rand(2..11)
  42. @bot += bot
  43. m.reply "I have #{card_check(bot)}. Total:#{@bot}"
  44. elsif rand(2) == 1
  45. bot = rand(2..11)
  46. @bot += bot
  47. m.reply "I have #{card_check(bot)}. Total:#{@bot}"
  48. else
  49. m.reply "Pass"
  50. end
  51. if @player > 21 && @bot < @player
  52. m.reply "You lost!"
  53. @player = @bot = 0
  54. end
  55. if @bot > 21 && @player < @bot || @player == 21
  56. m.reply "You win!"
  57. @player = @bot = 0
  58. end
  59. end
  60. end
  61.  
  62. plugin = RussianBlackjack.new
  63. plugin.map "rbj", :action => :game, :thread => "yes"
  64. plugin.map "rbj :stop", :action => :game, :requirements => {:stop => /stop/}, :thread => "yes"
Advertisement
Add Comment
Please, Sign In to add comment