Sha256: 9748a29bfb92264bfb495e325cac78b1b23d3a996ec5bd6754a179a065f26c0d
Contents?: true
Size: 1009 Bytes
Versions: 6
Compression:
Stored size: 1009 Bytes
Contents
module Constants CHOICES = [['r', 'rock'], ['p', 'paper'], ['s', 'scissors']] # create 2d list of choices NTRY_TO_SYM = { # define entry to symbol (key to value) CHOICES[0][0] => :ROCK , CHOICES[0][1] => :ROCK , CHOICES[1][0] => :PAPER , CHOICES[1][1] => :PAPER , CHOICES[2][0] => :SCISSORS, CHOICES[2][1] => :SCISSORS } VALID_ENTRIES = NTRY_TO_SYM.keys # define valid entries COMPUTER_CHOICES = NTRY_TO_SYM.values # define computer choices WINNERS = [ # format: player choice, computer choice [:SCISSORS, :PAPER ], [:PAPER , :ROCK ], [:ROCK , :SCISSORS] ] LOSERS = WINNERS.map { |winning_choice,losing_choice| [losing_choice,winning_choice] } # this will take the original WINNERS array and flip the symbols, thus returning a loss for the user/player INIT_STRINGS = [ "You are about to enter a rock-paper-scissors best of 3 match.", "Press the return/enter key to continue...", "" ] end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
rpsg-0.1.1 | lib/Constants.rb |
rpsg-0.1.0 | lib/Constants.rb |
rpsg-0.0.9 | lib/Constants.rb |
rpsg-0.0.8 | lib/Constants.rb |
rpsg-0.0.7 | lib/Constants.rb |
rpsg-0.0.6 | lib/Constants.rb |