lib/99_game.rb in 99_game-1.0.3.pre vs lib/99_game.rb in 99_game-1.0.3
- old
+ new
@@ -1,5 +1,14 @@
+def pause(p)
+ sleep(p)
+ puts
+end
+def converter(input)
+ if input == input.capitalize; return input.to_i
+ else; return input.capitalize
+ end
+end
class CardError < Exception; end
class Card # Represents a card in the deck
attr_reader :num
@@value = {"Ace" => 1, 4 => 0, 9 => 0, "Jack" => 0, "Joker" => 0, "King" => 99, "Queen" => -10}
def value
@@ -19,15 +28,9 @@
when "King" then 99
when "Joker" then 0
end
end
def initialize(card); @num = card; end
-end
-class UserCard < Card # This class converts user input into a Card-like object
- attr_reader :num
- @@num = {King: "King", K: "King", Ace: "Ace", A: "Ace", Queen: "Queen", Q: "Queen", Jack: "Jack", J: "Jack", Joker: "Joker", "$".to_sym => "Joker"}
- def _num; @@num; end
- def initialize(number=""); @@num.default, @num = number.to_i, @@num[number.capitalize.to_sym]; end
end
class Hand # Creates a object that holds and can play cards
attr_reader :hand
def initialize; @hand = [$deck.shift, $deck.shift, $deck.shift]; end
def play(card)