Class: RpgTools::PlayingCardDeck
- Inherits:
-
Object
- Object
- RpgTools::PlayingCardDeck
- Defined in:
- lib/rpg_tools/playing_card_deck.rb
Instance Attribute Summary collapse
-
#card_picks ⇒ Object
Returns the value of attribute card_picks.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #card ⇒ Object
- #hand ⇒ Object
-
#initialize(type) ⇒ PlayingCardDeck
constructor
A new instance of PlayingCardDeck.
Constructor Details
#initialize(type) ⇒ PlayingCardDeck
Returns a new instance of PlayingCardDeck.
5 6 7 8 9 10 |
# File 'lib/rpg_tools/playing_card_deck.rb', line 5 def initialize(type) @type = type type_check @card_picks = 0 @value = nil end |
Instance Attribute Details
#card_picks ⇒ Object
Returns the value of attribute card_picks.
3 4 5 |
# File 'lib/rpg_tools/playing_card_deck.rb', line 3 def card_picks @card_picks end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/rpg_tools/playing_card_deck.rb', line 3 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/rpg_tools/playing_card_deck.rb', line 3 def value @value end |
Instance Method Details
#card ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rpg_tools/playing_card_deck.rb', line 12 def card @card_picks += 1 @value = if @type == 52 joker_picked? ? 'Joker' : standard_card else standard_card end end |
#hand ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rpg_tools/playing_card_deck.rb', line 23 def hand [].tap do |hand| until hand.count == 5 card = standard_card unless hand.include?(card) || hand.count('Joker') == 2 hand << card @card_picks += 1 end end end end |