ใ๐ฐๅๅฟ่ ใRubyใงใฎใใใใใใปใใฃใกๅใใฆใใคใขใใชใฎไฝๆ(ใใฃใกๅใใฆใใค้จๅ)
่งฃๆฑบใใใใใจ
ใใใใใ๏ผใใฃใกๅใใฆใใคใขใใชใฎ
ใใฃใกๅใใฆใใค้จๅใซ
โ ใใใใใใใซๅใฃใๅ ดๅใโๅใๆนๅใ้ธใใ ใๅใกใ้ใใชใใใฃใกๅใใฆใใคใใใ็ดใ
โกใใใใใใใซ่ฒ ใใๅ ดๅใโๅใๆนๅใ้ธใใ ใ่ฒ ใใ้ใใชใใใฃใกๅใใฆใใคใใใ็ดใ
ใจใใใณใผใใๆธใใใใจๆใฃใฆใใพใใ
็พๅจใๅใๆนๅใ้ธใใ ใๅใกใใใใไปฅๅคใชใใปใปใปใใจใใ้จๅใใ
ใณใผใใๆธใใฆใใชใใฎใงใใใใใฎๆกไปถๅๅฒใๆดใซๅคงๆ ใงใใใๅ
็จใฎใใใใใใงใฎๅใก่ฒ ใใใงๅฒใใซใฏใฉใฎใใใชๆธใๆนใ่ฏใใฎใ๏ผ๏ผcaseๆใงไธๆใใณใผใใฃใณใฐใใงใใใๆใๆญขใพใฃใฆใใพใใ๏ผ
ๆฉใใงใใพใใ
๏ผใค๏ผใคใคใณใฟใผใใใใงๆๅณใ่ชฟในใฆ็่งฃใใใใจใฏใงใใใฎใงใใใๅฎ้ใซ็ตใฟ็ซใฆใ็ต้จใ
่ถณใใฆใใชใใจๅฎๆใใฆใใพใใ๏ผใขใฆใใใใ๏ผ
ไปฅไธ็พๅจใฎใณใผใใงใใไธ้จใใใฃใกๅใใฆใใคใฎ้จๅใงใใ
๏ผๅๅใฎ่ณชๅใซใฆๆใใฆ้ ใใใณใผใ๏ผไธ้จใๅฎ่ฃ ไธญ๏ผ
require "csv"
puts"------------------------------"
puts"ใใฃใกๅใใฆใใคใฒใผใ ใๅงใใพใใ"
def janken
puts "ใใใใใใปใปใป"
puts "0(ใฐใผ)1(ใใงใญ)2(ใใผ)3(ๆฆใใชใ)"
select_number = gets.to_i
if !(select_number == 0 || select_number == 1 || select_number ==2)
select_number = 3
end
random_number = rand(3)
case_pattern = 0
jankens = ["ใฐใผ","ใใงใญ","ใใผ","ๆฆใใชใ"]
puts "ใใชใ๏ผ#{jankens[select_number]} ็ธๆ๏ผ#{jankens[random_number]}"
puts"------------------------------"
if select_number ==3 || random_number == 3
puts"ใใใใใใๆพๆฃใใใพใใใใฒใผใ ใ็ตไบใใพใใ"
case_pattern = 3
else
number = select_number - random_number
case number
when 0 then
puts "ใใใใงใใใใไธๅบฆใใใใใใใใพใใ"
case_pattern = janken
when 1, -2 then
puts"ใใใใใใซ่ฒ ใใพใใใใใฃใกใใใฆใปใปใป"
case_pattern = 2
when -1, 2 then
puts "ใใใใใใซๅใกใพใใใใใฃใกใใใฆใปใปใป"
case_pattern = 1
end
end
end
if result = janken == 3
return
end
puts "0(ไธ)1(ไธ)2(ๅทฆ)3(ๅณ)"
select_number2 = gets.to_i
random_number2 =rand(3)
directions = ["ไธ","ไธ","ๅทฆ","ๅณ"]
puts "ใใชใ๏ผ#{directions[select_number2]} ็ธๆ๏ผ#{directions[random_number2]}"
puts"------------------------------"
# ไปฅไธใซใใใใใใใซๅใฃใๅ ดๅใใจใ่ฒ ใใๅ ดๅใใจใใๆกไปถใ่ฟฝๅ ใใใใใซใใใฃใกๅใใฆใปใปใปใใฎๅ ดๅใฏ็นฐใ่ฟใใซใใใ
if select_number2 == random_number2
puts"ใใชใใฎๅใกใงใ๏ผใใใงใจใ"
else
puts"ใใฃใกๅใใฆใปใปใป"
end
if select_number2 == random_number2
puts"ใใชใใฎ่ฒ ใใงใใปใปใปๆฎๅฟต"
else
puts "ใใฃใกๅใใฆใปใปใป"
end
่ฟฝ่จ
ใ่จ่ใง่ใใใใฎใๅฎ่ฃ ใใฆใใๅใไปใใใซใฏใไฝๅบฆใใใใใฃใใขใใชใไฝใฃใฆๆ ฃใใใใจใงๅฟ็จใๅฉใใใใซใชใใฎใงใใใใใใๆกไปถๅๅฒใฎๆกไปถๅๅฒใใใcaseใใdefใปใปใปendใใชใฉใ็ตใฟๅใใใใใใใใซใชใใใใงใใ