Module: Pc::RockPaperScissors

Includes:
Game
Defined in:
lib/pc/games/rock_paper_scissors.rb

Instance Method Summary collapse

Methods included from Game

#choose, included, #prompt_move, #random_move, #show_outcome, #welcome

Methods included from Loop

#exit, #goodbye, included, #run, #say, #welcome

Instance Method Details

#compare_moves(move_a, move_b) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/pc/games/rock_paper_scissors.rb', line 15

def compare_moves(move_a, move_b)
  case "#{move_a}#{move_b}"
    when 'RS', 'SP', 'PR' then 1
    when 'RP', 'SR', 'PS' then -1
    else 0
  end
end

#movesObject



11
12
13
# File 'lib/pc/games/rock_paper_scissors.rb', line 11

def moves
  {rock: 'R', paper: 'P', scissors: 'S'}
end

#rulesObject



7
8
9
# File 'lib/pc/games/rock_paper_scissors.rb', line 7

def rules
  'Rock beats Scissors beats Paper beats Rock'
end