Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Rock, paper, sicssiors game assistance

$
0
0
So there are 3 things I am not understanding. the first thing that I'm not uderstanding is how to make the game go for x amount of times without starting the game over. So if a player wants to play 10 games at once I want them to be able to play that much. The second thing is where to put another if statement to ask the player if they want to quite the game.I think it would go in the game area, but I'm not 100% sure. The last thing is to keep track of the score of wins, loses and tie between the player and the computer. Thanks for the assistance and the understanding

 puts "Would you like to play a Game?"
     puts "Yes/No"
     player_input = gets.chomp.downcase
     if player_input == 'yes'
       puts "Welcome to Rock, Paper, Scissors!"
       puts "Press r for Rock"
       puts "Press s for Scissors"
       puts "Press p for Paper"
       computer = "rsp"[rand(3)].chr
       player = $stdin.gets.chomp.downcase
       case [player, computer]
         when ['p','r'], ['s','p'], ['r','s']
           puts "You Win!"
         when ['r','r'], ['s','s'], ['p','p']
           puts "You Tied!"
         else
           puts "You Lose!"
       end
       puts "The computer chose: #{computer.upcase}"
       
     else player_input = "no"
       puts "Come again soon. :)/>"
     end

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>