J
Josh Rowe
Hi all!
Following on from my previous question
http://www.rubyforum.com/topic/912567#new
I need some help with deleting cards from a hash. Heres what I have
#!/usr/bin/env ruby
Card = Struct.new :name, :type, :atk, :defn, :level
$deck = [
Card["Celtic Guardian", :monster, 1400, 1200,4],
Card["Dark Magician", :monster, 2500, 2100,7],
]
def draw
draw = rand(1)
puts "you drew the number #{draw}"
puts "you drew the card #{$deck[draw].name}"
end
draw
So what I need help with is deleting the card I just drew and stopping
it from being drawn again. Also I've heard it's bad to use global
variable but is it ok to have just one?
Thank you in advance. Regards Joshua
Following on from my previous question
http://www.rubyforum.com/topic/912567#new
I need some help with deleting cards from a hash. Heres what I have
#!/usr/bin/env ruby
Card = Struct.new :name, :type, :atk, :defn, :level
$deck = [
Card["Celtic Guardian", :monster, 1400, 1200,4],
Card["Dark Magician", :monster, 2500, 2100,7],
]
def draw
draw = rand(1)
puts "you drew the number #{draw}"
puts "you drew the card #{$deck[draw].name}"
end
draw
So what I need help with is deleting the card I just drew and stopping
it from being drawn again. Also I've heard it's bad to use global
variable but is it ok to have just one?
Thank you in advance. Regards Joshua