Class: GameEngine::Player

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#deckObject (readonly)

Returns the value of attribute deck.



3
4
5
# File 'lib/smack_engine/player.rb', line 3

def deck
  @deck
end

#handObject (readonly)

Returns the value of attribute hand.



3
4
5
# File 'lib/smack_engine/player.rb', line 3

def hand
  @hand
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/smack_engine/player.rb', line 3

def id
  @id
end

#pointsObject

Returns the value of attribute points.



4
5
6
# File 'lib/smack_engine/player.rb', line 4

def points
  @points
end

#selectionObject

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