Class: Game
- Inherits:
-
Object
- Object
- Game
- Defined in:
- lib/manasimu/game.rb
Instance Attribute Summary collapse
-
#deck ⇒ Object
Returns the value of attribute deck.
-
#hands ⇒ Object
Returns the value of attribute hands.
-
#plays ⇒ Object
Returns the value of attribute plays.
Instance Method Summary collapse
- #draw(turn) ⇒ Object
-
#initialize(deck) ⇒ Game
constructor
A new instance of Game.
- #plan ⇒ Object
- #play(card, turn) ⇒ Object
- #step(turn) ⇒ Object
- #upkeep(turn) ⇒ Object
Constructor Details
Instance Attribute Details
#deck ⇒ Object
Returns the value of attribute deck.
2 3 4 |
# File 'lib/manasimu/game.rb', line 2 def deck @deck end |
#hands ⇒ Object
Returns the value of attribute hands.
2 3 4 |
# File 'lib/manasimu/game.rb', line 2 def hands @hands end |
#plays ⇒ Object
Returns the value of attribute plays.
2 3 4 |
# File 'lib/manasimu/game.rb', line 2 def plays @plays end |
Instance Method Details
#draw(turn) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/manasimu/game.rb', line 30 def draw(turn) card = @deck.pop # puts "draw #{card}" card.drawed(turn) @hands << card end |
#plan ⇒ Object
37 38 39 |
# File 'lib/manasimu/game.rb', line 37 def plan @planner.plan(@hands, @plays) end |
#play(card, turn) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/manasimu/game.rb', line 41 def play(card, turn) # puts "play #{card}" card.played(turn) @plays << card @hands.delete card end |
#step(turn) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/manasimu/game.rb', line 12 def step(turn) # puts "turn #{turn}" # puts "played" # @plays.each do |card| puts " #{card}" end # puts "hands" # @hands.each do |card| puts " #{card}" end upkeep(turn) draw(turn) plan.each do |card| play(card, turn) end end |
#upkeep(turn) ⇒ Object
26 27 28 |
# File 'lib/manasimu/game.rb', line 26 def upkeep(turn) @plays.each { |card| card.step(turn) } end |