Sha256: db66bca808206ece9e5cdec717a1973a82729758280c10cea9b1180de1ff4fd2

Contents?: true

Size: 830 Bytes

Versions: 4

Compression:

Stored size: 830 Bytes

Contents

require "colorized_string";
ColorizedString.colors;   
ColorizedString.modes;  
module PrivateMethods
  class << self
    def player_choice
      loop do
        print ColorizedString["Choose rock (r), paper (p) or scissors (s): "].colorize(:green);
        choice = gets.chomp.downcase;
        return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice); 
        puts ColorizedString["That entry is invalid. Please re-enter"].colorize(:green); 
      end; 
    end; 
    def player_outcome(plays)
      return :WIN  if Constants::WINNERS.include?(plays);
      return :LOSE if Constants::LOSERS.include?(plays);
      return :TIE  if (!:WIN || !:LOSE);
    end; 
    def final_outcome(pl, co) 
      return :WIN  if pl > co; 
      return :LOSE if pl < co;
      return :TIE  if pl = co; 
    end; 
  end;
end;

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
PlayRockPaperScissorsGame-1.7.4 lib/ref/PrivateMethods.rb
PlayRockPaperScissorsGame-1.7.3 lib/ref/PrivateMethods.rb
PlayRockPaperScissorsGame-1.7.2 lib/ref/PrivateMethods.rb
PlayRockPaperScissorsGame-1.7.1 lib/ref/PrivateMethods.rb