Module: AppController
- Defined in:
- lib/controllers/app_controller.rb
Class Method Summary collapse
- .clear_screen ⇒ Object
- .exit? ⇒ Boolean
- .play_game ⇒ Object
- .play_or_menu ⇒ Object
- .show_highscores ⇒ Object
- .show_rules ⇒ Object
Class Method Details
.clear_screen ⇒ Object
51 52 53 |
# File 'lib/controllers/app_controller.rb', line 51 def clear_screen system('clear') end |
.exit? ⇒ Boolean
55 56 57 58 |
# File 'lib/controllers/app_controller.rb', line 55 def exit? self.clear_screen ExitView.show end |
.play_game ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/controllers/app_controller.rb', line 11 def play_game begin self.clear_screen Sound.new("lib/media/blaster-firing.wav").play new_round = Round.new request_player_input = RoundsView.input round: new_round, round_number: Round.num_rounds new_round.player_input = request_player_input new_round.player_selection = new_round.selections request_player_input RoundsView.display_results new_round new_round.save! RoundsView.successful_save end until new_round.result == 'lost' new_game = Game.new GamesView.get_player_name new_game new_game.score = Round.count_wins * 100 + Round.count_draws * 25 self.clear_screen GamesView.thanks new_game new_game.save! GamesView.successful_save Round.clear_rounds self. end |
.play_or_menu ⇒ Object
47 48 49 |
# File 'lib/controllers/app_controller.rb', line 47 def OptionsView.show == false ? nil : self.play_game end |
.show_highscores ⇒ Object
34 35 36 37 38 39 |
# File 'lib/controllers/app_controller.rb', line 34 def show_highscores self.clear_screen games = Game.map { |game| [game.player_name, game.score] } HighscoresView.show games: games self. end |