docs/_site/code.html in rpsg-0.3.4 vs docs/_site/code.html in rpsg-0.3.5
- old
+ new
@@ -5,11 +5,11 @@
<title>Complete Code - RPSG</title>
<meta name="description" content="A Ruby Programmed Rock Paper Scissors Game"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="theme-color" content="#157878"/>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css' />
- <link rel="stylesheet" href="/assets/css/style.css?v=99aa3ba4838f7c1dfc972536e8124d81a090c7b3"/>
+ <link rel="stylesheet" href="/assets/css/style.css?v=147b36b436427ee81aaa6c863020ff4c4b0507e2"/>
<script src="assets/js/pace.min.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicons/apple-touch-icon.png"/>
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicons/favicon-32x32.png"/>
<link rel="icon" type="image/png" sizes="16x16" href="assets/favicons/favicon-16x16.png"/>
@@ -72,11 +72,11 @@
<span class="k">class</span> <span class="nc">RockPaperScissorsGame</span>
<span class="c1"># specify the version for the rubygem</span>
<span class="k">module</span> <span class="nn">RPSG</span>
<span class="c1"># create version constant for the rubygem</span>
- <span class="no">VERSION</span> <span class="o">=</span> <span class="s2">"0.3.4"</span>
+ <span class="no">VERSION</span> <span class="o">=</span> <span class="s2">"0.3.5"</span>
<span class="k">end</span>
<span class="c1"># create module that holds all contents for this script</span>
<span class="k">module</span> <span class="nn">Constants</span>
@@ -125,11 +125,11 @@
<span class="nb">puts</span> <span class="n">str3</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># print out strings</span>
- <span class="n">continue</span><span class="p">(</span><span class="s2">"You are about to enter a rock-paper-scissors best of 3 match."</span><span class="p">,</span> <span class="s2">"Press the return/enter key to continue..."</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span>
+ <span class="n">continue</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">You are about to enter a rock-paper-scissors best of 3 match."</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">Press the return/enter key to continue..."</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span>
<span class="c1"># initialize variables</span>
<span class="k">def</span> <span class="nf">initialize</span>
<span class="c1"># initialize variables and set all equal to zero</span>
<span class="vi">@player_score</span> <span class="o">=</span> <span class="vi">@computer_score</span> <span class="o">=</span> <span class="vi">@ties</span> <span class="o">=</span> <span class="mi">0</span>
@@ -137,11 +137,11 @@
<span class="c1"># define play method, this will be the main function for playing rock paper scissors</span>
<span class="k">def</span> <span class="nf">play</span><span class="p">(</span><span class="n">winning_score</span><span class="p">)</span>
<span class="c1"># make while loop</span>
<span class="k">while</span> <span class="vi">@player_score</span> <span class="o"><</span> <span class="n">winning_score</span> <span class="o">&&</span> <span class="vi">@computer_score</span> <span class="o"><</span> <span class="n">winning_score</span>
- <span class="nb">puts</span> <span class="s2">"Player score: </span><span class="si">#{</span><span class="vi">@player_score</span><span class="si">}</span><span class="s2">, "</span> <span class="o">+</span>
+ <span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">Player score: </span><span class="si">#{</span><span class="vi">@player_score</span><span class="si">}</span><span class="s2">, "</span> <span class="o">+</span>
<span class="s2">"Computer score: </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>
<span class="n">player</span> <span class="o">=</span> <span class="no">PrivateMethods</span><span class="p">.</span><span class="nf">player_choice</span>
<span class="n">computer</span> <span class="o">=</span> <span class="no">Constants</span><span class="o">::</span><span class="no">COMPUTER_CHOICES</span><span class="p">.</span><span class="nf">sample</span> <span class="c1"># chooses a random option</span>
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">Player chooses </span><span class="si">#{</span><span class="n">player</span><span class="p">.</span><span class="nf">to_s</span><span class="p">.</span><span class="nf">downcase</span><span class="si">}</span><span class="s2">."</span>
<span class="nb">puts</span> <span class="s2">"Computer chooses </span><span class="si">#{</span><span class="n">computer</span><span class="p">.</span><span class="nf">to_s</span><span class="p">.</span><span class="nf">downcase</span><span class="si">}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">"</span>
@@ -185,16 +185,9 @@
<span class="k">elsif</span> <span class="n">choice</span> <span class="o">!=</span> <span class="no">Constants</span><span class="o">::</span><span class="no">VALID_ENTRIES</span>
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">That entry is invalid. Please re-enter.</span><span class="se">\n</span><span class="s2">"</span>
<span class="k">else</span>
<span class="k">return</span> <span class="kp">nil</span>
<span class="k">end</span>
- <span class="c1"># # one may also do this:</span>
- <span class="c1"># case</span>
- <span class="c1"># when Constants::NTRY_TO_SYM.key?(choice)</span>
- <span class="c1"># return Constants::NTRY_TO_SYM[choice]</span>
- <span class="c1"># when choice != Constants::VALID_ENTRIES</span>
- <span class="c1"># puts "That entry is invalid. Please re-enter." </span>
- <span class="c1"># end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># define outcomes of players choice against cpu</span>
<span class="k">def</span> <span class="nf">player_outcome</span><span class="p">(</span><span class="n">plays</span><span class="p">)</span>
<span class="k">return</span> <span class="ss">:WIN</span> <span class="k">if</span> <span class="no">Constants</span><span class="o">::</span><span class="no">WINNERS</span><span class="p">.</span><span class="nf">include?</span><span class="p">(</span><span class="n">plays</span><span class="p">)</span>