test/test_rps.rb in PlayRockPaperScissorsGame-1.7.8 vs test/test_rps.rb in PlayRockPaperScissorsGame-1.7.9

- old
+ new

@@ -19,11 +19,10 @@ COMPUTER_CHOICES = NTRY_TO_SYM.values; WINNERS = [[:SCISSORS, :PAPER], [:PAPER, :ROCK], [:ROCK, :SCISSORS]]; # format: player choice, computer choice LOSERS = WINNERS.map { |i,j| [j,i] }; # this will take the original WINNERS array and flip the symbols, thus returning a loss for the user/player INIT_STRINGS = ["You are about to enter a rock-paper-scissors best of 3 match.", "Press the return/enter key to continue...", ""]; end; - class << self def continue(str1, str2, str3) puts ColorizedString[str1].colorize(:color => :green); print ColorizedString[str2].colorize(:color => :green); gets; @@ -34,16 +33,16 @@ def initialize @player_score = @computer_score = @ties = 0; end; def testPlay(winning_score) while @player_score < winning_score && @computer_score < winning_score - puts ColorizedString["Player score: #{@player_score}, "].colorize(:blue) + - ColorizedString["Computer score: #{@computer_score}, Ties: #{@ties}"].colorize(:blue); + puts ColorizedString["Player score: #{@player_score}, "].colorize(:light_blue) + + ColorizedString["Computer score: #{@computer_score}, Ties: #{@ties}"].colorize(:light_blue); player = PrivateMethods.player_choice; computer = Constants::COMPUTER_CHOICES.sample; - puts ColorizedString["\nPlayer chooses #{player.to_s.downcase}"].colorize(:blue); - puts ColorizedString["Computer chooses #{computer.to_s.downcase}"].colorize(:blue); + puts ColorizedString["\nPlayer chooses #{player.to_s.downcase}"].colorize(:light_blue); + puts ColorizedString["Computer chooses #{computer.to_s.downcase}"].colorize(:light_blue); case PrivateMethods.player_outcome [player, computer] when :WIN puts ColorizedString["#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round"].colorize(:red); @player_score += 1; when :LOSE @@ -52,22 +51,21 @@ else puts ColorizedString["Tie, choose again"].colorize(:red); @ties += 1; end; end; - puts ColorizedString["\nFinal score: player: #{@player_score}, "].colorize(:blue) + - ColorizedString["computer: #{@computer_score} (ties: #{@ties})"].colorize(:blue); + puts ColorizedString["\nFinal score: player: #{@player_score}, "].colorize(:light_blue) + + ColorizedString["computer: #{@computer_score} (ties: #{@ties})"].colorize(:light_blue); case PrivateMethods.final_outcome(@player_score, @computer_score) when :WIN puts ColorizedString["Player wins!"].colorize(:red); when :LOSE puts ColorizedString["Computer wins!"].colorize(:red); else puts ColorizedString["It's a tie!"].colorize(:red); end; gets; end; - private module PrivateMethods private; class << self def player_choice loop do