rpsg 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/PrivateMethods.html +3 -3
- data/doc/RockPaperScissorsGame.html +4 -3
- data/doc/created.rid +5 -5
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js.gz +0 -0
- data/docs/_includes/footer.html +1 -1
- data/docs/_pages/README.txt +1 -0
- data/docs/_pages/code.txt +28 -14
- data/docs/_site/bundler.html +2 -2
- data/docs/_site/code.html +31 -17
- data/docs/_site/index.html +2 -2
- data/docs/_site/install.html +2 -2
- data/docs/_site/readme.html +4 -3
- data/docs/_site/simple.html +2 -2
- data/docs/_site/test.html +2 -2
- data/docs/_site/uninstall.html +2 -2
- data/docs/_site/update.html +2 -2
- data/lib/Constants.rb +6 -0
- data/lib/Main.rb +6 -5
- data/lib/PrivateMethods.rb +2 -0
- data/lib/rpsg/version.rb +1 -1
- data/rpsg.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 947eb3ec6ff66507a85bf6b755a6ec73ea01bbb6
|
4
|
+
data.tar.gz: 53dbc36684f843eae9a2dab5cc118b7cb0918631
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6065a2da2817620cc64ef55b682d042d661e04f7612bd47f010b4ae31ea62477f1828531e21c70af6ebe7dc5fb1ae8409e422dd0ae68d3cc2eb6da36ae66ff6a
|
7
|
+
data.tar.gz: ff00629721be7560b4f4cc1ed78fd4a13a2c7a0e826d39453ce92e4f92b158bfbffb660d0084bf519c6e96ab1ff7e19fb7201a7af696d73f69b2229eea3c859d
|
data/doc/PrivateMethods.html
CHANGED
@@ -125,7 +125,7 @@
|
|
125
125
|
|
126
126
|
|
127
127
|
<div class="method-source-code" id="final_outcome-source">
|
128
|
-
<pre><span class="ruby-comment"># File lib/PrivateMethods.rb, line
|
128
|
+
<pre><span class="ruby-comment"># File lib/PrivateMethods.rb, line 33</span>
|
129
129
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">final_outcome</span>(<span class="ruby-identifier">pl</span>,<span class="ruby-identifier">co</span>)
|
130
130
|
<span class="ruby-keyword">return</span> <span class="ruby-value">:WIN</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">pl</span> <span class="ruby-operator">></span> <span class="ruby-identifier">co</span>
|
131
131
|
<span class="ruby-keyword">return</span> <span class="ruby-value">:LOSE</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">pl</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">co</span>
|
@@ -161,7 +161,7 @@
|
|
161
161
|
|
162
162
|
|
163
163
|
<div class="method-source-code" id="player_choice-source">
|
164
|
-
<pre><span class="ruby-comment"># File lib/PrivateMethods.rb, line
|
164
|
+
<pre><span class="ruby-comment"># File lib/PrivateMethods.rb, line 6</span>
|
165
165
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">player_choice</span>
|
166
166
|
<span class="ruby-identifier">loop</span> <span class="ruby-keyword">do</span>
|
167
167
|
<span class="ruby-identifier">print</span> <span class="ruby-string">"\nChoose: Rock (r), Paper (p), or Scissors (s): "</span>
|
@@ -211,7 +211,7 @@
|
|
211
211
|
|
212
212
|
|
213
213
|
<div class="method-source-code" id="player_outcome-source">
|
214
|
-
<pre><span class="ruby-comment"># File lib/PrivateMethods.rb, line
|
214
|
+
<pre><span class="ruby-comment"># File lib/PrivateMethods.rb, line 27</span>
|
215
215
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">player_outcome</span>(<span class="ruby-identifier">plays</span>)
|
216
216
|
<span class="ruby-keyword">return</span> <span class="ruby-value">:WIN</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">Constants</span><span class="ruby-operator">::</span><span class="ruby-constant">WINNERS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">plays</span>)
|
217
217
|
<span class="ruby-keyword">return</span> <span class="ruby-value">:LOSE</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">Constants</span><span class="ruby-operator">::</span><span class="ruby-constant">LOSERS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">plays</span>)
|
@@ -238,12 +238,13 @@ scissors</p>
|
|
238
238
|
<span class="ruby-node">"computer: #{@computer_score} (ties: #{@ties}).\n"</span>
|
239
239
|
<span class="ruby-keyword">case</span> <span class="ruby-constant">PrivateMethods</span>.<span class="ruby-identifier">final_outcome</span>(<span class="ruby-ivar">@player_score</span>, <span class="ruby-ivar">@computer_score</span>)
|
240
240
|
<span class="ruby-keyword">when</span> <span class="ruby-value">:WIN</span>
|
241
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"\nPlayer wins
|
241
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">"\nPlayer wins!\n"</span>
|
242
242
|
<span class="ruby-keyword">when</span> <span class="ruby-value">:LOSE</span>
|
243
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"\nComputer wins
|
243
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">"\nComputer wins!\n"</span>
|
244
244
|
<span class="ruby-keyword">else</span>
|
245
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"\nIt's a tie
|
245
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">"\nIt's a tie!\n"</span>
|
246
246
|
<span class="ruby-keyword">end</span>
|
247
|
+
<span class="ruby-identifier">print</span> <span class="ruby-string">"\n[press any key to exit game]"</span>
|
247
248
|
<span class="ruby-identifier">gets</span>
|
248
249
|
<span class="ruby-keyword">end</span></pre>
|
249
250
|
</div>
|
data/doc/created.rid
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
Mon, 16 Oct 2017
|
2
|
-
lib/Constants.rb
|
3
|
-
lib/Main.rb
|
4
|
-
lib/PrivateMethods.rb
|
5
|
-
lib/rpsg/version.rb
|
1
|
+
Mon, 16 Oct 2017 11:40:37 -0700
|
2
|
+
lib/Constants.rb Mon, 16 Oct 2017 10:51:39 -0700
|
3
|
+
lib/Main.rb Mon, 16 Oct 2017 11:33:54 -0700
|
4
|
+
lib/PrivateMethods.rb Mon, 16 Oct 2017 10:51:29 -0700
|
5
|
+
lib/rpsg/version.rb Mon, 16 Oct 2017 07:50:02 -0700
|
data/doc/js/navigation.js.gz
CHANGED
Binary file
|
data/doc/js/search_index.js.gz
CHANGED
Binary file
|
data/doc/js/searcher.js.gz
CHANGED
Binary file
|
data/docs/_includes/footer.html
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
<td><a href="{{ domain }}install">Install</a></td>
|
9
9
|
<td><a href="{{ domain }}update">Update</a></td>
|
10
10
|
<td><a href="{{ domain }}uninstall">Uninstall</a></td>
|
11
|
-
<td><a href="{{ domain }}code">
|
11
|
+
<td><a href="{{ domain }}code">Full Code</a></td>
|
12
12
|
<td><a href="{{ domain }}simple">Simple Code</td>
|
13
13
|
<td><a href="{{ domain }}bundler">{% comment %}Using {% endcomment %}Bundler</a></td>
|
14
14
|
</tr>
|
data/docs/_pages/README.txt
CHANGED
data/docs/_pages/code.txt
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
---
|
2
2
|
layout: default
|
3
3
|
permalink: /code.html
|
4
|
-
title: "
|
4
|
+
title: "Complete Code - RPSG"
|
5
5
|
---
|
6
6
|
|
7
7
|
{::comment}
|
8
8
|
contains complete RPSG code
|
9
9
|
{:/comment}
|
10
10
|
|
11
|
-
#
|
11
|
+
# Complete Code
|
12
12
|
|
13
13
|
* auto-gen TOC:
|
14
14
|
{:toc}
|
15
15
|
|
16
|
-
> The
|
16
|
+
> The complete code will look like this:
|
17
17
|
|
18
18
|
```
|
19
19
|
% rpsg
|
@@ -23,23 +23,31 @@ contains complete RPSG code
|
|
23
23
|
#!/usr/bin/env ruby
|
24
24
|
|
25
25
|
=begin
|
26
|
-
|
27
|
-
| Req Ruby Ver |
|
28
|
-
|
29
|
-
| >= v2.0.0 |
|
30
|
-
|
26
|
+
|====================================|
|
27
|
+
| Req Ruby Ver | Req Ruby Gems Ver |
|
28
|
+
|--------------|---------------------|
|
29
|
+
| >= v2.0.0 | >= v2.6.0 |
|
30
|
+
|====================================|
|
31
31
|
=end
|
32
32
|
|
33
33
|
# create master class for rpsg
|
34
34
|
class RockPaperScissorsGame
|
35
35
|
|
36
|
+
# specify the version for the rubygem
|
37
|
+
module RPSG
|
38
|
+
# create version constant for the rubygem
|
39
|
+
VERSION = "0.3.3"
|
40
|
+
end
|
41
|
+
|
36
42
|
# create module that holds all contents for this script
|
37
43
|
module Constants
|
38
44
|
|
39
45
|
# create 2d list of choices
|
46
|
+
protected
|
40
47
|
CHOICES = [['r', 'rock'], ['p', 'paper'], ['s', 'scissors']]
|
41
48
|
|
42
49
|
# define entry to symbol (key to value)
|
50
|
+
protected
|
43
51
|
NTRY_TO_SYM = {
|
44
52
|
CHOICES[0][0] => :ROCK , CHOICES[0][1] => :ROCK ,
|
45
53
|
CHOICES[1][0] => :PAPER , CHOICES[1][1] => :PAPER ,
|
@@ -47,12 +55,15 @@ class RockPaperScissorsGame
|
|
47
55
|
}
|
48
56
|
|
49
57
|
# define valid entries
|
58
|
+
protected
|
50
59
|
VALID_ENTRIES = NTRY_TO_SYM.keys
|
51
60
|
|
52
61
|
# define computer choices
|
62
|
+
protected
|
53
63
|
COMPUTER_CHOICES = NTRY_TO_SYM.values
|
54
64
|
|
55
65
|
# create winners 2d list array with format: winning choice, losing choice
|
66
|
+
protected
|
56
67
|
WINNERS = [
|
57
68
|
[:SCISSORS, :PAPER ],
|
58
69
|
[:PAPER , :ROCK ],
|
@@ -60,11 +71,12 @@ class RockPaperScissorsGame
|
|
60
71
|
]
|
61
72
|
|
62
73
|
# this will take the original WINNERS array and flip the symbols, thus returning a loss for the user/player
|
74
|
+
protected
|
63
75
|
LOSERS = WINNERS.map { |winning_choice,losing_choice| [losing_choice,winning_choice] }
|
64
76
|
|
65
77
|
end
|
66
78
|
|
67
|
-
protected_methods :Constants
|
79
|
+
# protected_methods :Constants
|
68
80
|
|
69
81
|
class << self
|
70
82
|
# add continue method for asking the user if they want to play rock paper scissors
|
@@ -111,15 +123,17 @@ class RockPaperScissorsGame
|
|
111
123
|
"computer: #{@computer_score} (ties: #{@ties}).\n"
|
112
124
|
case PrivateMethods.final_outcome(@player_score, @computer_score)
|
113
125
|
when :WIN
|
114
|
-
puts "\nPlayer wins
|
126
|
+
puts "\nPlayer wins!\n"
|
115
127
|
when :LOSE
|
116
|
-
puts "\nComputer wins
|
128
|
+
puts "\nComputer wins!\n"
|
117
129
|
else
|
118
|
-
puts "\nIt's a tie
|
130
|
+
puts "\nIt's a tie!\n"
|
119
131
|
end
|
132
|
+
print "\n[press any key to exit game]"
|
120
133
|
gets
|
121
134
|
end
|
122
135
|
|
136
|
+
private
|
123
137
|
# add module for private methods for the rpsg calculations
|
124
138
|
module PrivateMethods
|
125
139
|
class << self
|
@@ -159,9 +173,9 @@ class RockPaperScissorsGame
|
|
159
173
|
end
|
160
174
|
end
|
161
175
|
end
|
162
|
-
|
176
|
+
public
|
163
177
|
|
164
|
-
private_methods :PrivateMethods
|
178
|
+
# private_methods :PrivateMethods
|
165
179
|
|
166
180
|
end
|
167
181
|
|
data/docs/_site/bundler.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
8
8
|
<meta name="theme-color" content="#157878"/>
|
9
9
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
|
10
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
10
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=a5baafbc722707c67aa6887b8c329cac4fb1a8fe"/>
|
11
11
|
<script src="assets/js/pace.min.js"></script>
|
12
12
|
|
13
13
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
|
@@ -91,7 +91,7 @@
|
|
91
91
|
<td><a href="install">Install</a></td>
|
92
92
|
<td><a href="update">Update</a></td>
|
93
93
|
<td><a href="uninstall">Uninstall</a></td>
|
94
|
-
<td><a href="code">
|
94
|
+
<td><a href="code">Full Code</a></td>
|
95
95
|
<td><a href="simple">Simple Code</td>
|
96
96
|
<td><a href="bundler">Bundler</a></td>
|
97
97
|
</tr>
|
data/docs/_site/code.html
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
<html lang="en-us">
|
3
3
|
<head>
|
4
4
|
<meta charset="UTF-8"/>
|
5
|
-
<title>
|
5
|
+
<title>Complete Code - RPSG</title>
|
6
6
|
<meta name="description" content="A Ruby Programmed Rock Paper Scissors Game"/>
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
8
8
|
<meta name="theme-color" content="#157878"/>
|
9
9
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
|
10
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
10
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=a5baafbc722707c67aa6887b8c329cac4fb1a8fe"/>
|
11
11
|
<script src="assets/js/pace.min.js"></script>
|
12
12
|
|
13
13
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
|
@@ -44,14 +44,14 @@
|
|
44
44
|
|
45
45
|
<!-- contains complete RPSG code -->
|
46
46
|
|
47
|
-
<h1 id="
|
47
|
+
<h1 id="complete-code">Complete Code</h1>
|
48
48
|
|
49
49
|
<ul id="markdown-toc">
|
50
|
-
<li><a href="#
|
50
|
+
<li><a href="#complete-code" id="markdown-toc-complete-code">Complete Code</a></li>
|
51
51
|
</ul>
|
52
52
|
|
53
53
|
<blockquote>
|
54
|
-
<p>The
|
54
|
+
<p>The complete code will look like this:</p>
|
55
55
|
</blockquote>
|
56
56
|
|
57
57
|
<div class="highlighter-rouge"><pre class="highlight"><code>% rpsg
|
@@ -61,23 +61,31 @@
|
|
61
61
|
<div class="language-ruby highlighter-rouge"><pre class="highlight"><code><span class="c1">#!/usr/bin/env ruby</span>
|
62
62
|
|
63
63
|
<span class="cm">=begin
|
64
|
-
|
65
|
-
| Req Ruby Ver |
|
66
|
-
|
67
|
-
| >= v2.0.0 |
|
68
|
-
|
64
|
+
|====================================|
|
65
|
+
| Req Ruby Ver | Req Ruby Gems Ver |
|
66
|
+
|--------------|---------------------|
|
67
|
+
| >= v2.0.0 | >= v2.6.0 |
|
68
|
+
|====================================|
|
69
69
|
=end</span>
|
70
70
|
|
71
71
|
<span class="c1"># create master class for rpsg</span>
|
72
72
|
<span class="k">class</span> <span class="nc">RockPaperScissorsGame</span>
|
73
73
|
|
74
|
+
<span class="c1"># specify the version for the rubygem</span>
|
75
|
+
<span class="k">module</span> <span class="nn">RPSG</span>
|
76
|
+
<span class="c1"># create version constant for the rubygem</span>
|
77
|
+
<span class="no">VERSION</span> <span class="o">=</span> <span class="s2">"0.3.3"</span>
|
78
|
+
<span class="k">end</span>
|
79
|
+
|
74
80
|
<span class="c1"># create module that holds all contents for this script</span>
|
75
81
|
<span class="k">module</span> <span class="nn">Constants</span>
|
76
82
|
|
77
83
|
<span class="c1"># create 2d list of choices</span>
|
84
|
+
<span class="kp">protected</span>
|
78
85
|
<span class="no">CHOICES</span> <span class="o">=</span> <span class="p">[[</span><span class="s1">'r'</span><span class="p">,</span> <span class="s1">'rock'</span><span class="p">],</span> <span class="p">[</span><span class="s1">'p'</span><span class="p">,</span> <span class="s1">'paper'</span><span class="p">],</span> <span class="p">[</span><span class="s1">'s'</span><span class="p">,</span> <span class="s1">'scissors'</span><span class="p">]]</span>
|
79
86
|
|
80
87
|
<span class="c1"># define entry to symbol (key to value)</span>
|
88
|
+
<span class="kp">protected</span>
|
81
89
|
<span class="no">NTRY_TO_SYM</span> <span class="o">=</span> <span class="p">{</span>
|
82
90
|
<span class="no">CHOICES</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=></span> <span class="ss">:ROCK</span> <span class="p">,</span> <span class="no">CHOICES</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=></span> <span class="ss">:ROCK</span> <span class="p">,</span>
|
83
91
|
<span class="no">CHOICES</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=></span> <span class="ss">:PAPER</span> <span class="p">,</span> <span class="no">CHOICES</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=></span> <span class="ss">:PAPER</span> <span class="p">,</span>
|
@@ -85,12 +93,15 @@
|
|
85
93
|
<span class="p">}</span>
|
86
94
|
|
87
95
|
<span class="c1"># define valid entries</span>
|
96
|
+
<span class="kp">protected</span>
|
88
97
|
<span class="no">VALID_ENTRIES</span> <span class="o">=</span> <span class="no">NTRY_TO_SYM</span><span class="p">.</span><span class="nf">keys</span>
|
89
98
|
|
90
99
|
<span class="c1"># define computer choices</span>
|
100
|
+
<span class="kp">protected</span>
|
91
101
|
<span class="no">COMPUTER_CHOICES</span> <span class="o">=</span> <span class="no">NTRY_TO_SYM</span><span class="p">.</span><span class="nf">values</span>
|
92
102
|
|
93
103
|
<span class="c1"># create winners 2d list array with format: winning choice, losing choice</span>
|
104
|
+
<span class="kp">protected</span>
|
94
105
|
<span class="no">WINNERS</span> <span class="o">=</span> <span class="p">[</span>
|
95
106
|
<span class="p">[</span><span class="ss">:SCISSORS</span><span class="p">,</span> <span class="ss">:PAPER</span> <span class="p">],</span>
|
96
107
|
<span class="p">[</span><span class="ss">:PAPER</span> <span class="p">,</span> <span class="ss">:ROCK</span> <span class="p">],</span>
|
@@ -98,11 +109,12 @@
|
|
98
109
|
<span class="p">]</span>
|
99
110
|
|
100
111
|
<span class="c1"># this will take the original WINNERS array and flip the symbols, thus returning a loss for the user/player</span>
|
112
|
+
<span class="kp">protected</span>
|
101
113
|
<span class="no">LOSERS</span> <span class="o">=</span> <span class="no">WINNERS</span><span class="p">.</span><span class="nf">map</span> <span class="p">{</span> <span class="o">|</span><span class="n">winning_choice</span><span class="p">,</span><span class="n">losing_choice</span><span class="o">|</span> <span class="p">[</span><span class="n">losing_choice</span><span class="p">,</span><span class="n">winning_choice</span><span class="p">]</span> <span class="p">}</span>
|
102
114
|
|
103
115
|
<span class="k">end</span>
|
104
116
|
|
105
|
-
<span class="
|
117
|
+
<span class="c1"># protected_methods :Constants</span>
|
106
118
|
|
107
119
|
<span class="k">class</span> <span class="o"><<</span> <span class="nb">self</span>
|
108
120
|
<span class="c1"># add continue method for asking the user if they want to play rock paper scissors</span>
|
@@ -149,15 +161,17 @@
|
|
149
161
|
<span class="s2">"computer: </span><span class="si">#{</span><span class="vi">@computer_score</span><span class="si">}</span><span class="s2"> (ties: </span><span class="si">#{</span><span class="vi">@ties</span><span class="si">}</span><span class="s2">).</span><span class="se">\n</span><span class="s2">"</span>
|
150
162
|
<span class="k">case</span> <span class="no">PrivateMethods</span><span class="p">.</span><span class="nf">final_outcome</span><span class="p">(</span><span class="vi">@player_score</span><span class="p">,</span> <span class="vi">@computer_score</span><span class="p">)</span>
|
151
163
|
<span class="k">when</span> <span class="ss">:WIN</span>
|
152
|
-
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">Player wins
|
164
|
+
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">Player wins!</span><span class="se">\n</span><span class="s2">"</span>
|
153
165
|
<span class="k">when</span> <span class="ss">:LOSE</span>
|
154
|
-
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">Computer wins
|
166
|
+
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">Computer wins!</span><span class="se">\n</span><span class="s2">"</span>
|
155
167
|
<span class="k">else</span>
|
156
|
-
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">It's a tie
|
168
|
+
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">It's a tie!</span><span class="se">\n</span><span class="s2">"</span>
|
157
169
|
<span class="k">end</span>
|
170
|
+
<span class="nb">print</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">[press any key to exit game]"</span>
|
158
171
|
<span class="nb">gets</span>
|
159
172
|
<span class="k">end</span>
|
160
173
|
|
174
|
+
<span class="kp">private</span>
|
161
175
|
<span class="c1"># add module for private methods for the rpsg calculations</span>
|
162
176
|
<span class="k">module</span> <span class="nn">PrivateMethods</span>
|
163
177
|
<span class="k">class</span> <span class="o"><<</span> <span class="nb">self</span>
|
@@ -197,9 +211,9 @@
|
|
197
211
|
<span class="k">end</span>
|
198
212
|
<span class="k">end</span>
|
199
213
|
<span class="k">end</span>
|
200
|
-
|
214
|
+
<span class="kp">public</span>
|
201
215
|
|
202
|
-
<span class="
|
216
|
+
<span class="c1"># private_methods :PrivateMethods</span>
|
203
217
|
|
204
218
|
<span class="k">end</span>
|
205
219
|
|
@@ -220,7 +234,7 @@
|
|
220
234
|
<td><a href="install">Install</a></td>
|
221
235
|
<td><a href="update">Update</a></td>
|
222
236
|
<td><a href="uninstall">Uninstall</a></td>
|
223
|
-
<td><a href="code">
|
237
|
+
<td><a href="code">Full Code</a></td>
|
224
238
|
<td><a href="simple">Simple Code</td>
|
225
239
|
<td><a href="bundler">Bundler</a></td>
|
226
240
|
</tr>
|
data/docs/_site/index.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
8
8
|
<meta name="theme-color" content="#157878"/>
|
9
9
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
|
10
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
10
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=a5baafbc722707c67aa6887b8c329cac4fb1a8fe"/>
|
11
11
|
<script src="assets/js/pace.min.js"></script>
|
12
12
|
|
13
13
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
|
@@ -66,7 +66,7 @@
|
|
66
66
|
<td><a href="install">Install</a></td>
|
67
67
|
<td><a href="update">Update</a></td>
|
68
68
|
<td><a href="uninstall">Uninstall</a></td>
|
69
|
-
<td><a href="code">
|
69
|
+
<td><a href="code">Full Code</a></td>
|
70
70
|
<td><a href="simple">Simple Code</td>
|
71
71
|
<td><a href="bundler">Bundler</a></td>
|
72
72
|
</tr>
|
data/docs/_site/install.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
8
8
|
<meta name="theme-color" content="#157878"/>
|
9
9
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
|
10
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
10
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=a5baafbc722707c67aa6887b8c329cac4fb1a8fe"/>
|
11
11
|
<script src="assets/js/pace.min.js"></script>
|
12
12
|
|
13
13
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
|
@@ -228,7 +228,7 @@
|
|
228
228
|
<td><a href="install">Install</a></td>
|
229
229
|
<td><a href="update">Update</a></td>
|
230
230
|
<td><a href="uninstall">Uninstall</a></td>
|
231
|
-
<td><a href="code">
|
231
|
+
<td><a href="code">Full Code</a></td>
|
232
232
|
<td><a href="simple">Simple Code</td>
|
233
233
|
<td><a href="bundler">Bundler</a></td>
|
234
234
|
</tr>
|
data/docs/_site/readme.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
8
8
|
<meta name="theme-color" content="#157878"/>
|
9
9
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
|
10
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
10
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=a5baafbc722707c67aa6887b8c329cac4fb1a8fe"/>
|
11
11
|
<script src="assets/js/pace.min.js"></script>
|
12
12
|
|
13
13
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
|
@@ -101,7 +101,8 @@
|
|
101
101
|
|
102
102
|
<hr />
|
103
103
|
|
104
|
-
<p>RubyGems page: <a href="https://rubygems.org/gems/rpsg" target="_blank">https://rubygems.org/gems/rpsg</a
|
104
|
+
<p>RubyGems page: <a href="https://rubygems.org/gems/rpsg" target="_blank">https://rubygems.org/gems/rpsg</a>
|
105
|
+
Source Code: <a href="https://github.com/bag3318/rpsg" target="_blank">https://github.com/bag3318/rpsg</a></p>
|
105
106
|
|
106
107
|
|
107
108
|
<footer class="site-footer">
|
@@ -114,7 +115,7 @@
|
|
114
115
|
<td><a href="install">Install</a></td>
|
115
116
|
<td><a href="update">Update</a></td>
|
116
117
|
<td><a href="uninstall">Uninstall</a></td>
|
117
|
-
<td><a href="code">
|
118
|
+
<td><a href="code">Full Code</a></td>
|
118
119
|
<td><a href="simple">Simple Code</td>
|
119
120
|
<td><a href="bundler">Bundler</a></td>
|
120
121
|
</tr>
|
data/docs/_site/simple.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
8
8
|
<meta name="theme-color" content="#157878"/>
|
9
9
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
|
10
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
10
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=a5baafbc722707c67aa6887b8c329cac4fb1a8fe"/>
|
11
11
|
<script src="assets/js/pace.min.js"></script>
|
12
12
|
|
13
13
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
|
@@ -94,7 +94,7 @@
|
|
94
94
|
<td><a href="install">Install</a></td>
|
95
95
|
<td><a href="update">Update</a></td>
|
96
96
|
<td><a href="uninstall">Uninstall</a></td>
|
97
|
-
<td><a href="code">
|
97
|
+
<td><a href="code">Full Code</a></td>
|
98
98
|
<td><a href="simple">Simple Code</td>
|
99
99
|
<td><a href="bundler">Bundler</a></td>
|
100
100
|
</tr>
|
data/docs/_site/test.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
8
8
|
<meta name="theme-color" content="#157878"/>
|
9
9
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
|
10
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
10
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=a5baafbc722707c67aa6887b8c329cac4fb1a8fe"/>
|
11
11
|
<script src="assets/js/pace.min.js"></script>
|
12
12
|
|
13
13
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
|
@@ -82,7 +82,7 @@
|
|
82
82
|
<td><a href="install">Install</a></td>
|
83
83
|
<td><a href="update">Update</a></td>
|
84
84
|
<td><a href="uninstall">Uninstall</a></td>
|
85
|
-
<td><a href="code">
|
85
|
+
<td><a href="code">Full Code</a></td>
|
86
86
|
<td><a href="simple">Simple Code</td>
|
87
87
|
<td><a href="bundler">Bundler</a></td>
|
88
88
|
</tr>
|
data/docs/_site/uninstall.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
8
8
|
<meta name="theme-color" content="#157878"/>
|
9
9
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
|
10
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
10
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=a5baafbc722707c67aa6887b8c329cac4fb1a8fe"/>
|
11
11
|
<script src="assets/js/pace.min.js"></script>
|
12
12
|
|
13
13
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
|
@@ -75,7 +75,7 @@
|
|
75
75
|
<td><a href="install">Install</a></td>
|
76
76
|
<td><a href="update">Update</a></td>
|
77
77
|
<td><a href="uninstall">Uninstall</a></td>
|
78
|
-
<td><a href="code">
|
78
|
+
<td><a href="code">Full Code</a></td>
|
79
79
|
<td><a href="simple">Simple Code</td>
|
80
80
|
<td><a href="bundler">Bundler</a></td>
|
81
81
|
</tr>
|
data/docs/_site/update.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
8
8
|
<meta name="theme-color" content="#157878"/>
|
9
9
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
|
10
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
10
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=a5baafbc722707c67aa6887b8c329cac4fb1a8fe"/>
|
11
11
|
<script src="assets/js/pace.min.js"></script>
|
12
12
|
|
13
13
|
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
|
@@ -75,7 +75,7 @@
|
|
75
75
|
<td><a href="install">Install</a></td>
|
76
76
|
<td><a href="update">Update</a></td>
|
77
77
|
<td><a href="uninstall">Uninstall</a></td>
|
78
|
-
<td><a href="code">
|
78
|
+
<td><a href="code">Full Code</a></td>
|
79
79
|
<td><a href="simple">Simple Code</td>
|
80
80
|
<td><a href="bundler">Bundler</a></td>
|
81
81
|
</tr>
|
data/lib/Constants.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
module Constants
|
3
3
|
|
4
4
|
# create 2d list of choices
|
5
|
+
protected
|
5
6
|
CHOICES = [['r', 'rock'], ['p', 'paper'], ['s', 'scissors']]
|
6
7
|
|
7
8
|
# define entry to symbol (key to value)
|
9
|
+
protected
|
8
10
|
NTRY_TO_SYM = {
|
9
11
|
CHOICES[0][0] => :ROCK , CHOICES[0][1] => :ROCK ,
|
10
12
|
CHOICES[1][0] => :PAPER , CHOICES[1][1] => :PAPER ,
|
@@ -12,12 +14,15 @@ module Constants
|
|
12
14
|
}
|
13
15
|
|
14
16
|
# define valid entries
|
17
|
+
protected
|
15
18
|
VALID_ENTRIES = NTRY_TO_SYM.keys
|
16
19
|
|
17
20
|
# define computer choices
|
21
|
+
protected
|
18
22
|
COMPUTER_CHOICES = NTRY_TO_SYM.values
|
19
23
|
|
20
24
|
# create winners 2d list array with format: winning choice, losing choice
|
25
|
+
protected
|
21
26
|
WINNERS = [
|
22
27
|
[:SCISSORS, :PAPER ],
|
23
28
|
[:PAPER , :ROCK ],
|
@@ -25,6 +30,7 @@ module Constants
|
|
25
30
|
]
|
26
31
|
|
27
32
|
# this will take the original WINNERS array and flip the symbols, thus returning a loss for the user/player
|
33
|
+
protected
|
28
34
|
LOSERS = WINNERS.map { |winning_choice,losing_choice| [losing_choice,winning_choice] }
|
29
35
|
|
30
36
|
end
|
data/lib/Main.rb
CHANGED
@@ -5,7 +5,7 @@ class RockPaperScissorsGame
|
|
5
5
|
|
6
6
|
require "Constants.rb"
|
7
7
|
|
8
|
-
protected_methods :Constants
|
8
|
+
# protected_methods :Constants
|
9
9
|
|
10
10
|
class << self
|
11
11
|
# add continue method for asking the user if they want to play rock paper scissors
|
@@ -52,18 +52,19 @@ class RockPaperScissorsGame
|
|
52
52
|
"computer: #{@computer_score} (ties: #{@ties}).\n"
|
53
53
|
case PrivateMethods.final_outcome(@player_score, @computer_score)
|
54
54
|
when :WIN
|
55
|
-
puts "\nPlayer wins
|
55
|
+
puts "\nPlayer wins!\n"
|
56
56
|
when :LOSE
|
57
|
-
puts "\nComputer wins
|
57
|
+
puts "\nComputer wins!\n"
|
58
58
|
else
|
59
|
-
puts "\nIt's a tie
|
59
|
+
puts "\nIt's a tie!\n"
|
60
60
|
end
|
61
|
+
print "\n[press any key to exit game]"
|
61
62
|
gets
|
62
63
|
end
|
63
64
|
|
64
65
|
require "PrivateMethods.rb"
|
65
66
|
|
66
|
-
private_methods :PrivateMethods
|
67
|
+
# private_methods :PrivateMethods
|
67
68
|
|
68
69
|
end
|
69
70
|
|
data/lib/PrivateMethods.rb
CHANGED
data/lib/rpsg/version.rb
CHANGED
data/rpsg.gemspec
CHANGED