Module: Pc::OddsAndEvens
- Includes:
- Game
- Defined in:
- lib/pc/games/odds_and_evens.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
|
# File 'lib/pc/games/odds_and_evens.rb', line 15
def compare_moves(move_a, move_b)
case move_a + move_b when ->(sum) { sum.odd? } then 1
when ->(sum) { sum.even? } then -1
end
end
|
#moves ⇒ Object
11
12
13
|
# File 'lib/pc/games/odds_and_evens.rb', line 11
def moves
{'1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5}
end
|
#rules ⇒ Object
7
8
9
|
# File 'lib/pc/games/odds_and_evens.rb', line 7
def rules
'Odd sum wins, even sum loses'
end
|