-
-
Save gouf/22ca4acd06be0769f2db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
あいて = %w(ぐー ちょき ぱー) | |
じゃんけん = { :"ぐー" => 0, | |
:"ちょき" => 1, | |
:"ぱー" => 2} | |
loop do | |
print 'じゃんけん... :' | |
ぷれいやーの手 = gets.chomp | |
break if ぷれいやーの手 == 'やめる' | |
あいての手 = あいて.sample | |
puts "相手の手#{あいての手}" | |
result_num = (じゃんけん[ぷれいやーの手.to_sym] - | |
じゃんけん[あいての手.to_sym]) | |
if あいての手 == ぷれいやーの手 | |
puts 'あいこ!' | |
elsif [-1, 2].include?(result_num) | |
puts 'かち!' | |
else | |
puts 'まけ!' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment