rpsg 0.1.5 → 0.1.6
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/bin/rpsg +3 -69
- data/html/Constants.html +1 -1
- data/html/PrivateMethods.html +1 -1
- data/html/README_md.html +1 -1
- data/html/RPSG.html +1 -1
- data/html/RockPaperScissorsGame.html +4 -4
- data/html/created.rid +4 -3
- data/html/index.html +1 -1
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +1 -1
- data/lib/Main.rb +69 -0
- data/lib/rpsg/version.rb +1 -1
- data/rpsg.gemspec +7 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f7b37b3919a94dc8db713df202111e4a973e869
|
4
|
+
data.tar.gz: 60ebeb201bbb4433d0c986dc69bbef40a3e1cfbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24eccb1c2fdab5c688556896711051965ad4137264a19018aa97b9f47f0e23a57a7adc78b5141b42ac3e41d6339f9e6a0ce9806096602ca9097ea73b90b7dddf
|
7
|
+
data.tar.gz: 2f98f193f39670da4aad309eabaa41b7b429031308c74807ef1baee4d82f56def43d9a5d47504b088ae4f29e6c65dc3768c624e857ebb89ca34d23da81b8658c
|
data/bin/rpsg
CHANGED
@@ -1,75 +1,9 @@
|
|
1
1
|
#!/usr/bin/env rubyn
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
lib = File.expand_path("../../lib", __FILE__)
|
3
|
+
lib = File.expand_path("../../lib", __FILE__)
|
6
4
|
|
7
|
-
$:.unshift(lib)
|
8
5
|
|
9
|
-
|
6
|
+
$:.unshift(lib)
|
10
7
|
|
11
|
-
|
8
|
+
load "Main.rb"
|
12
9
|
|
13
|
-
protected_methods :Constants
|
14
|
-
|
15
|
-
class << self
|
16
|
-
# add continue method for asking the user if they want to play rock paper scissors
|
17
|
-
def continue(str1,str2,str3)
|
18
|
-
puts str1
|
19
|
-
print str2
|
20
|
-
gets
|
21
|
-
puts str3
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# print out strings
|
26
|
-
continue("You are about to enter a rock-paper-scissors best of 3 match.", "Press the return/enter key to continue...", "")
|
27
|
-
|
28
|
-
# initialize variables
|
29
|
-
def initialize
|
30
|
-
# set all equal to zero
|
31
|
-
@player_score = @computer_score = @ties = 0
|
32
|
-
end
|
33
|
-
|
34
|
-
# define play method, this will be the main function for playing rock paper scissors
|
35
|
-
def play(winning_score)
|
36
|
-
# make while loop
|
37
|
-
while @player_score < winning_score && @computer_score < winning_score
|
38
|
-
puts "Player score: #{@player_score}, " +
|
39
|
-
"Computer score: #{@computer_score}, Ties: #{@ties}.\n"
|
40
|
-
player = PrivateMethods.player_choice
|
41
|
-
computer = Constants::COMPUTER_CHOICES.sample # chooses a random option
|
42
|
-
puts "\nPlayer chooses #{player.to_s.downcase}."
|
43
|
-
puts "Computer chooses #{computer.to_s.downcase}.\n"
|
44
|
-
case PrivateMethods.player_outcome [player, computer]
|
45
|
-
when :WIN
|
46
|
-
puts "\n#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round.\n"
|
47
|
-
@player_score += 1
|
48
|
-
when :LOSE
|
49
|
-
puts "\n#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round.\n"
|
50
|
-
@computer_score += 1
|
51
|
-
else
|
52
|
-
puts "\nTie, choose again\n"
|
53
|
-
@ties += 1
|
54
|
-
end
|
55
|
-
end
|
56
|
-
puts "\nFinal score: player: #{@player_score}, " +
|
57
|
-
"computer: #{@computer_score} (ties: #{@ties}).\n"
|
58
|
-
case PrivateMethods.final_outcome(@player_score, @computer_score)
|
59
|
-
when :WIN
|
60
|
-
puts "\nPlayer wins!"
|
61
|
-
when :LOSE
|
62
|
-
puts "\nComputer wins!"
|
63
|
-
else
|
64
|
-
puts "\nIt's a tie!"
|
65
|
-
end
|
66
|
-
gets
|
67
|
-
end
|
68
|
-
|
69
|
-
require "PrivateMethods.rb"
|
70
|
-
|
71
|
-
private_methods :PrivateMethods
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
RockPaperScissorsGame.new.play(2) # best of 3 (0, 1, 2)
|
data/html/Constants.html
CHANGED
@@ -132,7 +132,7 @@ array and flip the symbols, thus returning a loss for the user/player</p>
|
|
132
132
|
|
133
133
|
<footer id="validator-badges" role="contentinfo">
|
134
134
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
135
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.
|
135
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
136
136
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
137
137
|
</footer>
|
138
138
|
|
data/html/PrivateMethods.html
CHANGED
@@ -235,7 +235,7 @@
|
|
235
235
|
|
236
236
|
<footer id="validator-badges" role="contentinfo">
|
237
237
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
238
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.
|
238
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
239
239
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
240
240
|
</footer>
|
241
241
|
|
data/html/README_md.html
CHANGED
@@ -133,7 +133,7 @@ href="https://rubygems.org/gems/rpsg">rubygems.org/gems/rpsg</a></p>
|
|
133
133
|
|
134
134
|
<footer id="validator-badges" role="contentinfo">
|
135
135
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
136
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.
|
136
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
137
137
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
138
138
|
</footer>
|
139
139
|
|
data/html/RPSG.html
CHANGED
@@ -106,7 +106,7 @@
|
|
106
106
|
|
107
107
|
<footer id="validator-badges" role="contentinfo">
|
108
108
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
109
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.
|
109
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
110
110
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
111
111
|
</footer>
|
112
112
|
|
@@ -131,7 +131,7 @@ scissors</p>
|
|
131
131
|
|
132
132
|
|
133
133
|
<div class="method-source-code" id="continue-source">
|
134
|
-
<pre><span class="ruby-comment"># File
|
134
|
+
<pre><span class="ruby-comment"># File lib/Main.rb, line 11</span>
|
135
135
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">continue</span>(<span class="ruby-identifier">str1</span>,<span class="ruby-identifier">str2</span>,<span class="ruby-identifier">str3</span>)
|
136
136
|
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">str1</span>
|
137
137
|
<span class="ruby-identifier">print</span> <span class="ruby-identifier">str2</span>
|
@@ -167,7 +167,7 @@ scissors</p>
|
|
167
167
|
|
168
168
|
|
169
169
|
<div class="method-source-code" id="new-source">
|
170
|
-
<pre><span class="ruby-comment"># File
|
170
|
+
<pre><span class="ruby-comment"># File lib/Main.rb, line 23</span>
|
171
171
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
|
172
172
|
<span class="ruby-comment"># set all equal to zero</span>
|
173
173
|
<span class="ruby-ivar">@player_score</span> = <span class="ruby-ivar">@computer_score</span> = <span class="ruby-ivar">@ties</span> = <span class="ruby-value">0</span>
|
@@ -210,7 +210,7 @@ scissors</p>
|
|
210
210
|
|
211
211
|
|
212
212
|
<div class="method-source-code" id="play-source">
|
213
|
-
<pre><span class="ruby-comment"># File
|
213
|
+
<pre><span class="ruby-comment"># File lib/Main.rb, line 29</span>
|
214
214
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">play</span>(<span class="ruby-identifier">winning_score</span>)
|
215
215
|
<span class="ruby-comment"># make while loop</span>
|
216
216
|
<span class="ruby-keyword">while</span> <span class="ruby-ivar">@player_score</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">winning_score</span> <span class="ruby-operator">&&</span> <span class="ruby-ivar">@computer_score</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">winning_score</span>
|
@@ -262,7 +262,7 @@ scissors</p>
|
|
262
262
|
|
263
263
|
<footer id="validator-badges" role="contentinfo">
|
264
264
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
265
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.
|
265
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
266
266
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
267
267
|
</footer>
|
268
268
|
|
data/html/created.rid
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
Thu, 12 Oct 2017
|
1
|
+
Thu, 12 Oct 2017 15:00:25 -0700
|
2
2
|
README.md Thu, 12 Oct 2017 12:13:30 -0700
|
3
3
|
lib/Constants.rb Thu, 12 Oct 2017 14:19:30 -0700
|
4
|
+
lib/Main.rb Thu, 12 Oct 2017 14:57:30 -0700
|
4
5
|
lib/PrivateMethods.rb Thu, 12 Oct 2017 13:53:33 -0700
|
5
|
-
lib/rpsg/version.rb Thu, 12 Oct 2017 14:39
|
6
|
-
bin/rpsg Thu, 12 Oct 2017 14:
|
6
|
+
lib/rpsg/version.rb Thu, 12 Oct 2017 14:45:39 -0700
|
7
|
+
bin/rpsg Thu, 12 Oct 2017 14:57:41 -0700
|
7
8
|
test/rpsg.rb Thu, 12 Oct 2017 14:13:08 -0700
|
data/html/index.html
CHANGED
@@ -90,7 +90,7 @@
|
|
90
90
|
|
91
91
|
<footer id="validator-badges" role="contentinfo">
|
92
92
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
93
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.
|
93
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
94
94
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
95
95
|
</footer>
|
96
96
|
|
data/html/js/navigation.js.gz
CHANGED
Binary file
|
data/html/js/search_index.js.gz
CHANGED
Binary file
|
data/html/js/searcher.js.gz
CHANGED
Binary file
|
data/html/table_of_contents.html
CHANGED
@@ -95,7 +95,7 @@
|
|
95
95
|
|
96
96
|
<footer id="validator-badges" role="contentinfo">
|
97
97
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
98
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.
|
98
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
99
99
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
100
100
|
</footer>
|
101
101
|
|
data/lib/Main.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
class RockPaperScissorsGame
|
2
|
+
|
3
|
+
require "rpsg/version.rb"
|
4
|
+
|
5
|
+
require "Constants.rb"
|
6
|
+
|
7
|
+
protected_methods :Constants
|
8
|
+
|
9
|
+
class << self
|
10
|
+
# add continue method for asking the user if they want to play rock paper scissors
|
11
|
+
def continue(str1,str2,str3)
|
12
|
+
puts str1
|
13
|
+
print str2
|
14
|
+
gets
|
15
|
+
puts str3
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# print out strings
|
20
|
+
continue("You are about to enter a rock-paper-scissors best of 3 match.", "Press the return/enter key to continue...", "")
|
21
|
+
|
22
|
+
# initialize variables
|
23
|
+
def initialize
|
24
|
+
# set all equal to zero
|
25
|
+
@player_score = @computer_score = @ties = 0
|
26
|
+
end
|
27
|
+
|
28
|
+
# define play method, this will be the main function for playing rock paper scissors
|
29
|
+
def play(winning_score)
|
30
|
+
# make while loop
|
31
|
+
while @player_score < winning_score && @computer_score < winning_score
|
32
|
+
puts "Player score: #{@player_score}, " +
|
33
|
+
"Computer score: #{@computer_score}, Ties: #{@ties}.\n"
|
34
|
+
player = PrivateMethods.player_choice
|
35
|
+
computer = Constants::COMPUTER_CHOICES.sample # chooses a random option
|
36
|
+
puts "\nPlayer chooses #{player.to_s.downcase}."
|
37
|
+
puts "Computer chooses #{computer.to_s.downcase}.\n"
|
38
|
+
case PrivateMethods.player_outcome [player, computer]
|
39
|
+
when :WIN
|
40
|
+
puts "\n#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round.\n"
|
41
|
+
@player_score += 1
|
42
|
+
when :LOSE
|
43
|
+
puts "\n#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round.\n"
|
44
|
+
@computer_score += 1
|
45
|
+
else
|
46
|
+
puts "\nTie, choose again\n"
|
47
|
+
@ties += 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
puts "\nFinal score: player: #{@player_score}, " +
|
51
|
+
"computer: #{@computer_score} (ties: #{@ties}).\n"
|
52
|
+
case PrivateMethods.final_outcome(@player_score, @computer_score)
|
53
|
+
when :WIN
|
54
|
+
puts "\nPlayer wins!"
|
55
|
+
when :LOSE
|
56
|
+
puts "\nComputer wins!"
|
57
|
+
else
|
58
|
+
puts "\nIt's a tie!"
|
59
|
+
end
|
60
|
+
gets
|
61
|
+
end
|
62
|
+
|
63
|
+
require "PrivateMethods.rb"
|
64
|
+
|
65
|
+
private_methods :PrivateMethods
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
RockPaperScissorsGame.new.play(2) # best of 3 (0, 1, 2)
|
data/lib/rpsg/version.rb
CHANGED
data/rpsg.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "rpsg"
|
3
|
-
spec.version = "0.1.
|
3
|
+
spec.version = "0.1.6"
|
4
4
|
spec.date = "2017-10-12"
|
5
5
|
spec.summary = "A Rock Paper Scissors Game Ruby Gem"
|
6
6
|
spec.description = <<-EOF
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ""
|
12
12
|
spec.homepage = "https://rubygems.org/gems/rpsg"
|
13
13
|
spec.platform = Gem::Platform::RUBY
|
14
|
-
spec.require_paths = ["lib"
|
14
|
+
spec.require_paths = ["lib"]
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
16
16
|
spec.post_install_message = <<-EOF
|
17
17
|
Thanks for installing! I hope you will have fun playing rock paper scissors! :)
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.license = "MIT"
|
20
20
|
spec.required_ruby_version = ">= 2.0.0"
|
21
21
|
spec.required_rubygems_version = ">= 2.6.0"
|
22
|
-
spec.extra_rdoc_files = "
|
22
|
+
spec.extra_rdoc_files = "README.md"
|
23
23
|
spec.bindir = "bin"
|
24
24
|
spec.metadata = {
|
25
25
|
"issue_tracker" => "https://github.com/bag3318/RPSG/issues",
|
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
}
|
28
28
|
spec.executables << "rpsg"
|
29
29
|
spec.requirements << "A Windows or Mac computer"
|
30
|
-
spec.add_runtime_dependency 'rake'
|
31
|
-
spec.add_runtime_dependency 'rvm'
|
32
|
-
spec.add_runtime_dependency 'bundler', '~> 1.14', '>= 1.14.6'
|
33
|
-
spec.
|
30
|
+
spec.add_runtime_dependency 'rake' , '~> 12.0', '>= 12.0.0'
|
31
|
+
spec.add_runtime_dependency 'rvm' , '~> 1.11', '>= 1.11.3.9'
|
32
|
+
spec.add_runtime_dependency 'bundler' , '~> 1.14', '>= 1.14.6'
|
33
|
+
spec.add_runtime_dependency 'rdoc' , '~> 5.1' , '>= 5.1.0'
|
34
34
|
end
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bag3318
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 5.1.0
|
83
|
-
type: :
|
83
|
+
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
@@ -97,7 +97,7 @@ executables:
|
|
97
97
|
- rpsg
|
98
98
|
extensions: []
|
99
99
|
extra_rdoc_files:
|
100
|
-
-
|
100
|
+
- README.md
|
101
101
|
files:
|
102
102
|
- ".gitignore"
|
103
103
|
- Gemfile
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- html/js/searcher.js.gz
|
157
157
|
- html/table_of_contents.html
|
158
158
|
- lib/Constants.rb
|
159
|
+
- lib/Main.rb
|
159
160
|
- lib/PrivateMethods.rb
|
160
161
|
- lib/rpsg/version.rb
|
161
162
|
- rpsg.gemspec
|
@@ -171,7 +172,6 @@ post_install_message: " Thanks for installing! I hope you will have fun playi
|
|
171
172
|
rdoc_options: []
|
172
173
|
require_paths:
|
173
174
|
- lib
|
174
|
-
- bin
|
175
175
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
177
|
- - ">="
|