Class: MastermindRuby::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/mastermind_ruby/game.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ui, solution: Code.random) ⇒ Game

Returns a new instance of Game.



5
6
7
8
9
10
# File 'lib/mastermind_ruby/game.rb', line 5

def initialize(ui, solution: Code.random)
  @solution_code = solution
  @ui = ui
  @try_count = 1
  @started = false
end

Instance Attribute Details

#try_countObject (readonly)

Returns the value of attribute try_count.



3
4
5
# File 'lib/mastermind_ruby/game.rb', line 3

def try_count
  @try_count
end

Instance Method Details

#startObject

Method to start a game Requests by calling read_playername for the playername on the UI



14
15
16
17
18
19
# File 'lib/mastermind_ruby/game.rb', line 14

def start
  @started = true
  @playername = @ui.read_playername
  @ui.display_welcome_message(@playername)
  run
end