rpsg 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -7
- data/Rakefile +8 -0
- data/bin/rpsg +8 -10
- data/html/Constants.html +138 -0
- data/html/PrivateMethods.html +241 -0
- data/html/README_md.html +139 -0
- data/html/RPSG.html +112 -0
- data/html/RockPapaerScissorsGame.html +268 -0
- data/html/created.rid +7 -0
- data/html/css/fonts.css +167 -0
- data/html/css/rdoc.css +590 -0
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +96 -0
- data/html/js/darkfish.js +161 -0
- data/html/js/jquery.js +4 -0
- data/html/js/navigation.js +142 -0
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +109 -0
- data/html/js/search_index.js +1 -0
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +229 -0
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +101 -0
- data/lib/Constants.rb +19 -11
- data/lib/PrivateMethods.rb +4 -0
- data/lib/rpsg/version.rb +3 -1
- data/rpsg.gemspec +1 -1
- data/test/rpsg.rb +1 -0
- metadata +51 -1
data/lib/Constants.rb
CHANGED
@@ -1,22 +1,30 @@
|
|
1
|
+
# create module that holds all contents for this script
|
1
2
|
module Constants
|
2
|
-
|
3
|
-
|
3
|
+
|
4
|
+
# create 2d list of choices
|
5
|
+
CHOICES = [['r', 'rock'], ['p', 'paper'], ['s', 'scissors']]
|
6
|
+
|
7
|
+
# define entry to symbol (key to value)
|
8
|
+
NTRY_TO_SYM = {
|
4
9
|
CHOICES[0][0] => :ROCK , CHOICES[0][1] => :ROCK ,
|
5
10
|
CHOICES[1][0] => :PAPER , CHOICES[1][1] => :PAPER ,
|
6
11
|
CHOICES[2][0] => :SCISSORS, CHOICES[2][1] => :SCISSORS
|
7
12
|
}
|
8
|
-
|
9
|
-
|
13
|
+
|
14
|
+
# define valid entries
|
15
|
+
VALID_ENTRIES = NTRY_TO_SYM.keys
|
16
|
+
|
17
|
+
# define computer choices
|
18
|
+
COMPUTER_CHOICES = NTRY_TO_SYM.values
|
19
|
+
|
20
|
+
# create winners 2d list array with format: winning choice, losing choice
|
10
21
|
WINNERS = [
|
11
|
-
# format: player choice, computer choice
|
12
22
|
[:SCISSORS, :PAPER ],
|
13
23
|
[:PAPER , :ROCK ],
|
14
24
|
[:ROCK , :SCISSORS]
|
15
25
|
]
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
""
|
21
|
-
]
|
26
|
+
|
27
|
+
# this will take the original WINNERS array and flip the symbols, thus returning a loss for the user/player
|
28
|
+
LOSERS = WINNERS.map { |winning_choice,losing_choice| [losing_choice,winning_choice] }
|
29
|
+
|
22
30
|
end
|
data/lib/PrivateMethods.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# add module for private methods for the rpsg calculations
|
1
2
|
module PrivateMethods
|
2
3
|
class << self
|
4
|
+
# make a definition that asks for the players choice
|
3
5
|
def player_choice
|
4
6
|
loop do
|
5
7
|
print "\nChoose: Rock (r), Paper (p), or Scissors (s): \n"
|
@@ -20,11 +22,13 @@ module PrivateMethods
|
|
20
22
|
# end
|
21
23
|
end
|
22
24
|
end
|
25
|
+
# define outcomes of players choice against cpu
|
23
26
|
def player_outcome(plays)
|
24
27
|
return :WIN if Constants::WINNERS.include?(plays)
|
25
28
|
return :LOSE if Constants::LOSERS.include?(plays)
|
26
29
|
return :TIE if !:WIN | !:LOSE
|
27
30
|
end
|
31
|
+
# define final outcome that gives the result of who one the whole match
|
28
32
|
def final_outcome(pl,co)
|
29
33
|
return :WIN if pl > co
|
30
34
|
return :LOSE if pl < co
|
data/lib/rpsg/version.rb
CHANGED
data/rpsg.gemspec
CHANGED
data/test/rpsg.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpsg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bag3318
|
@@ -85,6 +85,56 @@ files:
|
|
85
85
|
- README.md
|
86
86
|
- Rakefile
|
87
87
|
- bin/rpsg
|
88
|
+
- html/Constants.html
|
89
|
+
- html/PrivateMethods.html
|
90
|
+
- html/README_md.html
|
91
|
+
- html/RPSG.html
|
92
|
+
- html/RockPapaerScissorsGame.html
|
93
|
+
- html/created.rid
|
94
|
+
- html/css/fonts.css
|
95
|
+
- html/css/rdoc.css
|
96
|
+
- html/fonts/Lato-Light.ttf
|
97
|
+
- html/fonts/Lato-LightItalic.ttf
|
98
|
+
- html/fonts/Lato-Regular.ttf
|
99
|
+
- html/fonts/Lato-RegularItalic.ttf
|
100
|
+
- html/fonts/SourceCodePro-Bold.ttf
|
101
|
+
- html/fonts/SourceCodePro-Regular.ttf
|
102
|
+
- html/images/add.png
|
103
|
+
- html/images/arrow_up.png
|
104
|
+
- html/images/brick.png
|
105
|
+
- html/images/brick_link.png
|
106
|
+
- html/images/bug.png
|
107
|
+
- html/images/bullet_black.png
|
108
|
+
- html/images/bullet_toggle_minus.png
|
109
|
+
- html/images/bullet_toggle_plus.png
|
110
|
+
- html/images/date.png
|
111
|
+
- html/images/delete.png
|
112
|
+
- html/images/find.png
|
113
|
+
- html/images/loadingAnimation.gif
|
114
|
+
- html/images/macFFBgHack.png
|
115
|
+
- html/images/package.png
|
116
|
+
- html/images/page_green.png
|
117
|
+
- html/images/page_white_text.png
|
118
|
+
- html/images/page_white_width.png
|
119
|
+
- html/images/plugin.png
|
120
|
+
- html/images/ruby.png
|
121
|
+
- html/images/tag_blue.png
|
122
|
+
- html/images/tag_green.png
|
123
|
+
- html/images/transparent.png
|
124
|
+
- html/images/wrench.png
|
125
|
+
- html/images/wrench_orange.png
|
126
|
+
- html/images/zoom.png
|
127
|
+
- html/index.html
|
128
|
+
- html/js/darkfish.js
|
129
|
+
- html/js/jquery.js
|
130
|
+
- html/js/navigation.js
|
131
|
+
- html/js/navigation.js.gz
|
132
|
+
- html/js/search.js
|
133
|
+
- html/js/search_index.js
|
134
|
+
- html/js/search_index.js.gz
|
135
|
+
- html/js/searcher.js
|
136
|
+
- html/js/searcher.js.gz
|
137
|
+
- html/table_of_contents.html
|
88
138
|
- lib/Constants.rb
|
89
139
|
- lib/PrivateMethods.rb
|
90
140
|
- lib/rpsg/version.rb
|