Class: Shithead::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/shithead/player.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Player

Returns a new instance of Player.



4
5
6
7
8
9
# File 'lib/shithead/player.rb', line 4

def initialize(name)
  @name    = name
  @hidden  = []
  @visible = Shithead::SortedStack.new
  @hand    = Shithead::SortedStack.new
end

Instance Attribute Details

#handObject (readonly)

Returns the value of attribute hand.



2
3
4
# File 'lib/shithead/player.rb', line 2

def hand
  @hand
end

#hiddenObject (readonly)

Returns the value of attribute hidden.



2
3
4
# File 'lib/shithead/player.rb', line 2

def hidden
  @hidden
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/shithead/player.rb', line 2

def name
  @name
end

#visibleObject (readonly)

Returns the value of attribute visible.



2
3
4
# File 'lib/shithead/player.rb', line 2

def visible
  @visible
end

Instance Method Details

#add(card) ⇒ Object



11
12
13
# File 'lib/shithead/player.rb', line 11

def add(card)
  hand.add card
end

#clear?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/shithead/player.rb', line 15

def clear?
  hidden.empty? && visible.empty? && hand.empty?
end

#hand_countObject



19
20
21
# File 'lib/shithead/player.rb', line 19

def hand_count
  hand.length
end

#hidden_countObject



23
24
25
# File 'lib/shithead/player.rb', line 23

def hidden_count
  hidden.length
end