PlayRockPaperScissorsGame 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/PlayRockPaperScissorsGame +5 -5
- data/bin/rps +5 -5
- data/lib/ref/{PrivateVars.rb → PrivateMethods.rb} +2 -2
- data/lib/rps.rb +4 -4
- data/rps.gemspec +2 -2
- data/test/test_rps.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87748761c1568de8dedafa46b1ae8f7e81bd9208
|
4
|
+
data.tar.gz: e74289d3a1f0cd8349ea46c662916ce2d44e9b7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ce093532f1bda5f4799a4437f8501dadfdd28b08d5708044b54ae257324d0fc79df5980096f077533c46b95397c7ed679e0b68963adfdbe54660692b1ecb393
|
7
|
+
data.tar.gz: 9fc73ee5c047e537a1f89279a9fd6949eae34b22e5d258dceb57eb8074a399da6da5207a281c5b573768aebae9af766c8020aced2a8da75bd5a49500345c0943
|
@@ -38,11 +38,11 @@ class PlayRockPaperScissorsGame
|
|
38
38
|
while @player_score < winning_score && @computer_score < winning_score
|
39
39
|
puts "Player score: #{@player_score}, " +
|
40
40
|
"Computer score: #{@computer_score}, Ties: #{@ties}";
|
41
|
-
player =
|
41
|
+
player = PrivateMethods.player_choice;
|
42
42
|
computer = Constants::COMPUTER_CHOICES.sample;
|
43
43
|
puts "\nPlayer chooses #{player.to_s.downcase}";
|
44
44
|
puts "Computer chooses #{computer.to_s.downcase}";
|
45
|
-
case
|
45
|
+
case PrivateMethods.player_outcome [player, computer]
|
46
46
|
when :WIN
|
47
47
|
puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
|
48
48
|
@player_score += 1;
|
@@ -56,7 +56,7 @@ class PlayRockPaperScissorsGame
|
|
56
56
|
end;
|
57
57
|
puts "\nFinal score: player: #{@player_score}, " +
|
58
58
|
"computer: #{@computer_score} (ties: #{@ties})";
|
59
|
-
case
|
59
|
+
case PrivateMethods.final_outcome(@player_score, @computer_score)
|
60
60
|
when :WIN
|
61
61
|
puts "Player wins!";
|
62
62
|
when :LOSE
|
@@ -67,14 +67,14 @@ class PlayRockPaperScissorsGame
|
|
67
67
|
gets;
|
68
68
|
end;
|
69
69
|
private;
|
70
|
-
module
|
70
|
+
module PrivateMethods
|
71
71
|
class << self
|
72
72
|
def player_choice
|
73
73
|
loop do
|
74
74
|
print "Choose rock (r), paper (p) or scissors (s): ";
|
75
75
|
choice = gets.chomp.downcase;
|
76
76
|
return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice);
|
77
|
-
puts "That entry is invalid. Please re-enter";
|
77
|
+
puts "That entry is invalid. Please re-enter.";
|
78
78
|
end;
|
79
79
|
end;
|
80
80
|
def player_outcome(plays)
|
data/bin/rps
CHANGED
@@ -38,11 +38,11 @@ class PlayRockPaperScissorsGame
|
|
38
38
|
while @player_score < winning_score && @computer_score < winning_score
|
39
39
|
puts "Player score: #{@player_score}, " +
|
40
40
|
"Computer score: #{@computer_score}, Ties: #{@ties}";
|
41
|
-
player =
|
41
|
+
player = PrivateMethods.player_choice;
|
42
42
|
computer = Constants::COMPUTER_CHOICES.sample;
|
43
43
|
puts "\nPlayer chooses #{player.to_s.downcase}";
|
44
44
|
puts "Computer chooses #{computer.to_s.downcase}";
|
45
|
-
case
|
45
|
+
case PrivateMethods.player_outcome [player, computer]
|
46
46
|
when :WIN
|
47
47
|
puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
|
48
48
|
@player_score += 1;
|
@@ -56,7 +56,7 @@ class PlayRockPaperScissorsGame
|
|
56
56
|
end;
|
57
57
|
puts "\nFinal score: player: #{@player_score}, " +
|
58
58
|
"computer: #{@computer_score} (ties: #{@ties})";
|
59
|
-
case
|
59
|
+
case PrivateMethods.final_outcome(@player_score, @computer_score)
|
60
60
|
when :WIN
|
61
61
|
puts "Player wins!";
|
62
62
|
when :LOSE
|
@@ -67,14 +67,14 @@ class PlayRockPaperScissorsGame
|
|
67
67
|
gets;
|
68
68
|
end;
|
69
69
|
private;
|
70
|
-
module
|
70
|
+
module PrivateMethods
|
71
71
|
class << self
|
72
72
|
def player_choice
|
73
73
|
loop do
|
74
74
|
print "Choose rock (r), paper (p) or scissors (s): ";
|
75
75
|
choice = gets.chomp.downcase;
|
76
76
|
return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice);
|
77
|
-
puts "That entry is invalid. Please re-enter";
|
77
|
+
puts "That entry is invalid. Please re-enter.";
|
78
78
|
end;
|
79
79
|
end;
|
80
80
|
def player_outcome(plays)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
private;
|
2
|
-
module
|
2
|
+
module PrivateMethods
|
3
3
|
class << self
|
4
4
|
def player_choice
|
5
5
|
loop do
|
6
6
|
print "Choose rock (r), paper (p) or scissors (s): ";
|
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.";
|
10
10
|
end;
|
11
11
|
end;
|
12
12
|
def player_outcome(plays)
|
data/lib/rps.rb
CHANGED
@@ -29,11 +29,11 @@ class PlayRockPaperScissorsGame
|
|
29
29
|
while @player_score < winning_score && @computer_score < winning_score
|
30
30
|
puts "Player score: #{@player_score}, " +
|
31
31
|
"Computer score: #{@computer_score}, Ties: #{@ties}";
|
32
|
-
player =
|
32
|
+
player = PrivateMethods.player_choice;
|
33
33
|
computer = Constants::COMPUTER_CHOICES.sample;
|
34
34
|
puts "\nPlayer chooses #{player.to_s.downcase}";
|
35
35
|
puts "Computer chooses #{computer.to_s.downcase}";
|
36
|
-
case
|
36
|
+
case PrivateMethods.player_outcome [player, computer]
|
37
37
|
when :WIN
|
38
38
|
puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
|
39
39
|
@player_score += 1;
|
@@ -47,7 +47,7 @@ class PlayRockPaperScissorsGame
|
|
47
47
|
end;
|
48
48
|
puts "\nFinal score: player: #{@player_score}, " +
|
49
49
|
"computer: #{@computer_score} (ties: #{@ties})";
|
50
|
-
case
|
50
|
+
case PrivateMethods.final_outcome(@player_score, @computer_score)
|
51
51
|
when :WIN
|
52
52
|
puts "Player wins!";
|
53
53
|
when :LOSE
|
@@ -57,7 +57,7 @@ class PlayRockPaperScissorsGame
|
|
57
57
|
end;
|
58
58
|
gets;
|
59
59
|
end;
|
60
|
-
require "ref/
|
60
|
+
require "ref/PrivateMethods.rb";
|
61
61
|
end;
|
62
62
|
end;
|
63
63
|
end;
|
data/rps.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "PlayRockPaperScissorsGame"
|
3
|
-
spec.version = "1.4.
|
3
|
+
spec.version = "1.4.5"
|
4
4
|
spec.date = "2017-03-30"
|
5
5
|
spec.summary = "A Rock Paper Scissors Ruby Gem"
|
6
6
|
spec.description = "A Ruby-programmed rock paper scissors game. To install: gem install PlayRockPaperScissorsGame; To run: rps; or: PlayRockPaperScissorsGame"
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.email = "" # email is disclosed for privacy reasons
|
9
9
|
spec.platform = Gem::Platform::RUBY
|
10
10
|
spec.require_paths = ["lib", "test", "exec", "bin"]
|
11
|
-
spec.files = ["lib/rps.rb", "lib/ref/
|
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
12
|
spec.bindir = "bin"
|
13
13
|
spec.executables << "rps"
|
14
14
|
spec.executables << "PlayRockPaperScissorsGame"
|
data/test/test_rps.rb
CHANGED
@@ -36,11 +36,11 @@ class Test
|
|
36
36
|
while @player_score < winning_score && @computer_score < winning_score
|
37
37
|
puts "Player score: #{@player_score}, " +
|
38
38
|
"Computer score: #{@computer_score}, Ties: #{@ties}";
|
39
|
-
player =
|
39
|
+
player = PrivateMethods.player_choice;
|
40
40
|
computer = Constants::COMPUTER_CHOICES.sample;
|
41
41
|
puts "\nPlayer chooses #{player.to_s.downcase}";
|
42
42
|
puts "Computer chooses #{computer.to_s.downcase}";
|
43
|
-
case
|
43
|
+
case PrivateMethods.player_outcome [player, computer]
|
44
44
|
when :WIN
|
45
45
|
puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
|
46
46
|
@player_score += 1;
|
@@ -54,7 +54,7 @@ class Test
|
|
54
54
|
end;
|
55
55
|
puts "\nFinal score: player: #{@player_score}, " +
|
56
56
|
"computer: #{@computer_score} (ties: #{@ties})";
|
57
|
-
case
|
57
|
+
case PrivateMethods.final_outcome(@player_score, @computer_score)
|
58
58
|
when :WIN
|
59
59
|
puts "Player wins!";
|
60
60
|
when :LOSE
|
@@ -65,7 +65,7 @@ class Test
|
|
65
65
|
gets;
|
66
66
|
end;
|
67
67
|
private;
|
68
|
-
module
|
68
|
+
module PrivateMethods
|
69
69
|
class << self
|
70
70
|
def player_choice
|
71
71
|
loop do
|
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.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bag3318
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- exec/run.bat
|
73
73
|
- exec/uninstall.sh
|
74
74
|
- lib/ref/Constants.rb
|
75
|
-
- lib/ref/
|
75
|
+
- lib/ref/PrivateMethods.rb
|
76
76
|
- lib/rps.rb
|
77
77
|
- rps.gemspec
|
78
78
|
- test/test_rps.rb
|