Class: CodebrackerSimb::Game
- Inherits:
-
Object
- Object
- CodebrackerSimb::Game
- Defined in:
- lib/codebracker_simb/game.rb
Overview
game cl
Constant Summary collapse
- ERR_UNEXPECTED_COMPLEXITY =
'complexity could be easy, medium or hard'- IS_OVER =
'Game is over, you lose'- GREETING =
'Hello! Welcome to CodeBracker Game! Have fun!'- CONGRATULATIONS =
'Congratulations! You broked a code, master!'
Instance Attribute Summary collapse
-
#answer ⇒ Object
Returns the value of attribute answer.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize(complexity) ⇒ Game
constructor
A new instance of Game.
- #play ⇒ Object
Constructor Details
#initialize(complexity) ⇒ Game
Returns a new instance of Game.
18 19 20 |
# File 'lib/codebracker_simb/game.rb', line 18 def initialize(complexity) @attempts = attempts(complexity) end |
Instance Attribute Details
#answer ⇒ Object
Returns the value of attribute answer.
11 12 13 |
# File 'lib/codebracker_simb/game.rb', line 11 def answer @answer end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
9 10 11 |
# File 'lib/codebracker_simb/game.rb', line 9 def code @code end |
Instance Method Details
#play ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/codebracker_simb/game.rb', line 22 def play define_code loop do input_answer result = Checker.new(code, answer).compare refresh_attempts_quantity break if win? || @attempts == 0 end end |