PlayRockPaperScissorsGame 2.2.8 → 2.2.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c303d5489fb2163b57885ad0d8ec81e4ffdd30ae
4
- data.tar.gz: 263038389f15625806e205c754aab5a3d0cd9bae
3
+ metadata.gz: c55b786ac8edef96c4a2eeb17aba34b5d94df509
4
+ data.tar.gz: 9deeacd39145b469bcd0748ab92b1aec14a41762
5
5
  SHA512:
6
- metadata.gz: 87df47fc0184b393d6ff382705bc1a2cdad67e308e9ad8a11a7bebd0c9f15905f36451e69129dd138d41e38367e21e390e9bcd865d67ab5f0739e673560a3c86
7
- data.tar.gz: f52747c5ec96730e819c7b8e1f68ca6c43a29c61b4ebd290bbe095f3995e711709678eab1b96def0606f0e74751a847d140a5133accf51dd4721712ccf6b9765
6
+ metadata.gz: 465a65325bcf84289192e51980d10ee1310c0b26dd4164a69c45d1ba43137934b9cc4caa7fa793bcb4c77399660bdb37713f2bbc51f51e2dc2ae9cd8f03aebf1
7
+ data.tar.gz: 1ae6a4d92bb7808cfe4e2ad6ab5f019c076ee54c36597dfd671409282dcf607d84c034de0bd3b1b1ee1b2a1ec92a09d5badd99719a3087f57bb8772e81452f42
checksums.yaml.gz.sig CHANGED
@@ -1,4 +1 @@
1
- �����4��
2
- �L'��I��� x<�Su�����_�k������i�����5fF ������ؐ��3��\E���L�
3
- �c�fy� ��9�.Di������)<*���-��7�qm/���/6�Dw>�5Dr�G��{*���_:
4
- f}���ۺ���+��1��G'm{���1��OޟR��2�H��ѳ���J=:1<.��>�ʥ�r:)]��b��;v�
1
+ L<͒yǢk�0ўR<�-�n�sm��~���;��R�� xŦxt�M�ZK�m 8��`­��X�ߚ�1�����V�F����1���8m�r�j��a ��r�/�Pj��dB;���תf�_�93��6:�#~Aekw߄�%,�[���P�d��t��ي�%8�b{�tD��1�����g`�R�M$9���A���0�f�'j���Y���9���R�� �'+�R𐋁>d�6�1 �Y|3�I�uN���Vn�sit�
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  *.sublime-project
5
5
  *.sublime-workspace
6
6
  *.jekyll-metadata
7
+ *master
7
8
  # _site
8
9
  # .sass-cache
9
10
 
@@ -12,7 +12,6 @@
12
12
  class PlayRockPaperScissorsGame
13
13
 
14
14
  require_relative "./../lib/rps/version.rb"
15
-
16
15
  # intiate the colorize gem
17
16
  require "colorized_string"
18
17
  ColorizedString.colors
@@ -22,29 +21,29 @@ class PlayRockPaperScissorsGame
22
21
 
23
22
  protected_methods :Constants
24
23
 
25
- class << self
24
+ class << self # make continue a self calling method
26
25
  def continue(str1,str2,str3) # pass in 3 parameters
27
- puts ColorizedString[str1].colorize(:color => :green)
26
+ puts ColorizedString[str1].colorize(:color => :green) # make string output green text
28
27
  print ColorizedString[str2].colorize(:color => :green)
29
28
  gets # press enter or return to continue
30
29
  puts ColorizedString[str3].colorize(:color => :green)
31
30
  end
32
31
  end
33
32
 
34
- continue(Constants::INIT_STRINGS[0], Constants::INIT_STRINGS[1], Constants::INIT_STRINGS[2])
33
+ continue(Constants::INIT_STRINGS[0], Constants::INIT_STRINGS[1], Constants::INIT_STRINGS[2]) # define passed in parameters
35
34
 
36
35
  def initialize
37
- @player_score = @computer_score = @ties = 0
36
+ @player_score = @computer_score = @ties = 0 # intialize variables
38
37
  end
39
38
  def play(winning_score)
40
- while @player_score < winning_score && @computer_score < winning_score
39
+ while @player_score < winning_score && @computer_score < winning_score # both the player's and the computer's score have to be less than 3
41
40
  puts ColorizedString["Player score: #{@player_score}, "].colorize(:blue) +
42
41
  ColorizedString["Computer score: #{@computer_score}, Ties: #{@ties}"].colorize(:blue)
43
42
  player = PrivateMethods.player_choice
44
- computer = Constants::COMPUTER_CHOICES.sample # chooses a random option
43
+ computer = Constants::COMPUTER_CHOICES.sample # chooses a random option for the computer
45
44
  puts ColorizedString["\nPlayer chooses #{player.to_s.downcase}"].colorize(:blue)
46
45
  puts ColorizedString["Computer chooses #{computer.to_s.downcase}"].colorize(:blue)
47
- case PrivateMethods.player_outcome [player, computer]
46
+ case PrivateMethods.player_outcome [player, computer] # pass in player and computer for the contants arrays
48
47
  when :WIN
49
48
  puts ColorizedString["#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round"].colorize(:red)
50
49
  @player_score += 1
data/bin/rps CHANGED
@@ -75,4 +75,4 @@ class PlayRockPaperScissorsGame
75
75
 
76
76
  end
77
77
 
78
- PlayRockPaperScissorsGame.new.play(2) # best of 3
78
+ PlayRockPaperScissorsGame.new.play(2) # best of 3
data/lib/Constants.rb CHANGED
@@ -7,13 +7,14 @@ module Constants
7
7
  'r' => :ROCK,
8
8
  's' => :SCISSORS
9
9
  }
10
- VALID_ENTRIES = NTRY_TO_SYM.keys
11
- COMPUTER_CHOICES = NTRY_TO_SYM.values
10
+ VALID_ENTRIES = NTRY_TO_SYM.keys # create valid entries
11
+ COMPUTER_CHOICES = NTRY_TO_SYM.values # define computer choices
12
12
  WINNERS = [
13
+ # format: player choice, computer choice
13
14
  [:SCISSORS, :PAPER],
14
15
  [:PAPER, :ROCK],
15
16
  [:ROCK, :SCISSORS]
16
- ] # format: player choice, computer choice
17
+ ]
17
18
  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
18
19
  INIT_STRINGS = [
19
20
  ColorizedString["You are about to enter a rock-paper-scissors best of 3 match."].colorize(:green),
@@ -10,7 +10,7 @@ module PrivateMethods
10
10
  if Constants::NTRY_TO_SYM.key?(choice)
11
11
  return Constants::NTRY_TO_SYM[choice]
12
12
  elsif choice != Constants::VALID_ENTRIES
13
- puts ColorizedString["That entry is invalid. Please re-enter"].colorize(:green)
13
+ puts ColorizedString["That entry is invalid. Please re-enter."].colorize(:red)
14
14
  end
15
15
  # # one may also do this:
16
16
  # case
data/lib/rps/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RockPaperScissors
2
- VERSION = "2.2.8"
2
+ VERSION = "2.2.9"
3
3
  end
data/rps.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "PlayRockPaperScissorsGame"
3
- spec.version = "2.2.8"
3
+ spec.version = "2.2.9"
4
4
  spec.date = "2017-04-04"
5
5
  spec.summary = "A Rock Paper Scissors Ruby Gem"
6
6
  spec.description = <<-EOF
data.tar.gz.sig CHANGED
Binary file
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: 2.2.8
4
+ version: 2.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - bag3318
metadata.gz.sig CHANGED
Binary file