PlayRockPaperScissorsGame 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ref/Constants.rb +20 -0
- data/lib/ref/PrivateVars.rb +23 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b9edbcb6a87123e1e532b3dd15c82f5074354b
|
4
|
+
data.tar.gz: 5f924307d6ab9a932ef1c701f60c9a222b96b3b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 441c7b47b99e74d7a04dad9b3a84b72849cee179f2c2d1b53bc2e7856a412a76cbdbd9326925a73593b3fc16d870820513ee5d55c7c710bc9e50664b772f75c1
|
7
|
+
data.tar.gz: e7c7b195d45979090677cd08b9764040f13ee0bf100a6a96bf30465dec4c879b7894b833e91d460776bc73570885f97712d566b8a7816c85d48ec6349f271c91
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Constants
|
2
|
+
NTRY_TO_SYM = {
|
3
|
+
'p' => :PAPER,
|
4
|
+
'r' => :ROCK,
|
5
|
+
's' => :SCISSORS
|
6
|
+
};
|
7
|
+
VALID_ENTRIES = NTRY_TO_SYM.keys;
|
8
|
+
COMPUTER_CHOICES = NTRY_TO_SYM.values;
|
9
|
+
WINNERS = [
|
10
|
+
[:SCISSORS, :PAPER],
|
11
|
+
[:PAPER, :ROCK],
|
12
|
+
[:ROCK, :SCISSORS]
|
13
|
+
]; # format: player choice, computer choice
|
14
|
+
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
|
15
|
+
INIT_STRINGS = [
|
16
|
+
"You are about to enter a rock-paper-scissors best of 3 match.",
|
17
|
+
"Press the return/enter key to continue...",
|
18
|
+
""
|
19
|
+
];
|
20
|
+
end;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
private
|
2
|
+
module PrivateVars
|
3
|
+
class << self
|
4
|
+
def player_choice
|
5
|
+
loop do
|
6
|
+
print "Choose rock (r), paper (p) or scissors (s): ";
|
7
|
+
choice = gets.chomp.downcase;
|
8
|
+
return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice);
|
9
|
+
puts "That entry is invalid. Please re-enter";
|
10
|
+
end;
|
11
|
+
end;
|
12
|
+
def player_outcome(plays)
|
13
|
+
return :WIN if Constants::WINNERS.include?(plays);
|
14
|
+
return :LOSE if Constants::LOSERS.include?(plays);
|
15
|
+
return :TIE if !:WIN | !:LOSE;
|
16
|
+
end;
|
17
|
+
def final_outcome(pl, co)
|
18
|
+
return :WIN if pl > co;
|
19
|
+
return :LOSE if pl < co;
|
20
|
+
return :TIE if pl = co;
|
21
|
+
end;
|
22
|
+
end;
|
23
|
+
end;
|
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.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bag3318
|
@@ -64,6 +64,8 @@ files:
|
|
64
64
|
- README.md
|
65
65
|
- bin/PlayRockPaperScissorsGame
|
66
66
|
- bin/rps
|
67
|
+
- lib/ref/Constants.rb
|
68
|
+
- lib/ref/PrivateVars.rb
|
67
69
|
- lib/rps.rb
|
68
70
|
homepage: https://rubygems.org/gems/PlayRockPaperScissorsGame/
|
69
71
|
licenses:
|