Class: Hearthstone::Models::Player

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#deckObject (readonly)

Returns the value of attribute deck.



6
7
8
# File 'lib/hearthstone/models/player.rb', line 6

def deck
  @deck
end

#first_playerObject (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

#graveyardObject (readonly)

Returns the value of attribute graveyard.



6
7
8
# File 'lib/hearthstone/models/player.rb', line 6

def graveyard
  @graveyard
end

#handObject (readonly)

Returns the value of attribute hand.



6
7
8
# File 'lib/hearthstone/models/player.rb', line 6

def hand
  @hand
end

#heroObject

Returns the value of attribute hero.



5
6
7
# File 'lib/hearthstone/models/player.rb', line 5

def hero
  @hero
end

#hero_powerObject

Returns the value of attribute hero_power.



5
6
7
# File 'lib/hearthstone/models/player.rb', line 5

def hero_power
  @hero_power
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#playObject (readonly)

Returns the value of attribute play.



6
7
8
# File 'lib/hearthstone/models/player.rb', line 6

def play
  @play
end

#setasideObject (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_sObject



32
33
34
# File 'lib/hearthstone/models/player.rb', line 32

def to_s
  "<Player ##{id} \"#{name}\">"
end