Class: GameEngine::Player
- Inherits:
-
Object
- Object
- GameEngine::Player
- Defined in:
- lib/smack_engine/player.rb
Instance Attribute Summary collapse
-
#deck ⇒ Object
readonly
Returns the value of attribute deck.
-
#hand ⇒ Object
readonly
Returns the value of attribute hand.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#points ⇒ Object
Returns the value of attribute points.
-
#selection ⇒ Object
Returns the value of attribute selection.
Instance Method Summary collapse
-
#initialize(player_data) ⇒ Player
constructor
A new instance of Player.
- #play_cards(indexes) ⇒ Object
Constructor Details
#initialize(player_data) ⇒ Player
Returns a new instance of Player.
6 7 8 9 10 11 12 |
# File 'lib/smack_engine/player.rb', line 6 def initialize(player_data) @id = player_data.id @deck = GameEngine::Deck.new(player_data.deck) @hand = [] @selection = [] @points = GameEngine::GAME_RULES[:starting_points] end |
Instance Attribute Details
#deck ⇒ Object (readonly)
Returns the value of attribute deck.
3 4 5 |
# File 'lib/smack_engine/player.rb', line 3 def deck @deck end |
#hand ⇒ Object (readonly)
Returns the value of attribute hand.
3 4 5 |
# File 'lib/smack_engine/player.rb', line 3 def hand @hand end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/smack_engine/player.rb', line 3 def id @id end |
#points ⇒ Object
Returns the value of attribute points.
4 5 6 |
# File 'lib/smack_engine/player.rb', line 4 def points @points end |
#selection ⇒ Object
Returns the value of attribute selection.
4 5 6 |
# File 'lib/smack_engine/player.rb', line 4 def selection @selection end |
Instance Method Details
#play_cards(indexes) ⇒ Object
14 15 16 |
# File 'lib/smack_engine/player.rb', line 14 def play_cards(indexes) indexes.each { |i| selection << hand.delete_at(i) } end |