Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:11160503
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
result =['Scissors cut paper', #0
'Paper covers rock', #01
'Rock crushes lizard', #02
'Lizard poisons Spock', #03
'Spock smashes scissors', #04
'Scissors decapitate lizard', #05
'Lizard eats paper', #06
'Paper disproves Spock', #07
'Spock vaporizes rock', #08
'Rock crushes scissors'] #09
 
ai = ['r','p','s','l','k']
 
while true
 
puts( 'Welcome to Rock-Paper-Scissors-Lizard-Spock!'.center(line_width = 50))
puts ''
puts 'Please pick your attack by selecting the corresponding letter.'
puts ''
puts 'R: Rock'
puts 'P: Paper'
puts 'S: Scissors'
puts 'L: Lizard'
puts 'K: Spock'
 
player = gets.chomp
 
while player.downcase != 'done'
ai_rand = ai.sample
# player picks rock
if player.downcase == 'r' && ai_rand == 'l'
puts result[2] + ', you win!'
elsif player.downcase == 'r' && ai_rand == 's'
puts result[9] + ', you win!'
#rock looses
elsif player.downcase == 'r' && ai_rand == 'p'
puts result[1] + ', you loose!'
elsif player.downcase == 'r' && ai_rand == 'k'
puts result[8] + ', you loose!'
elsif player.downcase == 'r' && ai_rand == 'r'
puts 'It\'s a tie!'
end
# player picks paper
if player.downcase == 'p' && ai_rand == 'r'
puts result[1] + ', you win!'
elsif player.downcase == 'p' && ai_rand == 'k'
puts result[7] + ', you win!'
elsif player.downcase == 'p' && ai_rand == 's'
puts result[0] + ', you loose!'
elsif player.downcase == 'p' && ai_rand == 'l'
puts result[6] + ', you loose!'
elsif player.downcase == 'p' && ai_rand == 'p'
puts 'It\'s a tie!'
end
# player picks scissors
if player.downcase == 's' && ai_rand == 'p'
puts result[0] + ', you win!'
elsif player.downcase == 's' && ai_rand == 'l'
puts result[5] + ', you win!'
elsif player.downcase == 's' && ai_rand == 'k'
puts result[4] + ', you loose!'
elsif player.downcase == 's' && ai_rand == 'r'
puts result[9] + ', you loose!'
elsif player.downcase == 's' && ai_rand == 's'
puts 'It\'s a tie!'
end
# player picks lizard
if player.downcase == 'l' && ai_rand == 'k'
puts result[3] + ', you win!'
elsif player.downcase == 'l' && ai_rand == 'p'
puts result[6] + ', you win!'
elsif player.downcase == 'l' && ai_rand == 'r'
puts result[2] + ', you loose!'
elsif player.downcase == 'l' && ai_rand == 's'
puts result[5] + ', you loose!'
elsif player.downcase == 'l' && ai_rand == 'l'
puts 'It\'s a tie!'
end
# player picks spock
if player.downcase == 'k' && ai_rand == 's'
puts result[4] + ', you win!'
elsif player.downcase == 'k' && ai_rand == 'r'
puts result[8] + ', you win!'
elsif player.downcase == 'k' && ai_rand == 'l'
puts result[3] + ', you loose!'
elsif player.downcase == 'k' && ai_rand == 'p'
puts result[7] + ', you loose!'
elsif player.downcase == 'k' && ai_rand == 'k'
puts 'It\'s a tie!'
end
puts ''
puts 'press enter to play again or say "done" if you\'re finished.'
player = gets.chomp
break
end
if player.downcase == 'done'
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.