class Rpsdz::Game
Public Instance Methods
rps()
click to toggle source
main script
# File lib/game.rb, line 9 def rps puts "Would you like to play against computer or play two player? (Type 'c' or '2p')" mode = gets.chomp if mode == "c" puts "Enter P1 Name: " p1 = Player.new(gets.chomp) computer = Computer.new play(p1, computer) elsif mode == "2p" puts "Enter P1 Name: " p1 = Player.new(gets.chomp) puts "Enter P2 Name: " p2 = Player.new(gets.chomp) play(p1, p2) else raise "Invalid input" end end
Private Instance Methods
play(p1, p2)
click to toggle source
# File lib/game.rb, line 33 def play(p1, p2) keep_playing = true while (keep_playing) p1.showdown(p2) puts "Play again? (y/n): " if gets.chomp.downcase == 'n' keep_playing = false puts "Thanks for playing!" else end end end