Closed Jammer2omega closed 11 years ago
class Deck attr_accessor :deck attr_accessor :num_decks
def initialize(decks=1) @num_decks = decks self.send('generate') end
def draw() hand = @deck.pop(5) p hand if @deck.length() <= 5 self.send('generate') end return hand.join(" ") end
def drawe() hand = @deck.pop(@value) p hand if @deck.length() <= 5 self.send('generate') end return hand.join(" ") end
def draw1()
hand = @deck.pop(1)
p hand
if @deck.length() <= 5
self.send('generate')
end
return hand.join(" ")
end
def draw2()
hand = @deck.pop(2)
p hand
if @deck.length() <= 5
self.send('generate')
end
return hand.join(" ")
end
def draw3()
hand = @deck.pop(3)
p hand
if @deck.length() <= 5
self.send('generate')
end
return hand.join(" ")
end
def generate() @deck = Array.new() @num_decks.times { |i| ['[color=yellow]♠[/color]', '♣', '[color=red]♥[/color]', '[color=blue]♦[/color]'].each do |suit| %w{A 2 3 4 5 6 7 8 9 10 J Q K}.each do |rank| @deck << "#{rank}#{suit}" end end } @deck.shuffle! p @deck end
end
Added a few more 'accessories' while learning the code Hello, and Hi responses.
Different number deck drawing (1, 2 and 3)
Start of the !slap and !MMs command.
as well as a !Drawe command, which will hopefully let you draw a number of cards = to e.