Class: Hearthstone::Models::Player
- Inherits:
-
Object
- Object
- Hearthstone::Models::Player
- Defined in:
- lib/hearthstone/models/player.rb
Instance Attribute Summary collapse
-
#deck ⇒ Object
readonly
Returns the value of attribute deck.
-
#first_player ⇒ Object
readonly
Returns the value of attribute first_player.
-
#graveyard ⇒ Object
readonly
Returns the value of attribute graveyard.
-
#hand ⇒ Object
readonly
Returns the value of attribute hand.
-
#hero ⇒ Object
Returns the value of attribute hero.
-
#hero_power ⇒ Object
Returns the value of attribute hero_power.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#play ⇒ Object
readonly
Returns the value of attribute play.
-
#setaside ⇒ Object
readonly
Returns the value of attribute setaside.
Instance Method Summary collapse
-
#initialize(id: nil, name: nil, first_player: nil, hero: nil, hero_power: nil) ⇒ Player
constructor
A new instance of Player.
- #move_card(card, to_zone) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id: nil, name: nil, first_player: nil, hero: nil, hero_power: nil) ⇒ Player
Returns a new instance of Player.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hearthstone/models/player.rb', line 8 def initialize(id: nil, name: nil, first_player: nil, hero: nil, hero_power: nil) @id = id @name = name @first_player = first_player @hero = hero @hero_power = hero_power @deck = Set.new @hand = Set.new @play = Set.new @graveyard = Set.new @setaside = Set.new end |
Instance Attribute Details
#deck ⇒ Object (readonly)
Returns the value of attribute deck.
6 7 8 |
# File 'lib/hearthstone/models/player.rb', line 6 def deck @deck end |
#first_player ⇒ Object (readonly)
Returns the value of attribute first_player.
4 5 6 |
# File 'lib/hearthstone/models/player.rb', line 4 def first_player @first_player end |
#graveyard ⇒ Object (readonly)
Returns the value of attribute graveyard.
6 7 8 |
# File 'lib/hearthstone/models/player.rb', line 6 def graveyard @graveyard end |
#hand ⇒ Object (readonly)
Returns the value of attribute hand.
6 7 8 |
# File 'lib/hearthstone/models/player.rb', line 6 def hand @hand end |
#hero ⇒ Object
Returns the value of attribute hero.
5 6 7 |
# File 'lib/hearthstone/models/player.rb', line 5 def hero @hero end |
#hero_power ⇒ Object
Returns the value of attribute hero_power.
5 6 7 |
# File 'lib/hearthstone/models/player.rb', line 5 def hero_power @hero_power end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/hearthstone/models/player.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/hearthstone/models/player.rb', line 4 def name @name end |
#play ⇒ Object (readonly)
Returns the value of attribute play.
6 7 8 |
# File 'lib/hearthstone/models/player.rb', line 6 def play @play end |
#setaside ⇒ Object (readonly)
Returns the value of attribute setaside.
6 7 8 |
# File 'lib/hearthstone/models/player.rb', line 6 def setaside @setaside end |
Instance Method Details
#move_card(card, to_zone) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/hearthstone/models/player.rb', line 22 def move_card(card, to_zone) [:deck, :hand, :play, :graveyard, :setaside].each do |zone| if to_zone != zone self.send(zone).delete(card) else self.send(to_zone) << card end end end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/hearthstone/models/player.rb', line 32 def to_s "<Player ##{id} \"#{name}\">" end |