PlayRockPaperScissorsGame 1.4.8 → 1.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39514921253d922c83d7bdab665efa7a893e5e29
4
- data.tar.gz: 4614fdf836fd38de3f9b7cf75162f3e2f75ccac6
3
+ metadata.gz: 7a0788a26867539fd3cd74225e8e3cb73b9fce82
4
+ data.tar.gz: ad5046e6e4b6cef07c23da4b681b70b6ea31576f
5
5
  SHA512:
6
- metadata.gz: 7fcc031b6d16b14dff2b602d0632ced4500df1f40e2cb89208c39109e927fb3b064f875b4de5cee5893e3915e369ac2216300642ee5f89f46783695aecd8790c
7
- data.tar.gz: 3216faa99622206d150a084a5b787d8eb21db38e2a123790afa5732b0b1bda6510cbd4032153f5b728a7695f428cf6723d08b567b08d8dc652080d89bd8b3b9b
6
+ metadata.gz: a1b68b8e24f213d590044eae5def1fe48d256e6d2de71e3757ea2b2d95d08333096cd57871d406156d282ffb90ed5f1251ddbc8545947ddaf2c67401c1ad3b93
7
+ data.tar.gz: d73f20e097a5f4e50d906089698cd40616bd5c044bd5f7c4bf4e4333c2874778d005c2fbd34ddc95b43287fbdf820531b4df4e0971dd63d4fef14c14c6c3b2d6
data/Gemfile CHANGED
@@ -3,8 +3,9 @@ ruby '2.4.0'
3
3
  platform :ruby do
4
4
  gemspec
5
5
  group :test do
6
- gem 'bundler', '>= 1.14.6' , :require => true
7
- gem 'rake' , '>= 12.0.0' , :require => true
8
- gem 'rvm' , '>= 1.11.3.9', :require => true
6
+ gem 'bundler' , '>= 1.14.6' , :require => true
7
+ gem 'colorize', '>= 0.8.1' , :require => true
8
+ gem 'rake' , '>= 12.0.0' , :require => true
9
+ gem 'rvm' , '>= 1.11.3.9', :require => true
9
10
  end
10
11
  end
@@ -10,6 +10,8 @@
10
10
 
11
11
  class PlayRockPaperScissorsGame
12
12
 
13
+ require "colorize";
14
+
13
15
  class RPS
14
16
 
15
17
  protected;
@@ -25,10 +27,10 @@ class PlayRockPaperScissorsGame
25
27
  class RockPaperScissors
26
28
  class << self
27
29
  def continue(str1, str2, str3)
28
- puts str1;
29
- print str2;
30
+ puts str1.green.bold;
31
+ print str2.green.bold;
30
32
  gets;
31
- puts str3;
33
+ puts str3.green.bold;
32
34
  end;
33
35
  end;
34
36
  continue(Constants::INIT_STRINGS[0], Constants::INIT_STRINGS[1], Constants::INIT_STRINGS[2]);
@@ -37,33 +39,33 @@ class PlayRockPaperScissorsGame
37
39
  end;
38
40
  def play(winning_score)
39
41
  while @player_score < winning_score && @computer_score < winning_score
40
- puts "Player score: #{@player_score}, " +
41
- "Computer score: #{@computer_score}, Ties: #{@ties}";
42
+ puts "Player score: #{@player_score}, ".green.bold +
43
+ "Computer score: #{@computer_score}, Ties: #{@ties}".green.bold;
42
44
  player = PrivateMethods.player_choice;
43
45
  computer = Constants::COMPUTER_CHOICES.sample;
44
- puts "\nPlayer chooses #{player.to_s.downcase}";
45
- puts "Computer chooses #{computer.to_s.downcase}";
46
+ puts "\nPlayer chooses #{player.to_s.downcase}".green.bold;
47
+ puts "Computer chooses #{computer.to_s.downcase}".green.bold;
46
48
  case PrivateMethods.player_outcome [player, computer]
47
49
  when :WIN
48
- puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
50
+ puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round".green.bold;
49
51
  @player_score += 1;
50
52
  when :LOSE
51
- puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round";
53
+ puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round".green.bold;
52
54
  @computer_score += 1;
53
55
  else
54
- puts "Tie, choose again";
56
+ puts "Tie, choose again".green.bold;
55
57
  @ties += 1;
56
58
  end;
57
59
  end;
58
- puts "\nFinal score: player: #{@player_score}, " +
59
- "computer: #{@computer_score} (ties: #{@ties})";
60
+ puts "\nFinal score: player: #{@player_score}, ".green.bold +
61
+ "computer: #{@computer_score} (ties: #{@ties})".green.bold;
60
62
  case PrivateMethods.final_outcome(@player_score, @computer_score)
61
63
  when :WIN
62
- puts "Player wins!";
64
+ puts "Player wins!".green.bold;
63
65
  when :LOSE
64
- puts "Computer wins!";
66
+ puts "Computer wins!".green.bold;
65
67
  else
66
- puts "It's a tie!";
68
+ puts "It's a tie!".green.bold;
67
69
  end;
68
70
  gets;
69
71
  end;
@@ -72,10 +74,10 @@ class PlayRockPaperScissorsGame
72
74
  class << self
73
75
  def player_choice
74
76
  loop do
75
- print "Choose rock (r), paper (p) or scissors (s): ";
77
+ print "Choose rock (r), paper (p) or scissors (s): ".green.bold;
76
78
  choice = gets.chomp.downcase;
77
79
  return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice);
78
- puts "That entry is invalid. Please re-enter.";
80
+ puts "That entry is invalid. Please re-enter.".green.bold;
79
81
  end;
80
82
  end;
81
83
  def player_outcome(plays)
data/bin/rps CHANGED
@@ -10,7 +10,10 @@
10
10
 
11
11
  class PlayRockPaperScissorsGame
12
12
 
13
+ require "colorize";
14
+
13
15
  class RPS
16
+
14
17
  protected;
15
18
  module Constants
16
19
  NTRY_TO_SYM = { 'p' => :PAPER, 'r' => :ROCK, 's' => :SCISSORS };
@@ -24,10 +27,10 @@ class PlayRockPaperScissorsGame
24
27
  class RockPaperScissors
25
28
  class << self
26
29
  def continue(str1, str2, str3)
27
- puts str1;
28
- print str2;
30
+ puts str1.green.bold;
31
+ print str2.green.bold;
29
32
  gets;
30
- puts str3;
33
+ puts str3.green.bold;
31
34
  end;
32
35
  end;
33
36
  continue(Constants::INIT_STRINGS[0], Constants::INIT_STRINGS[1], Constants::INIT_STRINGS[2]);
@@ -36,33 +39,33 @@ class PlayRockPaperScissorsGame
36
39
  end;
37
40
  def play(winning_score)
38
41
  while @player_score < winning_score && @computer_score < winning_score
39
- puts "Player score: #{@player_score}, " +
40
- "Computer score: #{@computer_score}, Ties: #{@ties}";
42
+ puts "Player score: #{@player_score}, ".green.bold +
43
+ "Computer score: #{@computer_score}, Ties: #{@ties}".green.bold;
41
44
  player = PrivateMethods.player_choice;
42
45
  computer = Constants::COMPUTER_CHOICES.sample;
43
- puts "\nPlayer chooses #{player.to_s.downcase}";
44
- puts "Computer chooses #{computer.to_s.downcase}";
46
+ puts "\nPlayer chooses #{player.to_s.downcase}".green.bold;
47
+ puts "Computer chooses #{computer.to_s.downcase}".green.bold;
45
48
  case PrivateMethods.player_outcome [player, computer]
46
49
  when :WIN
47
- puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
50
+ puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round".green.bold;
48
51
  @player_score += 1;
49
52
  when :LOSE
50
- puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round";
53
+ puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round".green.bold;
51
54
  @computer_score += 1;
52
55
  else
53
- puts "Tie, choose again";
56
+ puts "Tie, choose again".green.bold;
54
57
  @ties += 1;
55
58
  end;
56
59
  end;
57
- puts "\nFinal score: player: #{@player_score}, " +
58
- "computer: #{@computer_score} (ties: #{@ties})";
60
+ puts "\nFinal score: player: #{@player_score}, ".green.bold +
61
+ "computer: #{@computer_score} (ties: #{@ties})".green.bold;
59
62
  case PrivateMethods.final_outcome(@player_score, @computer_score)
60
63
  when :WIN
61
- puts "Player wins!";
64
+ puts "Player wins!".green.bold;
62
65
  when :LOSE
63
- puts "Computer wins!";
66
+ puts "Computer wins!".green.bold;
64
67
  else
65
- puts "It's a tie!";
68
+ puts "It's a tie!".green.bold;
66
69
  end;
67
70
  gets;
68
71
  end;
@@ -71,10 +74,10 @@ class PlayRockPaperScissorsGame
71
74
  class << self
72
75
  def player_choice
73
76
  loop do
74
- print "Choose rock (r), paper (p) or scissors (s): ";
77
+ print "Choose rock (r), paper (p) or scissors (s): ".green.bold;
75
78
  choice = gets.chomp.downcase;
76
79
  return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice);
77
- puts "That entry is invalid. Please re-enter.";
80
+ puts "That entry is invalid. Please re-enter.".green.bold;
78
81
  end;
79
82
  end;
80
83
  def player_outcome(plays)
@@ -94,4 +97,3 @@ class PlayRockPaperScissorsGame
94
97
  end;
95
98
 
96
99
  PlayRockPaperScissorsGame::RPS::RockPaperScissors.new.play(2); # best of 3
97
-
data/lib/ref/Constants.rb CHANGED
@@ -14,8 +14,8 @@ module Constants
14
14
  ]; # format: player choice, computer choice
15
15
  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
16
16
  INIT_STRINGS = [
17
- "You are about to enter a rock-paper-scissors best of 3 match.",
18
- "Press the return/enter key to continue...",
17
+ "You are about to enter a rock-paper-scissors best of 3 match.".green.bold,
18
+ "Press the return/enter key to continue...".green.bold,
19
19
  ""
20
20
  ];
21
21
  end;
@@ -3,10 +3,10 @@ module PrivateMethods
3
3
  class << self
4
4
  def player_choice
5
5
  loop do
6
- print "Choose rock (r), paper (p) or scissors (s): ";
6
+ print "Choose rock (r), paper (p) or scissors (s): ".green.bold;
7
7
  choice = gets.chomp.downcase;
8
8
  return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice);
9
- puts "That entry is invalid. Please re-enter.";
9
+ puts "That entry is invalid. Please re-enter.".green.bold;
10
10
  end;
11
11
  end;
12
12
  def player_outcome(plays)
data/lib/rps.rb CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  class PlayRockPaperScissorsGame
10
10
 
11
+ require "colorize";
12
+
11
13
  class RPS
12
14
 
13
15
  require "ref/Constants.rb";
@@ -15,10 +17,10 @@ class PlayRockPaperScissorsGame
15
17
  class RockPaperScissors
16
18
  class << self
17
19
  def continue(str1, str2, str3)
18
- puts str1;
19
- print str2;
20
+ puts str1.green.bold;
21
+ print str2.green.bold;
20
22
  gets;
21
- puts str3;
23
+ puts str3.green.bold;
22
24
  end;
23
25
  end;
24
26
  continue(Constants::INIT_STRINGS[0], Constants::INIT_STRINGS[1], Constants::INIT_STRINGS[2]);
@@ -27,37 +29,37 @@ class PlayRockPaperScissorsGame
27
29
  end;
28
30
  def play(winning_score)
29
31
  while @player_score < winning_score && @computer_score < winning_score
30
- puts "Player score: #{@player_score}, " +
31
- "Computer score: #{@computer_score}, Ties: #{@ties}";
32
+ puts "Player score: #{@player_score}, ".green.bold +
33
+ "Computer score: #{@computer_score}, Ties: #{@ties}".green.bold;
32
34
  player = PrivateMethods.player_choice;
33
35
  computer = Constants::COMPUTER_CHOICES.sample;
34
- puts "\nPlayer chooses #{player.to_s.downcase}";
35
- puts "Computer chooses #{computer.to_s.downcase}";
36
+ puts "\nPlayer chooses #{player.to_s.downcase}".green.bold;
37
+ puts "Computer chooses #{computer.to_s.downcase}".green.bold;
36
38
  case PrivateMethods.player_outcome [player, computer]
37
39
  when :WIN
38
- puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
40
+ puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round".green.bold;
39
41
  @player_score += 1;
40
42
  when :LOSE
41
- puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round";
43
+ puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round".green.bold;
42
44
  @computer_score += 1;
43
45
  else
44
- puts "Tie, choose again";
46
+ puts "Tie, choose again".green.bold;
45
47
  @ties += 1;
46
48
  end;
47
49
  end;
48
- puts "\nFinal score: player: #{@player_score}, " +
49
- "computer: #{@computer_score} (ties: #{@ties})";
50
+ puts "\nFinal score: player: #{@player_score}, ".green.bold +
51
+ "computer: #{@computer_score} (ties: #{@ties})".green.bold;
50
52
  case PrivateMethods.final_outcome(@player_score, @computer_score)
51
53
  when :WIN
52
- puts "Player wins!";
54
+ puts "Player wins!".green.bold;
53
55
  when :LOSE
54
- puts "Computer wins!";
56
+ puts "Computer wins!".green.bold;
55
57
  else
56
- puts "It's a tie!";
58
+ puts "It's a tie!".green.bold;
57
59
  end;
58
60
  gets;
59
61
  end;
60
- require "ref/PrivateMethods.rb";
62
+ require "ref/PrivateMethods.rb".green.bold;
61
63
  end;
62
64
  end;
63
65
  end;
data/rps.gemspec CHANGED
@@ -1,25 +1,26 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = "PlayRockPaperScissorsGame"
3
- spec.version = "1.4.8"
4
- spec.date = "2017-03-30"
5
- spec.summary = "A Rock Paper Scissors Ruby Gem"
6
- spec.description = "A Ruby-programmed rock paper scissors game. To install: gem install PlayRockPaperScissorsGame; To run: rps; or: PlayRockPaperScissorsGame"
7
- spec.author = "bag3318"
8
- spec.email = "" # email is disclosed for privacy reasons
9
- spec.platform = Gem::Platform::RUBY
10
- spec.require_paths = ["lib", "test", "exec", "bin"]
11
- spec.files = ["lib/rps.rb", "lib/ref/PrivateMethods.rb", "lib/ref/Constants.rb", "test/test_rps.rb", "exec/run.bat", "exec/rps.bash", "exec/uninstall.sh", "rps.gemspec", "Rakefile", "Gemfile", "LICENSE"]
12
- spec.bindir = "bin"
13
- spec.executables << "rps"
14
- spec.executables << "PlayRockPaperScissorsGame"
15
- spec.license = "MIT"
16
- spec.homepage = "https://rubygems.org/gems/PlayRockPaperScissorsGame/"
17
- spec.extra_rdoc_files = "README.md"
18
- spec.required_ruby_version = "2.4.0"
19
- spec.required_rubygems_version = "2.6.11"
20
- spec.metadata = { "issue_tracker" => "https://github.com/bag3318/RockPaperScissors/issues" }
21
- spec.post_install_message = "Thanks for installing! I hope you have fun playing rock paper scissors! :)"
22
- spec.add_runtime_dependency "bundler", ">= 1.14.6"
23
- spec.add_runtime_dependency "rake" , ">= 12.0.0"
24
- spec.add_runtime_dependency "rvm" , ">= 1.11.3.9"
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "PlayRockPaperScissorsGame"
3
+ spec.version = "1.4.9"
4
+ spec.date = "2017-03-30"
5
+ spec.summary = "A Rock Paper Scissors Ruby Gem"
6
+ spec.description = "A Ruby-programmed rock paper scissors game. To install: gem install PlayRockPaperScissorsGame; To run: rps; or: PlayRockPaperScissorsGame"
7
+ spec.author = "bag3318"
8
+ spec.email = "" # email is disclosed for privacy reasons
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.require_paths = ["lib", "test", "exec", "bin"]
11
+ spec.files = ["lib/rps.rb", "lib/ref/PrivateMethods.rb", "lib/ref/Constants.rb", "test/test_rps.rb", "exec/run.bat", "exec/rps.bash", "exec/uninstall.sh", "rps.gemspec", "Rakefile", "Gemfile", "LICENSE"]
12
+ spec.bindir = "bin"
13
+ spec.executables << "rps"
14
+ spec.executables << "PlayRockPaperScissorsGame"
15
+ spec.license = "MIT"
16
+ spec.homepage = "https://rubygems.org/gems/PlayRockPaperScissorsGame/"
17
+ spec.extra_rdoc_files = "README.md"
18
+ spec.required_ruby_version = "2.4.0"
19
+ spec.required_rubygems_version = "2.6.11"
20
+ spec.metadata = { "issue_tracker" => "https://github.com/bag3318/RockPaperScissors/issues" }
21
+ spec.post_install_message = "Thanks for installing! I hope you have fun playing rock paper scissors! :)"
22
+ spec.add_runtime_dependency "bundler" , ">= 1.14.6"
23
+ spec.add_runtime_dependency "colorize", ">= 0.8.1"
24
+ spec.add_runtime_dependency "rake" , ">= 12.0.0"
25
+ spec.add_runtime_dependency "rvm" , ">= 1.11.3.9"
25
26
  end
data/test/test_rps.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  =end
8
8
 
9
9
  class Test
10
-
10
+ require "colorize";
11
11
  class Rake < Test
12
12
  protected;
13
13
  module Constants
@@ -18,14 +18,13 @@ class Test
18
18
  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
19
19
  INIT_STRINGS = ["You are about to enter a rock-paper-scissors best of 3 match.", "Press the return/enter key to continue...", ""];
20
20
  end;
21
-
22
21
  class RockPaperScissorsTest
23
22
  class << self
24
23
  def continue(str1, str2, str3)
25
- puts str1;
26
- print str2;
24
+ puts str1.green.bold;
25
+ print str2.green.bold;
27
26
  gets;
28
- puts str3;
27
+ puts str3.green.bold;
29
28
  end;
30
29
  end;
31
30
  continue(Constants::INIT_STRINGS[0], Constants::INIT_STRINGS[1], Constants::INIT_STRINGS[2]);
@@ -34,33 +33,33 @@ class Test
34
33
  end;
35
34
  def testPlay(winning_score)
36
35
  while @player_score < winning_score && @computer_score < winning_score
37
- puts "Player score: #{@player_score}, " +
38
- "Computer score: #{@computer_score}, Ties: #{@ties}";
36
+ puts "Player score: #{@player_score}, ".green.bold +
37
+ "Computer score: #{@computer_score}, Ties: #{@ties}".green.bold;
39
38
  player = PrivateMethods.player_choice;
40
39
  computer = Constants::COMPUTER_CHOICES.sample;
41
- puts "\nPlayer chooses #{player.to_s.downcase}";
42
- puts "Computer chooses #{computer.to_s.downcase}";
40
+ puts "\nPlayer chooses #{player.to_s.downcase}".green.bold;
41
+ puts "Computer chooses #{computer.to_s.downcase}".green.bold;
43
42
  case PrivateMethods.player_outcome [player, computer]
44
43
  when :WIN
45
- puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
44
+ puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round".green.bold;
46
45
  @player_score += 1;
47
46
  when :LOSE
48
- puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round";
47
+ puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round".green.bold;
49
48
  @computer_score += 1;
50
49
  else
51
- puts "Tie, choose again";
50
+ puts "Tie, choose again".green.bold;
52
51
  @ties += 1;
53
52
  end;
54
53
  end;
55
- puts "\nFinal score: player: #{@player_score}, " +
56
- "computer: #{@computer_score} (ties: #{@ties})";
54
+ puts "\nFinal score: player: #{@player_score}, ".green.bold +
55
+ "computer: #{@computer_score} (ties: #{@ties})".green.bold;
57
56
  case PrivateMethods.final_outcome(@player_score, @computer_score)
58
57
  when :WIN
59
- puts "Player wins!";
58
+ puts "Player wins!".green.bold;
60
59
  when :LOSE
61
- puts "Computer wins!";
60
+ puts "Computer wins!".green.bold;
62
61
  else
63
- puts "It's a tie!";
62
+ puts "It's a tie!".green.bold;
64
63
  end;
65
64
  gets;
66
65
  end;
@@ -69,10 +68,10 @@ class Test
69
68
  class << self
70
69
  def player_choice
71
70
  loop do
72
- print "Choose rock (r), paper (p) or scissors (s): ";
71
+ print "Choose rock (r), paper (p) or scissors (s): ".green.bold;
73
72
  choice = gets.chomp.downcase;
74
73
  return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice);
75
- puts "That entry is invalid. Please re-enter";
74
+ puts "That entry is invalid. Please re-enter".green.bold;
76
75
  end;
77
76
  end;
78
77
  def player_outcome(plays)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: PlayRockPaperScissorsGame
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.8
4
+ version: 1.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - bag3318
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.14.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement