Class: Gitscrub::Game
- Inherits:
-
Object
- Object
- Gitscrub::Game
- Defined in:
- lib/gitscrub/game.rb
Instance Attribute Summary collapse
-
#profile ⇒ Object
Returns the value of attribute profile.
Instance Method Summary collapse
-
#initialize ⇒ Game
constructor
A new instance of Game.
- #level_bump ⇒ Object
- #play_level ⇒ Object
Constructor Details
Instance Attribute Details
#profile ⇒ Object
Returns the value of attribute profile.
4 5 6 |
# File 'lib/gitscrub/game.rb', line 4 def profile @profile end |
Instance Method Details
#level_bump ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/gitscrub/game.rb', line 30 def level_bump profile.level += 1 profile.save if level = Level.load(profile.level) UI.puts(level.full_description) level.setup_level end end |
#play_level ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gitscrub/game.rb', line 10 def play_level solve = true if profile.level == 0 UI.puts("Welcome to Gitscrub") solve = false level_bump else level = Level.load(profile.level) if solve && level if level.solve UI.success "Congratulations, you have solved the level" level_bump else UI.error "Sorry, this solution is not quite right!" UI.puts level.full_description end end end end |