Sha256: 4a6fc8af00bc11f7cfce497c5812a977c0f8657780f1122eb034936a542fffb8
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require "colorized_string" ColorizedString.colors ColorizedString.modes module Constants CHOICES = [['r', 'rock'], ['p', 'paper'], ['s', 'scissors']] 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 # create 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 = [ ColorizedString["You are about to enter a rock-paper-scissors best of 3 match."].colorize(:green), ColorizedString["Press the return/enter key to continue..."].colorize(:green), "" ] end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rpsg-0.0.2 | lib/Constants.rb |
rpsg-0.0.1 | lib/Constants.rb |