Class: Rockpaperscissorsbattle::Game
- Inherits:
-
Object
- Object
- Rockpaperscissorsbattle::Game
- Defined in:
- lib/rockpaperscissorsbattle/game.rb
Instance Method Summary collapse
- #compare(pick1, pick2) ⇒ Object
-
#initialize(args = {}) ⇒ Game
constructor
A new instance of Game.
- #play ⇒ Object
- #welcome ⇒ Object
Constructor Details
Instance Method Details
#compare(pick1, pick2) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rockpaperscissorsbattle/game.rb', line 23 def compare(pick1, pick2) if @options[pick1] == pick2 puts "Player1 wins!" winner = 1 elsif @options[pick2] == pick1 puts "Player2 wins!" winner = 2 else puts "You tied..." winner = 0 end end |
#play ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/rockpaperscissorsbattle/game.rb', line 13 def play puts "Get ready to Battle!" print "Player 1:" pick1 = @player1.pick(@options) print "Player 2:" pick2 = @player2.pick(@options) compare(pick1, pick2) end |
#welcome ⇒ Object
9 10 11 |
# File 'lib/rockpaperscissorsbattle/game.rb', line 9 def welcome puts "Welcome to Rock Paper Scissors" end |