Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.53 KB | None | 0 0
  1. things = ["Scissors", "Paper", "Rock", "Lizard", "Spock"]
  2. bot = things.sample
  3. puts "Let's play a round of RPSLS!\n Choose wisely:\n\t0) #{things[0]}\n\t1) #{things[1]}\n\t2) #{things[2]}\n\t3) #{things[3]}\n\t4) #{things[4]}\n"
  4. player = things[gets.chomp.to_i]
  5. conditions = ["I chose #{bot}. Draw", "I chose #{bot}. You lose! #{bot} beats #{player}.", "I chose #{bot}. You win! #{player} beats #{bot}."]
  6. distance = (things.index(player) - things.index(bot))
  7. puts conditions[distance == 0 ? 0 : ([1,-2,3,-4].include?(distance) ? 1 : -1)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement