Skip to content

Instantly share code, notes, and snippets.

@seanrclayton
Created April 16, 2014 15:11
Show Gist options
  • Save seanrclayton/10891677 to your computer and use it in GitHub Desktop.
Save seanrclayton/10891677 to your computer and use it in GitHub Desktop.
@player_win_count = 0
@op_win_count = 0
def game
choices = ['rock', 'paper', 'scissors' ]
playthrow = choices.sample
puts "player throws #{playthrow}"
opthrow = choices.sample
puts "oponent throws #{opthrow}"
if playthrow == 'rock' && opthrow == 'paper'
@op_win_count += 1
puts "opponent wins their score is #{@op_win_count}"
elsif playthrow == 'paper' && opthrow == 'scissors'
@op_win_count += 1
puts "opponent wins their score is #{@op_win_count}"
elsif playthrow == 'scissors' && opthrow == 'rock'
@op_win_count += 1
puts "opponent wins their score is #{@op_win_count}"
elsif playthrow == opthrow
puts 'draw'
else
@player_win_count += 1
puts "player wins their score is #{@player_win_count}"
end
throw
end
def throw
puts "Throw Again?"
answer = gets.chomp
if answer == "y"
game
elsif answer == "n"
puts "Goodbye"
else
puts "I have no idea what you said put y or n"
throw
end
end
game
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment