module AppController
Public Class Methods
clear_screen()
click to toggle source
# File lib/controllers/app_controller.rb, line 51 def clear_screen system('clear') end
exit?()
click to toggle source
# File lib/controllers/app_controller.rb, line 55 def exit? self.clear_screen ExitView.show end
play_game()
click to toggle source
# 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.play_or_menu end
show_highscores()
click to toggle source
# 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.play_or_menu end
show_rules()
click to toggle source
# File lib/controllers/app_controller.rb, line 41 def show_rules self.clear_screen RulesView.show self.play_or_menu end
Private Instance Methods
clear_screen()
click to toggle source
# File lib/controllers/app_controller.rb, line 51 def clear_screen system('clear') end
exit?()
click to toggle source
# File lib/controllers/app_controller.rb, line 55 def exit? self.clear_screen ExitView.show end
play_game()
click to toggle source
# 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.play_or_menu end
show_highscores()
click to toggle source
# 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.play_or_menu end
show_rules()
click to toggle source
# File lib/controllers/app_controller.rb, line 41 def show_rules self.clear_screen RulesView.show self.play_or_menu end